Comparar commits
46 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 4268e3a1d2 | |||
| 860b9a266a | |||
| c39d752ccb | |||
| 15db1cf385 | |||
| 38d684d1e6 | |||
| ccb1bc514b | |||
| 27c46a2c8e | |||
| ff2f1d237a | |||
| 402f4c162c | |||
| 81013a98b4 | |||
| 971dd622c7 | |||
| 0045d31e2d | |||
| caef8f4ebc | |||
| 6116c1ae71 | |||
| 03ecf2b0bb | |||
| d4a5005273 | |||
| 7522f29f0a | |||
| 09f0a2e4a6 | |||
| aa846929f3 | |||
| b378af7cb1 | |||
| 8b549a487f | |||
| 005f659eaa | |||
| a5aad94f24 | |||
| 52a6926da3 | |||
| b3c0f003bb | |||
| 3d2360bc56 | |||
| 1267f51d8c | |||
| e7328001a4 | |||
| fc7b53e809 | |||
| 50637cb3c2 | |||
| 11b4203874 | |||
| 60beb432eb | |||
| 64331c9cf0 | |||
| 00088d4093 | |||
| 472f3660e0 | |||
| 3c13cc8c4d | |||
| 0792ac8eee | |||
| 4952af4ffe | |||
| 3fcca7ef56 | |||
| e93244fef2 | |||
| acf75ce7fe | |||
| 7560b6e53d | |||
| f5346bbec2 | |||
| 41958889fb | |||
| d439a7811d | |||
| 4951c00d23 |
+50
-33
@@ -22,6 +22,7 @@
|
||||
<property name="dynlink.native" value="false"/>
|
||||
<property name="native" location="native"/>
|
||||
<property name="src" location="src"/>
|
||||
<property name="contrib" location="contrib/src"/>
|
||||
<property name="dist" location="dist"/>
|
||||
<property name="test.src" location="test"/>
|
||||
<property name="doc" location="doc"/>
|
||||
@@ -34,7 +35,7 @@
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="3"/>
|
||||
<property name="jna.minor" value="2"/>
|
||||
<property name="jna.revision" value="4"/>
|
||||
<property name="jna.revision" value="5"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<!-- jnidispatch library release version -->
|
||||
@@ -59,7 +60,8 @@
|
||||
|
||||
<target name="default" depends="test" description="Build and Test."/>
|
||||
|
||||
<import file="nbproject/profiler-build-impl.xml"/>
|
||||
<!-- uncomment for netbeans profiling -->
|
||||
<!--<import file="nbproject/profiler-build-impl.xml"/>-->
|
||||
<target name="init" depends="-setup"/>
|
||||
<target name="compile-test-single" depends="compile-tests"/>
|
||||
<target name="compile-single" depends="compile"/>
|
||||
@@ -156,7 +158,7 @@
|
||||
</target>
|
||||
|
||||
<target name="-setup" depends="-dynamic-properties">
|
||||
<path id="compile-test.path">
|
||||
<path id="compile-test.path">
|
||||
<pathelement path="${test.src}"/>
|
||||
<path id="test.libs">
|
||||
<fileset dir="lib">
|
||||
@@ -168,12 +170,11 @@
|
||||
<path id="src.path">
|
||||
<pathelement location="${src}"/>
|
||||
</path>
|
||||
</path>
|
||||
</path>
|
||||
</path>
|
||||
|
||||
<path id="test.runpath">
|
||||
<pathelement path="${build}/${jar}"/>
|
||||
<pathelement path="${build}/examples.jar"/>
|
||||
<pathelement path="${test.classes}"/>
|
||||
<pathelement path="lib/clover.jar"/>
|
||||
<path refid="test.libs"/>
|
||||
@@ -197,8 +198,6 @@
|
||||
<patternset id="jar-compiled">
|
||||
<include name="com/sun/jna/*"/>
|
||||
<include name="com/sun/jna/**/*"/>
|
||||
<exclude name="com/sun/jna/examples/*"/>
|
||||
<exclude name="com/sun/jna/examples/**/*"/>
|
||||
</patternset>
|
||||
</srcfiles>
|
||||
</uptodate>
|
||||
@@ -209,31 +208,34 @@
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.sun.jna.Native"/>
|
||||
<section name="com/sun/jna/">
|
||||
<attribute name="Manifest-Version" value="1.0"/>
|
||||
<attribute name="Implementation-Title" value="${impl.title}"/>
|
||||
<attribute name="Implementation-Vendor" value="${vendor}"/>
|
||||
<attribute name="Implementation-Version" value="${impl.version}"/>
|
||||
<attribute name="Specification-Title" value="${spec.title}"/>
|
||||
<attribute name="Specification-Vendor" value="${spec.vendor}"/>
|
||||
<attribute name="Specification-Version" value="${spec.version}"/>
|
||||
<!-- OSGi Bundle attributes -->
|
||||
<attribute name="Bundle-ManifestVersion" value="2"/>
|
||||
<attribute name="Bundle-Name" value="jna"/>
|
||||
<attribute name="Bundle-Description" value="JNA Library"/>
|
||||
<attribute name="Bundle-SymbolicName" value="com.sun.jna"/>
|
||||
<attribute name="Bundle-Version" value="${spec.version}"/>
|
||||
<attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-1.4"/>
|
||||
<attribute name="Bundle-Vendor" value="${vendor}"/>
|
||||
<attribute name="Bundle-ActivationPolicy" value="lazy"/>
|
||||
<attribute name="Export-Package" value="com.sun.jna*"/>
|
||||
</section>
|
||||
</manifest>
|
||||
<fileset dir="${classes}" excludes="${jar.omitted}">
|
||||
<patternset refid="jar-compiled"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
<subant target="jar">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml" />
|
||||
<fileset dir="${contrib}" includes="*/build.xml" />
|
||||
</subant>
|
||||
</target>
|
||||
<target name="examples" depends="jar,native">
|
||||
<jar jarfile="${build}/examples.jar">
|
||||
<manifest>
|
||||
<attribute name="Class-Path" value="jna.jar"/>
|
||||
<attribute name="Main-Class" value="com.sun.jna.examples.ShapedWindowDemo"/>
|
||||
</manifest>
|
||||
<fileset dir="${src}" includes="**/examples/**/*.png"/>
|
||||
<fileset dir="${classes}" includes="**/examples/*,**/examples/**/*"/>
|
||||
<fileset dir="${classes}" includes="jnidispatch.dll"/>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="javah" depends="compile">
|
||||
<javah classpath="${classes}" destdir="${build.native}" force="yes">
|
||||
<class name="com.sun.jna.Function"/>
|
||||
@@ -400,8 +402,8 @@
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
description="Compile all test code">
|
||||
<target name="compile-tests" depends="compile,native,jar"
|
||||
description="Compile all test code">
|
||||
<javac classpathref="compile-test.path"
|
||||
source="${test.compatibility}"
|
||||
target="${test.compatibility}"
|
||||
@@ -426,10 +428,10 @@
|
||||
<fileset dir="${build}/jws" includes="jna.jar,jna-test.jar,junit.jar,jnidispatch.jar,clover.jar"/>
|
||||
</signjar>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- When running tests from an IDE, be sure to set jna.library.path -->
|
||||
<!-- to where the test library (testlib) is found. -->
|
||||
<target name="test" depends="jar,examples,compile-tests"
|
||||
<target name="test" depends="jar,compile-tests"
|
||||
description="Run all unit tests">
|
||||
<property name="test.fork" value="yes"/>
|
||||
<property name="reports.junit" location="${reports}/junit"/>
|
||||
@@ -437,7 +439,7 @@
|
||||
<mkdir dir="${results.junit}"/>
|
||||
<echo>Saving test results in ${results.junit}</echo>
|
||||
<property name="tests.stdcall" value="**/win32/*StdCallTest.java"/>
|
||||
<condition property="tests.platform" value="**/win32/*Test.java">
|
||||
<condition property="tests.platform" value="**/win32/**/*Test.java">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<condition property="tests.exclude" value="**/win32/*StdCallTest.java">
|
||||
@@ -471,12 +473,14 @@
|
||||
<batchtest todir="${results.junit}">
|
||||
<fileset dir="${test.src}">
|
||||
<include name="com/sun/jna/*Test.java"/>
|
||||
<include name="com/sun/jna/examples/*Test.java"/>
|
||||
<include name="${tests.platform}"/>
|
||||
<exclude name="${tests.exclude}"/>
|
||||
</fileset>
|
||||
</batchtest>
|
||||
</junit>
|
||||
<subant target="test">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml"/>
|
||||
</subant>
|
||||
<junitreport todir="${results.junit}">
|
||||
<fileset dir="${results.junit}">
|
||||
<include name="TEST-*.xml"/>
|
||||
@@ -500,7 +504,7 @@
|
||||
<mkdir dir="${reports.clover}"/>
|
||||
<clover-report>
|
||||
<current outfile="${reports.clover}" title="clover">
|
||||
<fileset dir="." includes="**/*.java" excludes="**/examples/**/*.java"/>
|
||||
<fileset dir="." includes="**/*.java" />
|
||||
<testresults dir="${results.junit}" includes="TEST-*.xml"/>
|
||||
<format type="html"/>
|
||||
</current>
|
||||
@@ -520,7 +524,7 @@
|
||||
sourcepathref="src.path"
|
||||
classpathref="compile.path"
|
||||
maxmemory="256m"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.examples,com.sun.jna.examples.win32,com.sun.jna.exmaples.unix"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32,com.sun.jna.exmaples.unix"
|
||||
overview="${src}/com/sun/jna/overview.html"
|
||||
destdir="${javadoc}">
|
||||
<!-- stylesheetfile="${stylesheet}" -->
|
||||
@@ -536,15 +540,16 @@
|
||||
</packageset>
|
||||
|
||||
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
|
||||
<group title="Examples" packages="com.sun.jna.examples,com.sun.jna.examples.dnd"/>
|
||||
<group title="Unix Examples" packages="com.sun.jna.examples.unix"/>
|
||||
<group title="Windows Examples" packages="com.sun.jna.examples.win32"/>
|
||||
|
||||
<group title="Platform Specific" packages="com.sun.jna.platform"/>
|
||||
|
||||
<arg value="-notimestamp"/>
|
||||
</javadoc>
|
||||
<subant target="javadoc">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="jar,compile-tests,native,examples,javadoc"
|
||||
<target name="dist" depends="jar,compile-tests,native,javadoc"
|
||||
description="Build distribution files">
|
||||
<jar jarfile="${dist}/jna.jar" duplicate="preserve">
|
||||
<manifest>
|
||||
@@ -602,11 +607,19 @@
|
||||
<copy todir="${dist}">
|
||||
<fileset dir="${build}">
|
||||
<include name="${native.jar}"/>
|
||||
<include name="examples.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${contrib}/platform/dist">
|
||||
<include name="platform.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${dist}/jnacontrib" flatten="true">
|
||||
<fileset dir="${contrib}">
|
||||
<include name="**/build/demo-*.jar" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<zip zipfile="${dist}/doc.zip">
|
||||
<zipfileset dir="${javadoc}" prefix="javadoc"/>
|
||||
<zipfileset dir="${contrib}/platform/dist/javadoc" prefix="platform/javadoc"/>
|
||||
</zip>
|
||||
<!-- JNA sources only, for use in Linux build from source/shared libffi -->
|
||||
<zip zipfile="${dist}/src.zip">
|
||||
@@ -614,6 +627,7 @@
|
||||
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
|
||||
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
|
||||
<zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java" prefix="contrib/platform"/>
|
||||
</zip>
|
||||
<!-- Full sources required to build and test everything -->
|
||||
<zip zipfile="${dist}/src-full.zip">
|
||||
@@ -638,6 +652,9 @@
|
||||
<fileset dir="${javadoc}"/>
|
||||
<fileset dir="." includes="*~,**/*~"/>
|
||||
</delete>
|
||||
<subant target="clean">
|
||||
<fileset dir="${contrib}" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
Arquivo binário não exibido.
@@ -1,6 +0,0 @@
|
||||
application.args=
|
||||
file.reference.jna.jar=D:\\temp\\JnaContrib\\lib\\jna.jar
|
||||
javac.debug=true
|
||||
javadoc.preview=true
|
||||
jaxws.endorsed.dir=D:\\Program Files\\netbeans551\\ide7\\modules\\ext\\jaxws21\\api
|
||||
user.properties.file=C:\\Users\\tb\\.netbeans\\5.5.1\\build.properties
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>alphamaskdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,78 @@
|
||||
<?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="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-alphamask.jar"/>
|
||||
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+19
-16
@@ -10,9 +10,9 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
|
||||
import java.awt.event.*;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
@@ -26,6 +26,7 @@ import java.awt.Window;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
@@ -38,6 +39,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
@@ -52,23 +54,24 @@ import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.unix.X11.Display;
|
||||
import com.sun.jna.examples.unix.X11.GC;
|
||||
import com.sun.jna.examples.unix.X11.XSetWindowAttributes;
|
||||
import com.sun.jna.examples.win32.GDI32;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
import com.sun.jna.examples.win32.GDI32.BITMAPINFO;
|
||||
import com.sun.jna.examples.win32.User32.BLENDFUNCTION;
|
||||
import com.sun.jna.examples.win32.User32.POINT;
|
||||
import com.sun.jna.examples.win32.User32.SIZE;
|
||||
import com.sun.jna.examples.win32.W32API.HANDLE;
|
||||
import com.sun.jna.examples.win32.W32API.HBITMAP;
|
||||
import com.sun.jna.examples.win32.W32API.HDC;
|
||||
import com.sun.jna.examples.win32.W32API.HWND;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.unix.X11.GC;
|
||||
import com.sun.jna.platform.win32.GDI32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.GDI32.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.User32.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.User32.POINT;
|
||||
import com.sun.jna.platform.win32.User32.SIZE;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLE;
|
||||
import com.sun.jna.platform.win32.W32API.HBITMAP;
|
||||
import com.sun.jna.platform.win32.W32API.HDC;
|
||||
import com.sun.jna.platform.win32.W32API.HWND;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: put this into a reasonable API; right now this is pretty much
|
||||
+4
-2
@@ -8,10 +8,10 @@
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
@@ -52,6 +52,8 @@ import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
public class AlphaMaskDemo2 implements Runnable {
|
||||
private static final DataFlavor URL_FLAVOR =
|
||||
new DataFlavor("application/x-java-url; class=java.net.URL", "URL");
|
||||
|
Antes Largura: | Altura: | Tamanho: 18 KiB Depois Largura: | Altura: | Tamanho: 18 KiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloonmanagerdemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+4
-1
@@ -10,7 +10,7 @@
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for
|
||||
* more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -31,11 +31,14 @@ import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* Provides a popup balloon containing an arbitrary component. This provides
|
||||
* a form of content-specific decoration less transient than a tooltip, and less
|
||||
+4
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
@@ -24,6 +24,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
@@ -35,6 +36,8 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Demonstration of BalloonManager. */
|
||||
public class BalloonManagerDemo {
|
||||
private static final int ICON_SIZE = 48;
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>balloontips</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
//package bms.ui.widgets;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
@@ -30,7 +30,7 @@ import javax.swing.Popup;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.examples.WindowUtils;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/**
|
||||
* The BalloonTipManager class handles creation and disposal of balloon style
|
||||
@@ -61,7 +61,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* The BalloonTip class defines the look of the BalloonTip object.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
private static final class BalloonTip extends JWindow {
|
||||
private static final Integer HMARGIN = 10;
|
||||
private static final Integer VMARGIN = 6;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//package bms.ui.widgets;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path=""/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="src" path="/platform"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>dnddemo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<dirset dir="${src}"/>
|
||||
</src>
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- platform -->
|
||||
<fileset dir="../platform/build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
||||
+5
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.contrib.demo;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
@@ -32,6 +32,10 @@ import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.platform.dnd.DragHandler;
|
||||
import com.sun.jna.platform.dnd.DropHandler;
|
||||
|
||||
|
||||
/** Demonstrate ghosted drag images. Unfortunately, Swing drag support hides
|
||||
* the hooks we need to move the drag image around, so we don't use it and
|
||||
* roll our own.
|
||||
Arquivo executável → Arquivo normal
|
Antes Largura: | Altura: | Tamanho: 28 KiB Depois Largura: | Altura: | Tamanho: 28 KiB |
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jna"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ntservice</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
+1
-1
@@ -19,7 +19,7 @@ is divided into following sections:
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="JnaContrib-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<project name="ntservice-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
+4
-3
@@ -14,12 +14,13 @@ debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/JnaContrib.jar
|
||||
dist.jar=${dist.dir}/contrib-ntservice.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=lib/jna.jar
|
||||
file.reference.jna.jar=../../../build/jna.jar
|
||||
libs.junit.classpath=../../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar}
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>JnaContrib</name>
|
||||
<name>ntservice</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" output="build.eclipse/contrib-test-classes" path="test"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jna"/>
|
||||
<classpathentry kind="lib" path="/jna/dist/jna.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>platform</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="platform" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project platform.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="JnaContrib-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<condition property="tests.platform" value="win32">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<target name="test" description="Run unit tests." if="tests.platform">
|
||||
<antcall target="test-win32" />
|
||||
</target>
|
||||
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
</project>
|
||||
@@ -0,0 +1,541 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
*** GENERATED FROM project.xml - DO NOT EDIT ***
|
||||
*** EDIT ../build.xml INSTEAD ***
|
||||
|
||||
For the purpose of easier reading the script
|
||||
is divided into following sections:
|
||||
|
||||
- initialization
|
||||
- compilation
|
||||
- jar
|
||||
- execution
|
||||
- debugging
|
||||
- javadoc
|
||||
- junit compilation
|
||||
- junit execution
|
||||
- junit debugging
|
||||
- applet
|
||||
- cleanup
|
||||
|
||||
-->
|
||||
<project name="platform-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:jaxws="http://www.netbeans.org/ns/jax-ws/1">
|
||||
<target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
|
||||
<!--
|
||||
======================
|
||||
INITIALIZATION SECTION
|
||||
======================
|
||||
-->
|
||||
<target name="-pre-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-private" depends="-pre-init">
|
||||
<property file="nbproject/private/private.properties"/>
|
||||
</target>
|
||||
<target name="-init-user" depends="-pre-init,-init-private">
|
||||
<property file="${user.properties.file}"/>
|
||||
<!-- The two properties below are usually overridden -->
|
||||
<!-- by the active platform. Just a fallback. -->
|
||||
<property name="default.javac.source" value="1.4"/>
|
||||
<property name="default.javac.target" value="1.4"/>
|
||||
</target>
|
||||
<target name="-init-project" depends="-pre-init,-init-private,-init-user">
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
<isset property="manifest.available"/>
|
||||
<isset property="main.class"/>
|
||||
<not>
|
||||
<equals arg1="${main.class}" arg2="" trim="true"/>
|
||||
</not>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="manifest.available+main.class+mkdist.available">
|
||||
<and>
|
||||
<istrue value="${manifest.available+main.class}"/>
|
||||
<isset property="libs.CopyLibs.classpath"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="have.tests">
|
||||
<or>
|
||||
<available file="${test.src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.dir}"/>
|
||||
</or>
|
||||
</condition>
|
||||
<condition property="netbeans.home+have.tests">
|
||||
<and>
|
||||
<isset property="netbeans.home"/>
|
||||
<isset property="have.tests"/>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="no.javadoc.preview">
|
||||
<isfalse value="${javadoc.preview}"/>
|
||||
</condition>
|
||||
<property name="run.jvmargs" value=""/>
|
||||
<property name="javac.compilerargs" value=""/>
|
||||
<property name="work.dir" value="${basedir}"/>
|
||||
<condition property="no.deps">
|
||||
<and>
|
||||
<istrue value="${no.dependencies}"/>
|
||||
</and>
|
||||
</condition>
|
||||
<property name="javac.debug" value="true"/>
|
||||
<property name="javadoc.preview" value="true"/>
|
||||
</target>
|
||||
<target name="-post-init">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.dir">Must set src.dir</fail>
|
||||
<fail unless="test.src.dir">Must set test.src.dir</fail>
|
||||
<fail unless="build.dir">Must set build.dir</fail>
|
||||
<fail unless="dist.dir">Must set dist.dir</fail>
|
||||
<fail unless="build.classes.dir">Must set build.classes.dir</fail>
|
||||
<fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
|
||||
<fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
|
||||
<fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
|
||||
<fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
|
||||
<fail unless="dist.jar">Must set dist.jar</fail>
|
||||
</target>
|
||||
<target name="-init-macrodef-property">
|
||||
<macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name"/>
|
||||
<attribute name="value"/>
|
||||
<sequential>
|
||||
<property name="@{name}" value="${@{value}}"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<compilerarg line="${javac.compilerargs}"/>
|
||||
<customize/>
|
||||
</javac>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-junit">
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}">
|
||||
<fileset dir="${test.src.dir}" includes="@{includes}"/>
|
||||
</batchtest>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="test-sys-prop."/>
|
||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<formatter type="brief" usefile="false"/>
|
||||
<formatter type="xml"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
</junit>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-nbjpda">
|
||||
<macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="name" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<attribute name="stopclassname" default=""/>
|
||||
<sequential>
|
||||
<nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
<macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="dir" default="${build.classes.dir}"/>
|
||||
<sequential>
|
||||
<nbjpdareload>
|
||||
<fileset includes="${fix.includes}*.class" dir="@{dir}"/>
|
||||
</nbjpdareload>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-debug">
|
||||
<macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-macrodef-java">
|
||||
<macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
</classpath>
|
||||
<syspropertyset>
|
||||
<propertyref prefix="run-sys-prop."/>
|
||||
<mapper type="glob" from="run-sys-prop.*" to="*"/>
|
||||
</syspropertyset>
|
||||
<customize/>
|
||||
</java>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
</target>
|
||||
<target name="-init-presetdef-jar">
|
||||
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
|
||||
<jar jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<j2seproject1:fileset dir="${build.classes.dir}"/>
|
||||
</jar>
|
||||
</presetdef>
|
||||
</target>
|
||||
<target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
|
||||
<!--
|
||||
===================
|
||||
COMPILATION SECTION
|
||||
===================
|
||||
-->
|
||||
<target name="deps-jar" depends="init" unless="no.deps"/>
|
||||
<target name="-pre-pre-compile" depends="init,deps-jar">
|
||||
<mkdir dir="${build.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
|
||||
<target name="-pre-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac>
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
</target>
|
||||
<target name="-post-compile-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
|
||||
<!--
|
||||
====================
|
||||
JAR BUILDING SECTION
|
||||
====================
|
||||
-->
|
||||
<target name="-pre-pre-jar" depends="init">
|
||||
<dirname property="dist.jar.dir" file="${dist.jar}"/>
|
||||
<mkdir dir="${dist.jar.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
|
||||
<j2seproject1:jar/>
|
||||
</target>
|
||||
<target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
|
||||
<j2seproject1:jar manifest="${manifest.file}"/>
|
||||
</target>
|
||||
<target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
|
||||
<j2seproject1:jar manifest="${manifest.file}">
|
||||
<j2seproject1:manifest>
|
||||
<j2seproject1:attribute name="Main-Class" value="${main.class}"/>
|
||||
</j2seproject1:manifest>
|
||||
</j2seproject1:jar>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<pathconvert property="run.classpath.with.dist.jar">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
<pathconvert property="run.classpath.without.build.classes.dir">
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<path path="${run.classpath.without.build.classes.dir}"/>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="lib/*"/>
|
||||
</chainedmapper>
|
||||
</pathconvert>
|
||||
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
|
||||
<copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main.class}"/>
|
||||
<attribute name="Class-Path" value="${jar.classpath}"/>
|
||||
</manifest>
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
|
||||
<!--
|
||||
=================
|
||||
EXECUTION SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="run" depends="init,compile" description="Run a main class.">
|
||||
<j2seproject1:java>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<target name="run-single" depends="init,compile-single">
|
||||
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
|
||||
<j2seproject1:java classname="${run.class}"/>
|
||||
</target>
|
||||
<!--
|
||||
=================
|
||||
DEBUGGING SECTION
|
||||
=================
|
||||
-->
|
||||
<target name="-debug-start-debugger" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart name="${debug.class}"/>
|
||||
</target>
|
||||
<target name="-debug-start-debuggee" depends="init,compile">
|
||||
<j2seproject3:debug>
|
||||
<customize>
|
||||
<arg line="${application.args}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
|
||||
<target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
|
||||
<j2seproject1:nbjpdastart stopclassname="${main.class}"/>
|
||||
</target>
|
||||
<target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
|
||||
<target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
|
||||
<j2seproject3:debug classname="${debug.class}"/>
|
||||
</target>
|
||||
<target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
|
||||
<target name="-pre-debug-fix" depends="init">
|
||||
<fail unless="fix.includes">Must set fix.includes</fail>
|
||||
<property name="javac.includes" value="${fix.includes}.java"/>
|
||||
</target>
|
||||
<target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
|
||||
<j2seproject1:nbjpdareload/>
|
||||
</target>
|
||||
<target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
|
||||
<!--
|
||||
===============
|
||||
JAVADOC SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.dir}" includes="*.java"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
|
||||
<nbbrowse file="${dist.javadoc.dir}/index.html"/>
|
||||
</target>
|
||||
<target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
|
||||
<!--
|
||||
=========================
|
||||
JUNIT COMPILATION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
|
||||
<mkdir dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="-pre-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
|
||||
<target name="-pre-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
|
||||
<fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
|
||||
<j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
|
||||
<customize>
|
||||
<patternset includes="${javac.includes}"/>
|
||||
</customize>
|
||||
</j2seproject3:javac>
|
||||
<copy todir="${build.test.classes.dir}">
|
||||
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
|
||||
</copy>
|
||||
</target>
|
||||
<target name="-post-compile-test-single">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT EXECUTION SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-pre-test-run" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
|
||||
<j2seproject3:junit/>
|
||||
</target>
|
||||
<target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-report" if="have.tests" depends="init"/>
|
||||
<target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
|
||||
<target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
|
||||
<target name="-pre-test-run-single" if="have.tests" depends="init">
|
||||
<mkdir dir="${build.test.results.dir}"/>
|
||||
</target>
|
||||
<target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
|
||||
<fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
|
||||
<j2seproject3:junit includes="${test.includes}"/>
|
||||
</target>
|
||||
<target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
|
||||
<fail if="tests.failed">Some tests failed; see details above.</fail>
|
||||
</target>
|
||||
<target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
|
||||
<!--
|
||||
=======================
|
||||
JUNIT DEBUGGING SECTION
|
||||
=======================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
|
||||
<fail unless="test.class">Must select one file in the IDE or set test.class</fail>
|
||||
<j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
|
||||
<customize>
|
||||
<arg line="${test.class}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
|
||||
<j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
|
||||
</target>
|
||||
<target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
|
||||
<target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
|
||||
<j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
|
||||
</target>
|
||||
<target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
|
||||
<!--
|
||||
=========================
|
||||
APPLET EXECUTION SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="run-applet" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject1:java classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject1:java>
|
||||
</target>
|
||||
<!--
|
||||
=========================
|
||||
APPLET DEBUGGING SECTION
|
||||
=========================
|
||||
-->
|
||||
<target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
|
||||
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
|
||||
<j2seproject3:debug classname="sun.applet.AppletViewer">
|
||||
<customize>
|
||||
<arg value="${applet.url}"/>
|
||||
</customize>
|
||||
</j2seproject3:debug>
|
||||
</target>
|
||||
<target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
|
||||
<!--
|
||||
===============
|
||||
CLEANUP SECTION
|
||||
===============
|
||||
-->
|
||||
<target name="deps-clean" depends="init" unless="no.deps"/>
|
||||
<target name="-do-clean" depends="init">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
</target>
|
||||
<target name="-post-clean">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
|
||||
</project>
|
||||
@@ -0,0 +1,59 @@
|
||||
application.args=
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java
|
||||
# This directory is removed when the project is cleaned:
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
# Only compile against the classpath explicitly listed here:
|
||||
build.sysclasspath=ignore
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
debug.classpath=\
|
||||
${run.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
# This directory is removed when the project is cleaned:
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/platform.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../../build/jna.jar
|
||||
libs.junit.classpath=../../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
${libs.junit.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
main.class=
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running the project
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||
run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.dir=src
|
||||
test.src.dir=test
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>platform</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -0,0 +1,135 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EventObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.win32.W32FileMonitor;
|
||||
|
||||
/** Provides notification of file system changes. Actual capabilities may
|
||||
* vary slightly by platform.
|
||||
* <p>
|
||||
* Watched files which are removed from the filesystem are no longer watched.
|
||||
* @author twall
|
||||
*/
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class FileMonitor {
|
||||
|
||||
public static final int FILE_CREATED = 0x1;
|
||||
public static final int FILE_DELETED = 0x2;
|
||||
public static final int FILE_MODIFIED = 0x4;
|
||||
public static final int FILE_ACCESSED = 0x8;
|
||||
public static final int FILE_NAME_CHANGED_OLD = 0x10;
|
||||
public static final int FILE_NAME_CHANGED_NEW = 0x20;
|
||||
public static final int FILE_RENAMED = FILE_NAME_CHANGED_OLD|FILE_NAME_CHANGED_NEW;
|
||||
public static final int FILE_SIZE_CHANGED = 0x40;
|
||||
public static final int FILE_ATTRIBUTES_CHANGED = 0x80;
|
||||
public static final int FILE_SECURITY_CHANGED = 0x100;
|
||||
public static final int FILE_ANY = 0x1FF;
|
||||
|
||||
public interface FileListener {
|
||||
public void fileChanged(FileEvent e);
|
||||
}
|
||||
|
||||
public class FileEvent extends EventObject {
|
||||
private final File file;
|
||||
private final int type;
|
||||
public FileEvent(File file, int type) {
|
||||
super(FileMonitor.this);
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
}
|
||||
public File getFile() { return file; }
|
||||
public int getType() { return type; }
|
||||
public String toString() {
|
||||
return "FileEvent: " + file + ":" + type;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<File, Integer> watched = new HashMap<File, Integer>();
|
||||
private List<FileListener> listeners = new ArrayList<FileListener>();
|
||||
|
||||
protected abstract void watch(File file, int mask, boolean recursive) throws IOException ;
|
||||
protected abstract void unwatch(File file);
|
||||
public abstract void dispose();
|
||||
|
||||
public void addWatch(File dir) throws IOException {
|
||||
addWatch(dir, FILE_ANY);
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask) throws IOException {
|
||||
addWatch(dir, mask, dir.isDirectory());
|
||||
}
|
||||
|
||||
public void addWatch(File dir, int mask, boolean recursive) throws IOException {
|
||||
watched.put(dir, new Integer(mask));
|
||||
watch(dir, mask, recursive);
|
||||
}
|
||||
|
||||
public void removeWatch(File file) {
|
||||
if (watched.remove(file) != null) {
|
||||
unwatch(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notify(FileEvent e) {
|
||||
for (FileListener listener : listeners) {
|
||||
listener.fileChanged(e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addFileListener(FileListener listener) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.add(listener);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
public synchronized void removeFileListener(FileListener x) {
|
||||
List<FileListener> list = new ArrayList<FileListener>(listeners);
|
||||
list.remove(x);
|
||||
listeners = list;
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
for (File watchedFile : watched.keySet()) {
|
||||
removeWatch(watchedFile);
|
||||
}
|
||||
|
||||
dispose();
|
||||
}
|
||||
|
||||
/** Canonical lazy loading of a singleton. */
|
||||
private static class Holder {
|
||||
public static final FileMonitor INSTANCE;
|
||||
static {
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.startsWith("Windows")) {
|
||||
INSTANCE = new W32FileMonitor();
|
||||
}
|
||||
else {
|
||||
throw new Error("FileMonitor not implemented for " + os);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static FileMonitor getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
}
|
||||
+7
-55
@@ -10,14 +10,15 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.sun.jna.examples.win32.Shell32;
|
||||
import com.sun.jna.examples.win32.Shell32.SHFILEOPSTRUCT;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.mac.MacFileUtils;
|
||||
import com.sun.jna.platform.win32.W32FileUtils;
|
||||
|
||||
/** Miscellaneous file utils not provided for by Java. */
|
||||
public abstract class FileUtils {
|
||||
@@ -50,56 +51,7 @@ public abstract class FileUtils {
|
||||
|
||||
public static FileUtils getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class W32FileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
Shell32 shell = Shell32.INSTANCE;
|
||||
SHFILEOPSTRUCT fileop = new SHFILEOPSTRUCT();
|
||||
fileop.wFunc = Shell32.FO_DELETE;
|
||||
String[] paths = new String[files.length];
|
||||
for (int i=0;i < paths.length;i++) {
|
||||
paths[i] = files[i].getAbsolutePath();
|
||||
}
|
||||
fileop.pFrom = fileop.encodePaths(paths);
|
||||
fileop.fFlags = Shell32.FOF_ALLOWUNDO|Shell32.FOF_NOCONFIRMATION|Shell32.FOF_SILENT;
|
||||
int ret = shell.SHFileOperation(fileop);
|
||||
if (ret != 0) {
|
||||
throw new IOException("Move to trash failed: " + ret);
|
||||
}
|
||||
if (fileop.fAnyOperationsAborted) {
|
||||
throw new IOException("Move to trash aborted");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
// TODO: use native API for moving to trash (if any)
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List failed = new ArrayList();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DefaultFileUtils extends FileUtils {
|
||||
|
||||
@@ -138,7 +90,7 @@ public abstract class FileUtils {
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("No trash location found (define fileutils.trash to be the path to the trash)");
|
||||
}
|
||||
List failed = new ArrayList();
|
||||
List<File> failed = new ArrayList<File>();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
+4
-4
@@ -10,16 +10,16 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.unix.X11.Display;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
|
||||
/** Provide access to the local keyboard state. Note that this is meaningless
|
||||
* on a headless system and some VNC setups.
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.DataBuffer;
|
||||
+24
-25
@@ -11,12 +11,12 @@
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples;
|
||||
package com.sun.jna.platform;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dialog;
|
||||
@@ -31,15 +31,14 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.HierarchyEvent;
|
||||
import java.awt.event.HierarchyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.Area;
|
||||
@@ -63,24 +62,24 @@ import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.examples.unix.X11;
|
||||
import com.sun.jna.examples.unix.X11.Display;
|
||||
import com.sun.jna.examples.unix.X11.GC;
|
||||
import com.sun.jna.examples.unix.X11.Pixmap;
|
||||
import com.sun.jna.examples.unix.X11.XVisualInfo;
|
||||
import com.sun.jna.examples.unix.X11.Xext;
|
||||
import com.sun.jna.examples.unix.X11.Xrender.XRenderPictFormat;
|
||||
import com.sun.jna.examples.win32.GDI32;
|
||||
import com.sun.jna.examples.win32.User32;
|
||||
import com.sun.jna.examples.win32.GDI32.BITMAPINFO;
|
||||
import com.sun.jna.examples.win32.User32.BLENDFUNCTION;
|
||||
import com.sun.jna.examples.win32.User32.POINT;
|
||||
import com.sun.jna.examples.win32.User32.SIZE;
|
||||
import com.sun.jna.examples.win32.W32API.HANDLE;
|
||||
import com.sun.jna.examples.win32.W32API.HBITMAP;
|
||||
import com.sun.jna.examples.win32.W32API.HDC;
|
||||
import com.sun.jna.examples.win32.W32API.HRGN;
|
||||
import com.sun.jna.examples.win32.W32API.HWND;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.unix.X11.GC;
|
||||
import com.sun.jna.platform.unix.X11.Pixmap;
|
||||
import com.sun.jna.platform.unix.X11.XVisualInfo;
|
||||
import com.sun.jna.platform.unix.X11.Xext;
|
||||
import com.sun.jna.platform.unix.X11.Xrender.XRenderPictFormat;
|
||||
import com.sun.jna.platform.win32.GDI32;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.GDI32.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.User32.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.User32.POINT;
|
||||
import com.sun.jna.platform.win32.User32.SIZE;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLE;
|
||||
import com.sun.jna.platform.win32.W32API.HBITMAP;
|
||||
import com.sun.jna.platform.win32.W32API.HDC;
|
||||
import com.sun.jna.platform.win32.W32API.HRGN;
|
||||
import com.sun.jna.platform.win32.W32API.HWND;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
@@ -645,7 +644,7 @@ public class WindowUtils {
|
||||
if (usingUpdateLayeredWindow(w)) {
|
||||
// If already using UpdateLayeredWindow, continue to
|
||||
// do so
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
User32.BLENDFUNCTION blend = new User32.BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = level;
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, null, null, null, null,
|
||||
+2
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Component;
|
||||
@@ -38,6 +38,7 @@ import java.awt.dnd.DropTargetEvent;
|
||||
import java.awt.dnd.InvalidDnDOperationException;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JFileChooser;
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.dnd.DropTargetEvent;
|
||||
+2
-2
@@ -10,7 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.dnd;
|
||||
package com.sun.jna.platform.dnd;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
@@ -29,7 +29,7 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import com.sun.jna.examples.WindowUtils;
|
||||
import com.sun.jna.platform.WindowUtils;
|
||||
|
||||
/** Provide a ghosted drag image for use during drags where
|
||||
* {@link DragSource#isDragImageSupported} returns false.<p>
|
||||
@@ -0,0 +1,45 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.mac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
|
||||
public class MacFileUtils extends FileUtils {
|
||||
|
||||
public boolean hasTrash() { return true; }
|
||||
|
||||
public void moveToTrash(File[] files) throws IOException {
|
||||
// TODO: use native API for moving to trash (if any)
|
||||
File home = new File(System.getProperty("user.home"));
|
||||
File trash = new File(home, ".Trash");
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + trash + ")");
|
||||
}
|
||||
List failed = new ArrayList();
|
||||
for (int i=0;i < files.length;i++) {
|
||||
File src = files[i];
|
||||
File target = new File(trash, src.getName());
|
||||
if (!src.renameTo(target)) {
|
||||
failed.add(src);
|
||||
}
|
||||
}
|
||||
if (failed.size() > 0) {
|
||||
throw new IOException("The following files could not be trashed: " + failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-3
@@ -10,10 +10,20 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.unix;
|
||||
package com.sun.jna.platform.unix;
|
||||
|
||||
import com.sun.jna.*;
|
||||
import com.sun.jna.ptr.*;
|
||||
import com.sun.jna.FromNativeContext;
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/** Definition (incomplete) of the X library. */
|
||||
public interface X11 extends Library {
|
||||
@@ -0,0 +1,623 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSIDByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.SECURITY_ATTRIBUTES;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEY;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Advapi32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Advapi32 extends W32API {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32",
|
||||
Advapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user associated with the current thread.
|
||||
* http://msdn.microsoft.com/en-us/library/ms724432(VS.85).aspx
|
||||
*
|
||||
* @param buffer
|
||||
* Buffer to receive the user's logon name.
|
||||
* @param len
|
||||
* On input, the size of the buffer, on output the number of
|
||||
* characters copied into the buffer, including the terminating
|
||||
* null character.
|
||||
* @return
|
||||
* True if succeeded.
|
||||
*/
|
||||
public boolean GetUserNameW(char[] buffer, IntByReference len);
|
||||
|
||||
/**
|
||||
* Accepts the name of a system and anaccount as input and retrieves a security
|
||||
* identifier (SID) for the account and the name of the domain on which the
|
||||
* account was found.
|
||||
* http://msdn.microsoft.com/en-us/library/aa379159(VS.85).aspx
|
||||
*
|
||||
* @param lpSystemName
|
||||
* Specifies the name of the system.
|
||||
* @param lpAccountName
|
||||
* Specifies the account name.
|
||||
* @param Sid
|
||||
* Receives the SID structure that corresponds to the account
|
||||
* name pointed to by the lpAccountName parameter.
|
||||
* @param cbSid
|
||||
* On input, this value specifies the size, in bytes, of the Sid
|
||||
* buffer. If the function fails because the buffer is too small
|
||||
* or if cbSid is zero, this variable receives the required
|
||||
* buffer size.
|
||||
* @param ReferencedDomainName
|
||||
* Receives the name of the domain where the account name is found.
|
||||
* @param cchReferencedDomainName
|
||||
* On input, this value specifies the size, in TCHARs, of the
|
||||
* ReferencedDomainName buffer. If the function fails because the
|
||||
* buffer is too small, this variable receives the required
|
||||
* buffer size, including the terminating null character.
|
||||
* @param peUse
|
||||
* SID_NAME_USE enumerated type that indicates the type of the
|
||||
* account when the function returns.
|
||||
* @return
|
||||
* True if the function was successful, False otherwise.
|
||||
*/
|
||||
public boolean LookupAccountName(String lpSystemName,
|
||||
String lpAccountName, PSID Sid, IntByReference cbSid,
|
||||
char[] ReferencedDomainName,
|
||||
IntByReference cchReferencedDomainName, PointerByReference peUse);
|
||||
|
||||
/**
|
||||
* Retrieves the name of the account for this SID and the name of the first domain
|
||||
* on which this SID is found.
|
||||
*
|
||||
* @param lpSystemName Specifies the target computer.
|
||||
* @param Sid The SID to look up.
|
||||
* @param lpName
|
||||
* Buffer that receives a null-terminated string that contains the
|
||||
* account name that corresponds to the lpSid parameter.
|
||||
* @param cchName
|
||||
* On input, specifies the size, in TCHARs, of the lpName buffer. If the function fails
|
||||
* because the buffer is too small or if cchName is zero, cchName receives the required
|
||||
* buffer size, including the terminating null character.
|
||||
* @param ReferencedDomainName
|
||||
* Pointer to a buffer that receives a null-terminated string that contains the name of
|
||||
* the domain where the account name was found.
|
||||
* @param cchReferencedDomainName
|
||||
* On input, specifies the size, in TCHARs, of the lpReferencedDomainName buffer. If the
|
||||
* function fails because the buffer is too small or if cchReferencedDomainName is zero,
|
||||
* cchReferencedDomainName receives the required buffer size, including the terminating
|
||||
* null character.
|
||||
* @param peUse
|
||||
* Pointer to a variable that receives a SID_NAME_USE value that indicates the type of
|
||||
* the account.
|
||||
* @return
|
||||
* If the function succeeds, the function returns nonzero.
|
||||
* If the function fails, it returns zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
public boolean LookupAccountSid(String lpSystemName, PSID Sid,
|
||||
char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
|
||||
IntByReference cchReferencedDomainName, PointerByReference peUse);
|
||||
|
||||
/**
|
||||
* Convert a security identifier (SID) to a string format suitable for display,
|
||||
* storage, or transmission.
|
||||
* http://msdn.microsoft.com/en-us/library/aa376399(VS.85).aspx
|
||||
*
|
||||
* @param Sid
|
||||
* The SID structure to be converted.
|
||||
* @param StringSid
|
||||
* Pointer to a variable that receives a pointer to a
|
||||
* null-terminated SID string. To free the returned buffer, call
|
||||
* the LocalFree function.
|
||||
* @return True if the function was successful, False otherwise.
|
||||
*/
|
||||
public boolean ConvertSidToStringSid(PSID Sid,
|
||||
PointerByReference StringSid);
|
||||
|
||||
/**
|
||||
* Convert a string-format security identifier (SID) into a valid, functional SID.
|
||||
* http://msdn.microsoft.com/en-us/library/aa376402(VS.85).aspx
|
||||
*
|
||||
* @param StringSid The string-format SID to convert.
|
||||
* @param Sid Receives a pointer to the converted SID.
|
||||
* @return True if the function was successful, False otherwise.
|
||||
*/
|
||||
public boolean ConvertStringSidToSid(String StringSid,
|
||||
PSIDByReference Sid);
|
||||
|
||||
/**
|
||||
* Returns the length, in bytes, of a valid security identifier (SID).
|
||||
* http://msdn.microsoft.com/en-us/library/aa446642(VS.85).aspx
|
||||
*
|
||||
* @param pSid A pointer to the SID structure whose length is returned.
|
||||
* @return Length of the SID.
|
||||
*/
|
||||
public int GetLengthSid(PSID pSid);
|
||||
|
||||
/**
|
||||
* The IsValidSid function validates a security identifier (SID) by verifying that
|
||||
* the revision number is within a known range, and that the number of subauthorities
|
||||
* is less than the maximum.
|
||||
* @param pSid
|
||||
* Pointer to the SID structure to validate. This parameter cannot be NULL.
|
||||
* @return
|
||||
* If the SID structure is valid, the return value is nonzero.
|
||||
* If the SID structure is not valid, the return value is zero. There is no extended
|
||||
* error information for this function; do not call GetLastError.
|
||||
*/
|
||||
public boolean IsValidSid(PSID pSid);
|
||||
|
||||
/**
|
||||
* The LogonUser function attempts to log a user on to the local computer. The local computer is
|
||||
* the computer from which LogonUser was called. You cannot use LogonUser to log on to a remote
|
||||
* computer. You specify the user with a user name and domain, and authenticate the user with a
|
||||
* plaintext password. If the function succeeds, you receive a handle to a token that represents
|
||||
* the logged-on user. You can then use this token handle to impersonate the specified user or,
|
||||
* in most cases, to create a process that runs in the context of the specified user.
|
||||
* @param lpszUsername
|
||||
* A pointer to a null-terminated string that specifies the name of the user. This is the name of
|
||||
* the user account to log on to. If you use the user principal name (UPN) format,
|
||||
* user@DNS_domain_name, the lpszDomain parameter must be NULL.
|
||||
* @param lpszDomain
|
||||
* A pointer to a null-terminated string that specifies the name of the domain or server whose
|
||||
* account database contains the lpszUsername account. If this parameter is NULL, the user name
|
||||
* must be specified in UPN format. If this parameter is ".", the function validates the account
|
||||
* using only the local account database.
|
||||
* @param lpszPassword
|
||||
* A pointer to a null-terminated string that specifies the plaintext password for the user
|
||||
* account specified by lpszUsername.
|
||||
* @param logonType
|
||||
* The type of logon operation to perform.
|
||||
* @param logonProvider
|
||||
* Specifies the logon provider.
|
||||
* @param phToken
|
||||
* A pointer to a handle variable that receives a handle to a token that represents the specified user.
|
||||
* @return
|
||||
* If the function succeeds, the function returns nonzero.
|
||||
* If the function fails, it returns zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean LogonUser(
|
||||
String lpszUsername,
|
||||
String lpszDomain,
|
||||
String lpszPassword,
|
||||
int logonType,
|
||||
int logonProvider,
|
||||
HANDLEByReference phToken);
|
||||
|
||||
/**
|
||||
* The OpenThreadToken function opens the access token associated with a thread.
|
||||
* @param ThreadHandle
|
||||
* Handle to the thread whose access token is opened.
|
||||
* @param DesiredAccess
|
||||
* Specifies an access mask that specifies the requested types of access to the access token.
|
||||
* These requested access types are reconciled against the token's discretionary access
|
||||
* control list (DACL) to determine which accesses are granted or denied.
|
||||
* @param OpenAsSelf
|
||||
* Indicates whether the access check is to be made against the security context of the
|
||||
* thread calling the OpenThreadToken function or against the security context of the
|
||||
* process for the calling thread.
|
||||
* @param TokenHandle
|
||||
* Pointer to a variable that receives the handle to the newly opened access token.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean OpenThreadToken(
|
||||
HANDLE ThreadHandle,
|
||||
int DesiredAccess,
|
||||
boolean OpenAsSelf,
|
||||
HANDLEByReference TokenHandle);
|
||||
|
||||
/**
|
||||
* The OpenProcessToken function opens the access token associated with a process.
|
||||
* @param ProcessHandle
|
||||
* Handle to the process whose access token is opened. The process must have the
|
||||
* PROCESS_QUERY_INFORMATION access permission.
|
||||
* @param DesiredAccess
|
||||
* Specifies an access mask that specifies the requested types of access to the access
|
||||
* token. These requested access types are compared with the discretionary access
|
||||
* control list (DACL) of the token to determine which accesses are granted or denied.
|
||||
* @param TokenHandle
|
||||
* Pointer to a handle that identifies the newly opened access token when the function returns.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean OpenProcessToken(
|
||||
HANDLE ProcessHandle,
|
||||
int DesiredAccess,
|
||||
HANDLEByReference TokenHandle);
|
||||
|
||||
/**
|
||||
* The DuplicateToken function creates a new access token that duplicates
|
||||
* one already in existence.
|
||||
*
|
||||
* @param ExistingTokenHandle
|
||||
* Handle to an access token opened with TOKEN_DUPLICATE access.
|
||||
* @param ImpersonationLevel
|
||||
* Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type that supplies
|
||||
* the impersonation level of the new token.
|
||||
* @param DuplicateTokenHandle
|
||||
* Pointer to a variable that receives a handle to the duplicate token.
|
||||
* This handle has TOKEN_IMPERSONATE and TOKEN_QUERY access to the new token.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean DuplicateToken(
|
||||
HANDLE ExistingTokenHandle,
|
||||
int ImpersonationLevel,
|
||||
HANDLEByReference DuplicateTokenHandle);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves a specified type of information about an access token.
|
||||
* The calling process must have appropriate access rights to obtain the information.
|
||||
|
||||
* @param tokenHandle
|
||||
* Handle to an access token from which information is retrieved. If TokenInformationClass
|
||||
* specifies TokenSource, the handle must have TOKEN_QUERY_SOURCE access. For all other
|
||||
* TokenInformationClass values, the handle must have TOKEN_QUERY access.
|
||||
* @param tokenInformationClass
|
||||
* Specifies a value from the TOKEN_INFORMATION_CLASS enumerated type to identify the type of
|
||||
* information the function retrieves.
|
||||
* @param tokenInformation
|
||||
* Pointer to a buffer the function fills with the requested information. The structure put
|
||||
* into this buffer depends upon the type of information specified by the TokenInformationClass
|
||||
* parameter.
|
||||
* @param tokenInformationLength
|
||||
* Specifies the size, in bytes, of the buffer pointed to by the TokenInformation parameter.
|
||||
* If TokenInformation is NULL, this parameter must be zero.
|
||||
* @param returnLength
|
||||
* Pointer to a variable that receives the number of bytes needed for the buffer pointed to by
|
||||
* the TokenInformation parameter. If this value is larger than the value specified in the
|
||||
* TokenInformationLength parameter, the function fails and stores no data in 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.
|
||||
*/
|
||||
public boolean GetTokenInformation(
|
||||
HANDLE tokenHandle,
|
||||
int tokenInformationClass,
|
||||
Structure tokenInformation,
|
||||
int tokenInformationLength,
|
||||
IntByReference returnLength);
|
||||
|
||||
/**
|
||||
* The ImpersonateLoggedOnUser function lets the calling thread impersonate the
|
||||
* security context of a logged-on user. The user is represented by a token
|
||||
* handle.
|
||||
* @param hToken
|
||||
* Handle to a primary or impersonation access token that represents a logged-on
|
||||
* user. This can be a token handle returned by a call to LogonUser,
|
||||
* CreateRestrictedToken, DuplicateToken, DuplicateTokenEx, OpenProcessToken,
|
||||
* or OpenThreadToken functions. If hToken is a primary token, it must have
|
||||
* TOKEN_QUERY and TOKEN_DUPLICATE access. If hToken is an impersonation token,
|
||||
* it must have TOKEN_QUERY and TOKEN_IMPERSONATE access.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
*/
|
||||
public boolean ImpersonateLoggedOnUser(
|
||||
HANDLE hToken);
|
||||
|
||||
/**
|
||||
* The RevertToSelf function terminates the impersonation of a client application.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*/
|
||||
public boolean RevertToSelf();
|
||||
|
||||
|
||||
/**
|
||||
* The RegOpenKeyEx function opens the specified registry key.
|
||||
* Note that key names are not case sensitive.
|
||||
* @param hKey
|
||||
* Handle to an open key.
|
||||
* @param lpSubKey
|
||||
* Pointer to a null-terminated string containing the name of the subkey to open.
|
||||
* @param ulOptions
|
||||
* Reserved; must be zero.
|
||||
* @param samDesired
|
||||
* Access mask that specifies the desired access rights to the key. The function
|
||||
* fails if the security descriptor of the key does not permit the requested access
|
||||
* for the calling process.
|
||||
* @param phkResult
|
||||
* Pointer to a variable that receives a handle to the opened key. If the key is
|
||||
* not one of the predefined registry keys, call the RegCloseKey function after
|
||||
* you have finished using the handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
* If the function fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegOpenKeyEx(HKEY hKey, String lpSubKey, int ulOptions, int samDesired,
|
||||
HKEYByReference phkResult);
|
||||
|
||||
/**
|
||||
* The RegQueryValueEx function retrieves the type and data for a specified value name
|
||||
* associated with an open registry key.
|
||||
* @param hKey
|
||||
* Handle to an open key. The key must have been opened with the
|
||||
* KEY_QUERY_VALUE access right.
|
||||
* @param lpValueName
|
||||
* Pointer to a null-terminated string containing the name of the value to query.
|
||||
* If lpValueName is NULL or an empty string, "", the function retrieves the type
|
||||
* and data for the key's unnamed or default value, if any.
|
||||
* @param lpReserved
|
||||
* Reserved; must be NULL.
|
||||
* @param lpType
|
||||
* Pointer to a variable that receives a code indicating the type of data stored
|
||||
* in the specified value.
|
||||
* @param lpData
|
||||
* Pointer to a buffer that receives the value's data. This parameter can be NULL
|
||||
* if the data is not required. If the data is a string, the function checks for
|
||||
* a terminating null character. If one is not found, the string is stored with a
|
||||
* null terminator if the buffer is large enough to accommodate the extra
|
||||
* character. Otherwise, the string is stored as is.
|
||||
* @param lpcbData
|
||||
* Pointer to a variable that specifies the size of the buffer pointed to by the
|
||||
* lpData parameter, in bytes. When the function returns, this variable contains
|
||||
* the size of the data copied to lpData. The lpcbData parameter can be NULL only
|
||||
* if lpData is NULL. If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ
|
||||
* type, this size includes any terminating null character or characters.
|
||||
* If the buffer specified by lpData parameter is not large enough to hold the
|
||||
* data, the function returns ERROR_MORE_DATA and stores the required buffer size
|
||||
* in the variable pointed to by lpcbData. In this case, the contents of the lpData
|
||||
* buffer are undefined. If lpData is NULL, and lpcbData is non-NULL, the function
|
||||
* returns ERROR_SUCCESS and stores the size of the data, in bytes, in the variable
|
||||
* pointed to by lpcbData. This enables an application to determine the best way
|
||||
* to allocate a buffer for the value's data.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS.
|
||||
* If the function fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
|
||||
IntByReference lpType, char[] lpData, IntByReference lpcbData);
|
||||
|
||||
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
public int RegQueryValueEx(HKEY hKey, String lpValueName, int lpReserved,
|
||||
IntByReference lpType, IntByReference lpData, IntByReference lpcbData);
|
||||
|
||||
/**
|
||||
* The RegCloseKey function releases a handle to the specified registry key.
|
||||
* @param hKey
|
||||
* Handle to the open key to be closed. The handle must have been opened by the
|
||||
* RegCreateKeyEx, RegOpenKeyEx, or RegConnectRegistry function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegCloseKey(HKEY hKey);
|
||||
|
||||
/**
|
||||
* The RegDeleteValue function removes a named value from the specified registry
|
||||
* key. Note that value names are not case sensitive.
|
||||
* @param hKey
|
||||
* Handle to an open key. The key must have been opened with the KEY_SET_VALUE
|
||||
* access right.
|
||||
* @param lpValueName
|
||||
* Pointer to a null-terminated string that names the value to remove. If this
|
||||
* parameter is NULL or an empty string, the value set by the RegSetValue function
|
||||
* is removed.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegDeleteValue(HKEY hKey, String lpValueName);
|
||||
|
||||
/**
|
||||
* The RegSetValueEx function sets the data and type of a specified value under a
|
||||
* registry key.
|
||||
* @param hKey
|
||||
* Handle to an open key. The key must have been opened with the KEY_SET_VALUE
|
||||
* access right.
|
||||
* @param lpValueName
|
||||
* Pointer to a string containing the name of the value to set. If a value with
|
||||
* this name is not already present in the key, the function adds it to the key.
|
||||
* If lpValueName is NULL or an empty string, "", the function sets the type and
|
||||
* data for the key's unnamed or default value.
|
||||
* @param Reserved
|
||||
* Reserved; must be zero.
|
||||
* @param dwType
|
||||
* Type of data pointed to by the lpData parameter.
|
||||
* @param lpData
|
||||
* Pointer to a buffer containing the data to be stored with the specified value name.
|
||||
* @param cbData
|
||||
* Size of the information pointed to by the lpData parameter, in bytes. If the data
|
||||
* is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must include the size of
|
||||
* the terminating null character or characters.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType,
|
||||
char[] lpData, int cbData);
|
||||
|
||||
public int RegSetValueEx(HKEY hKey, String lpValueName, int Reserved, int dwType,
|
||||
byte[] lpData, int cbData);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param hKey
|
||||
* @param lpSubKey
|
||||
* @param Reserved
|
||||
* @param lpClass
|
||||
* @param dwOptions
|
||||
* @param samDesired
|
||||
* @param lpSecurityAttributes
|
||||
* @param phkResult
|
||||
* @param lpdwDisposition
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegCreateKeyEx(HKEY hKey, String lpSubKey, int Reserved, String lpClass,
|
||||
int dwOptions, int samDesired, SECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
HKEYByReference phkResult, IntByReference lpdwDisposition);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param hKey
|
||||
* @param name
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegDeleteKey(HKEY hKey, String name);
|
||||
|
||||
/**
|
||||
* The RegEnumKeyEx function enumerates subkeys of the specified open registry key.
|
||||
* The function retrieves information about one subkey each time it is called.
|
||||
* @param hKey
|
||||
* Handle to an open key. The key must have been opened with the
|
||||
* KEY_ENUMERATE_SUB_KEYS access right.
|
||||
* @param dwIndex
|
||||
* Index of the subkey to retrieve. This parameter should be zero for the first
|
||||
* call to the RegEnumKeyEx function and then incremented for subsequent calls.
|
||||
* Because subkeys are not ordered, any new subkey will have an arbitrary index.
|
||||
* This means that the function may return subkeys in any order.
|
||||
* @param lpName
|
||||
* Pointer to a buffer that receives the name of the subkey, including the
|
||||
* terminating null character. The function copies only the name of the subkey,
|
||||
* not the full key hierarchy, to the buffer.
|
||||
* @param lpcName
|
||||
* Pointer to a variable that specifies the size of the buffer specified by the
|
||||
* lpName parameter, in TCHARs. This size should include the terminating null
|
||||
* character. When the function returns, the variable pointed to by lpcName
|
||||
* contains the number of characters stored in the buffer. The count returned
|
||||
* does not include the terminating null character.
|
||||
* @param reserved
|
||||
* Reserved; must be NULL.
|
||||
* @param lpClass
|
||||
* Pointer to a buffer that receives the null-terminated class string of the
|
||||
* enumerated subkey. This parameter can be NULL.
|
||||
* @param lpcClass
|
||||
* Pointer to a variable that specifies the size of the buffer specified by the
|
||||
* lpClass parameter, in TCHARs. The size should include the terminating null
|
||||
* character. When the function returns, lpcClass contains the number of
|
||||
* characters stored in the buffer. The count returned does not include the
|
||||
* terminating null character. This parameter can be NULL only if lpClass is NULL.
|
||||
* @param lpftLastWriteTime
|
||||
* Pointer to a variable that receives the time at which the enumerated subkey
|
||||
* was last written.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegEnumKeyEx(HKEY hKey, int dwIndex, char[] lpName, IntByReference lpcName,
|
||||
IntByReference reserved, char[] lpClass, IntByReference lpcClass,
|
||||
WinBase.FILETIME lpftLastWriteTime);
|
||||
|
||||
/**
|
||||
* The RegEnumValue function enumerates the values for the specified open registry
|
||||
* key. The function copies one indexed value name and data block for the key each
|
||||
* time it is called.
|
||||
* @param hKey
|
||||
* Handle to an open key. The key must have been opened with the KEY_QUERY_VALUE
|
||||
* access right.
|
||||
* @param dwIndex
|
||||
* Index of the value to be retrieved. This parameter should be zero for the first
|
||||
* call to the RegEnumValue function and then be incremented for subsequent calls.
|
||||
* Because values are not ordered, any new value will have an arbitrary index.
|
||||
* This means that the function may return values in any order.
|
||||
* @param lpValueName
|
||||
* Pointer to a buffer that receives the name of the value, including the
|
||||
* terminating null character.
|
||||
* @param lpcchValueName
|
||||
* Pointer to a variable that specifies the size of the buffer pointed to by the
|
||||
* lpValueName parameter, in TCHARs. This size should include the terminating null
|
||||
* character. When the function returns, the variable pointed to by lpcValueName
|
||||
* contains the number of characters stored in the buffer. The count returned
|
||||
* does not include the terminating null character.
|
||||
* @param reserved
|
||||
* Reserved; must be NULL.
|
||||
* @param lpType
|
||||
* Pointer to a variable that receives a code indicating the type of data stored
|
||||
* in the specified value.
|
||||
* @param lpData
|
||||
* Pointer to a buffer that receives the data for the value entry. This parameter
|
||||
* can be NULL if the data is not required.
|
||||
* @param lpcbData
|
||||
* Pointer to a variable that specifies the size of the buffer pointed to by the
|
||||
* lpData parameter, in bytes.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegEnumValue(HKEY hKey, int dwIndex, char[] lpValueName,
|
||||
IntByReference lpcchValueName, IntByReference reserved,
|
||||
IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
/**
|
||||
* The RegQueryInfoKey function retrieves information about the specified
|
||||
* registry key.
|
||||
* @param hKey
|
||||
* A handle to an open key. The key must have been opened with the
|
||||
* KEY_QUERY_VALUE access right.
|
||||
* @param lpClass
|
||||
* A pointer to a buffer that receives the null-terminated class
|
||||
* string of the key. This parameter can be ignored. This parameter can be NULL.
|
||||
* @param lpcClass
|
||||
* A pointer to a variable that specifies the size of the buffer pointed to by
|
||||
* the lpClass parameter, in characters.
|
||||
* @param lpReserved
|
||||
* Reserved; must be NULL.
|
||||
* @param lpcSubKeys
|
||||
* A pointer to a variable that receives the number of subkeys that are contained by the specified key.
|
||||
* This parameter can be NULL.
|
||||
* @param lpcMaxSubKeyLen
|
||||
* A pointer to a variable that receives the size of the key's subkey with the
|
||||
* longest name, in characters, not including the terminating null character.
|
||||
* This parameter can be NULL.
|
||||
* @param lpcMaxClassLen
|
||||
* A pointer to a variable that receives the size of the longest string that
|
||||
* specifies a subkey class, in characters. The count returned does not include
|
||||
* the terminating null character. This parameter can be NULL.
|
||||
* @param lpcValues
|
||||
* A pointer to a variable that receives the number of values that are associated
|
||||
* with the key. This parameter can be NULL.
|
||||
* @param lpcMaxValueNameLen
|
||||
* A pointer to a variable that receives the size of the key's longest value name,
|
||||
* in characters. The size does not include the terminating null character. This
|
||||
* parameter can be NULL.
|
||||
* @param lpcMaxValueLen
|
||||
* A pointer to a variable that receives the size of the longest data component
|
||||
* among the key's values, in bytes. This parameter can be NULL.
|
||||
* @param lpcbSecurityDescriptor
|
||||
* A pointer to a variable that receives the size of the key's security descriptor,
|
||||
* in bytes. This parameter can be NULL.
|
||||
* @param lpftLastWriteTime
|
||||
* A pointer to a FILETIME structure that receives the last write time.
|
||||
* This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is ERROR_SUCCESS. If the function
|
||||
* fails, the return value is a nonzero error code defined in Winerror.h.
|
||||
*/
|
||||
public int RegQueryInfoKey(HKEY hKey, char[] lpClass,
|
||||
IntByReference lpcClass, IntByReference lpReserved,
|
||||
IntByReference lpcSubKeys, IntByReference lpcMaxSubKeyLen,
|
||||
IntByReference lpcMaxClassLen, IntByReference lpcValues,
|
||||
IntByReference lpcMaxValueNameLen, IntByReference lpcMaxValueLen,
|
||||
IntByReference lpcbSecurityDescriptor,
|
||||
WinBase.FILETIME lpftLastWriteTime);
|
||||
}
|
||||
@@ -0,0 +1,880 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.sun.jna.Memory;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLE;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSIDByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.SID_AND_ATTRIBUTES;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEY;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Advapi32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Advapi32Util {
|
||||
|
||||
/**
|
||||
* A group.
|
||||
*/
|
||||
public static class Group {
|
||||
/**
|
||||
* Group name. When unavailable, always equals to sidString.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* String representation of the group SID.
|
||||
*/
|
||||
public String sidString;
|
||||
/**
|
||||
* Binary representation of the group SID.
|
||||
*/
|
||||
public byte[] sid;
|
||||
}
|
||||
|
||||
/**
|
||||
* An account.
|
||||
*/
|
||||
public static class Account {
|
||||
/**
|
||||
* Account name.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Account domain.
|
||||
*/
|
||||
public String domain;
|
||||
/**
|
||||
* Account SID.
|
||||
*/
|
||||
public byte[] sid;
|
||||
/**
|
||||
* String representation of the account SID.
|
||||
*/
|
||||
public String sidString;
|
||||
/**
|
||||
* Account type, one of SID_NAME_USE.
|
||||
*/
|
||||
public int accountType;
|
||||
/**
|
||||
* Fully qualified account name.
|
||||
*/
|
||||
public String fqn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user associated with the current thread.
|
||||
* @return A user name.
|
||||
*/
|
||||
public static String getUserName() {
|
||||
char[] buffer = new char[128];
|
||||
IntByReference len = new IntByReference(buffer.length);
|
||||
boolean result = Advapi32.INSTANCE.GetUserNameW(buffer, len);
|
||||
|
||||
if (! result) {
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
|
||||
buffer = new char[len.getValue()];
|
||||
break;
|
||||
default:
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
result = Advapi32.INSTANCE.GetUserNameW(buffer, len);
|
||||
}
|
||||
|
||||
if (! result) {
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a security identifier (SID) for the account on the current system.
|
||||
* @param accountName Specifies the account name.
|
||||
* @return A structure containing the account SID;
|
||||
*/
|
||||
public static Account getAccountByName(String accountName) {
|
||||
return getAccountByName(null, accountName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a security identifier (SID) for a given account.
|
||||
* @param systemName Name of the system.
|
||||
* @param accountName Account name.
|
||||
* @return A structure containing the account SID.
|
||||
*/
|
||||
public static Account getAccountByName(String systemName, String accountName) {
|
||||
IntByReference pSid = new IntByReference(0);
|
||||
IntByReference cchDomainName = new IntByReference(0);
|
||||
PointerByReference peUse = new PointerByReference();
|
||||
|
||||
if (Advapi32.INSTANCE.LookupAccountName(systemName, accountName, null, pSid, null, cchDomainName, peUse)) {
|
||||
throw new RuntimeException("LookupAccountNameW was expected to fail with ERROR_INSUFFICIENT_BUFFER");
|
||||
}
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
if (pSid.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
|
||||
Memory sidMemory = new Memory(pSid.getValue());
|
||||
PSID result = new PSID(sidMemory);
|
||||
char[] referencedDomainName = new char[cchDomainName.getValue() + 1];
|
||||
|
||||
if (! Advapi32.INSTANCE.LookupAccountName(systemName, accountName, result, pSid, referencedDomainName, cchDomainName, peUse)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
Account account = new Account();
|
||||
account.accountType = peUse.getPointer().getInt(0);
|
||||
account.name = accountName;
|
||||
|
||||
String[] accountNamePartsBs = accountName.split("\\\\", 2);
|
||||
String[] accountNamePartsAt = accountName.split("@", 2);
|
||||
|
||||
if (accountNamePartsBs.length == 2) {
|
||||
account.name = accountNamePartsBs[1];
|
||||
} else if (accountNamePartsAt.length == 2) {
|
||||
account.name = accountNamePartsAt[0];
|
||||
} else {
|
||||
account.name = accountName;
|
||||
}
|
||||
|
||||
if (cchDomainName.getValue() > 0) {
|
||||
account.domain = Native.toString(referencedDomainName);
|
||||
account.fqn = account.domain + "\\" + account.name;
|
||||
} else {
|
||||
account.fqn = account.name;
|
||||
}
|
||||
|
||||
account.sid = result.getBytes();
|
||||
account.sidString = convertSidToStringSid(new PSID(account.sid));
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the account by SID on the local system.
|
||||
*
|
||||
* @param sid SID.
|
||||
* @return Account.
|
||||
*/
|
||||
public static Account getAccountBySid(PSID sid) {
|
||||
return getAccountBySid(null, sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the account by SID.
|
||||
*
|
||||
* @param systemName Name of the system.
|
||||
* @param sid SID.
|
||||
* @return Account.
|
||||
*/
|
||||
public static Account getAccountBySid(String systemName, PSID sid) {
|
||||
IntByReference cchName = new IntByReference();
|
||||
IntByReference cchDomainName = new IntByReference();
|
||||
PointerByReference peUse = new PointerByReference();
|
||||
|
||||
if (Advapi32.INSTANCE.LookupAccountSid(null, sid,
|
||||
null, cchName, null, cchDomainName, peUse)) {
|
||||
throw new RuntimeException("LookupAccountSidW was expected to fail with ERROR_INSUFFICIENT_BUFFER");
|
||||
}
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
if (cchName.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
|
||||
char[] domainName = new char[cchDomainName.getValue()];
|
||||
char[] name = new char[cchName.getValue()];
|
||||
|
||||
if (! Advapi32.INSTANCE.LookupAccountSid(null, sid,
|
||||
name, cchName, domainName, cchDomainName, peUse)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
Account account = new Account();
|
||||
account.accountType = peUse.getPointer().getInt(0);
|
||||
account.name = Native.toString(name);
|
||||
|
||||
if (cchDomainName.getValue() > 0) {
|
||||
account.domain = Native.toString(domainName);
|
||||
account.fqn = account.domain + "\\" + account.name;
|
||||
} else {
|
||||
account.fqn = account.name;
|
||||
}
|
||||
|
||||
account.sid = sid.getBytes();
|
||||
account.sidString = convertSidToStringSid(sid);
|
||||
return account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a security identifier (SID) to a string format suitable for display,
|
||||
* storage, or transmission.
|
||||
* @param sid SID bytes.
|
||||
* @return String SID.
|
||||
*/
|
||||
public static String convertSidToStringSid(PSID sid) {
|
||||
PointerByReference stringSid = new PointerByReference();
|
||||
if (! Advapi32.INSTANCE.ConvertSidToStringSid(sid, stringSid)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
String result = stringSid.getValue().getString(0, true);
|
||||
Kernel32.INSTANCE.LocalFree(stringSid.getValue());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a string representation of a security identifier (SID) to
|
||||
* a binary format.
|
||||
* @param sid String SID.
|
||||
* @return SID bytes.
|
||||
*/
|
||||
public static byte[] convertStringSidToSid(String sid) {
|
||||
PSIDByReference pSID = new PSIDByReference();
|
||||
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sid, pSID)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pSID.getValue().getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an account name from a string SID on the local machine.
|
||||
*
|
||||
* @param sidString SID.
|
||||
* @return Account.
|
||||
*/
|
||||
public static Account getAccountBySid(String sidString) {
|
||||
return getAccountBySid(null, sidString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an account name from a string SID.
|
||||
*
|
||||
* @param systemName System name.
|
||||
* @param sidString SID.
|
||||
* @return Account.
|
||||
*/
|
||||
public static Account getAccountBySid(String systemName, String sidString) {
|
||||
return getAccountBySid(systemName, new PSID(convertStringSidToSid(sidString)));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the groups associated with a security token,
|
||||
* such as a user token.
|
||||
*
|
||||
* @param hToken Token.
|
||||
* @return Token groups.
|
||||
*/
|
||||
public static Group[] getTokenGroups(HANDLE hToken) {
|
||||
// get token group information size
|
||||
IntByReference tokenInformationLength = new IntByReference();
|
||||
if (Advapi32.INSTANCE.GetTokenInformation(hToken,
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength)
|
||||
|| Kernel32.INSTANCE.GetLastError() != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
|
||||
}
|
||||
// get token group information
|
||||
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
|
||||
WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationBuffer);
|
||||
if (! Advapi32.INSTANCE.GetTokenInformation(hToken,
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, groups,
|
||||
tokenInformationLength.getValue(), tokenInformationLength)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
ArrayList<Group> userGroups = new ArrayList<Group>();
|
||||
// make array of names
|
||||
for (SID_AND_ATTRIBUTES sidAndAttribute : groups.getGroups()) {
|
||||
Group group = new Group();
|
||||
group.sid = sidAndAttribute.Sid.getBytes();
|
||||
group.sidString = Advapi32Util.convertSidToStringSid(sidAndAttribute.Sid);
|
||||
try {
|
||||
group.name = Advapi32Util.getAccountBySid(sidAndAttribute.Sid).name;
|
||||
} catch(Exception e) {
|
||||
group.name = group.sidString;
|
||||
}
|
||||
userGroups.add(group);
|
||||
}
|
||||
return userGroups.toArray(new Group[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns the information about the user who owns a security token,
|
||||
*
|
||||
* @param hToken Token.
|
||||
* @return Token user.
|
||||
*/
|
||||
public static Account getTokenAccount(HANDLE hToken) {
|
||||
// get token group information size
|
||||
IntByReference tokenInformationLength = new IntByReference();
|
||||
if (Advapi32.INSTANCE.GetTokenInformation(hToken,
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength)
|
||||
|| Kernel32.INSTANCE.GetLastError() != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
|
||||
}
|
||||
// get token user information
|
||||
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
|
||||
WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationBuffer);
|
||||
if (! Advapi32.INSTANCE.GetTokenInformation(hToken,
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, user,
|
||||
tokenInformationLength.getValue(), tokenInformationLength)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return getAccountBySid(user.User.Sid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the group memberships of the currently logged on user.
|
||||
* @return An array of groups.
|
||||
*/
|
||||
public static Group[] getCurrentUserGroups() {
|
||||
HANDLEByReference phToken = new HANDLEByReference();
|
||||
try {
|
||||
// open thread or process token
|
||||
HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread();
|
||||
if (! Advapi32.INSTANCE.OpenThreadToken(threadHandle,
|
||||
WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, true, phToken)) {
|
||||
if (W32Errors.ERROR_NO_TOKEN != Kernel32.INSTANCE.GetLastError()) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
|
||||
if (! Advapi32.INSTANCE.OpenProcessToken(processHandle,
|
||||
WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
return getTokenGroups(phToken.getValue());
|
||||
} finally {
|
||||
if (phToken.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
|
||||
if (! Kernel32.INSTANCE.CloseHandle(phToken.getValue())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a registry key exists.
|
||||
* @param root
|
||||
* HKEY_LOCAL_MACHINE, etc.
|
||||
* @param key
|
||||
* Path to the registry key.
|
||||
* @return
|
||||
* True if the key exists.
|
||||
*/
|
||||
public static boolean registryKeyExists(HKEY root, String key) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_SUCCESS:
|
||||
Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
return true;
|
||||
case W32Errors.ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
default:
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a registry value exists.
|
||||
* @param root
|
||||
* HKEY_LOCAL_MACHINE, etc.
|
||||
* @param key
|
||||
* Registry key path.
|
||||
* @param value
|
||||
* Value name.
|
||||
* @return
|
||||
* True if the value exists.
|
||||
*/
|
||||
public static boolean registryValueExists(HKEY root, String key, String value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
|
||||
try {
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_SUCCESS:
|
||||
break;
|
||||
case W32Errors.ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
default:
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(
|
||||
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_SUCCESS:
|
||||
case W32Errors.ERROR_INSUFFICIENT_BUFFER:
|
||||
return true;
|
||||
case W32Errors.ERROR_FILE_NOT_FOUND:
|
||||
return false;
|
||||
default:
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
} finally {
|
||||
if (phkKey.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_SZ value.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param key
|
||||
* Registry path.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return
|
||||
* String value.
|
||||
*/
|
||||
public static String registryGetStringValue(HKEY root, String key, String value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(
|
||||
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
char[] data = new char[lpcbData.getValue()];
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(
|
||||
phkKey.getValue(), value, 0, lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return Native.toString(data);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry DWORD value.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param key
|
||||
* Registry key path.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return
|
||||
* Integer value.
|
||||
*/
|
||||
public static int registryGetIntValue(HKEY root, String key, String value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
IntByReference lpcbData = new IntByReference();
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(
|
||||
phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
if (lpType.getValue() != WinNT.REG_DWORD) {
|
||||
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
IntByReference data = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegQueryValueEx(
|
||||
phkKey.getValue(), value, 0, lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return data.getValue();
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a registry key.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param keyName
|
||||
* Key name.
|
||||
*/
|
||||
public static void registryCreateKey(HKEY hKey, String keyName) {
|
||||
HKEYByReference phkResult = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegCreateKeyEx(hKey, keyName, 0, null, 0,
|
||||
WinNT.KEY_READ, null, phkResult, null);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a registry key.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param parentPath
|
||||
* Path to an existing registry key.
|
||||
* @param keyName
|
||||
* Key name.
|
||||
*/
|
||||
public static void registryCreateKey(HKEY root, String parentPath, String keyName) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, parentPath, 0, WinNT.KEY_CREATE_SUB_KEY, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
registryCreateKey(phkKey.getValue(), keyName);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an integer value in registry.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Name.
|
||||
* @param value
|
||||
* Value.
|
||||
*/
|
||||
public static void registrySetIntValue(HKEY hKey, String name, int value) {
|
||||
byte[] data = new byte[4];
|
||||
data[0] = (byte)(value & 0xff);
|
||||
data[1] = (byte)((value >> 8) & 0xff);
|
||||
data[2] = (byte)((value >> 16) & 0xff);
|
||||
data[3] = (byte)((value >> 24) & 0xff);
|
||||
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_DWORD, data, 4);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an integer value in registry.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param name
|
||||
* Name.
|
||||
* @param value
|
||||
* Value.
|
||||
*/
|
||||
public static void registrySetIntValue(HKEY root, String keyPath, String name, int value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
registrySetIntValue(phkKey.getValue(), name, value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a string value in registry.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Name.
|
||||
* @param value
|
||||
* Value.
|
||||
*/
|
||||
public static void registrySetStringValue(HKEY hKey, String name, String value) {
|
||||
char[] data = Native.toCharArray(value);
|
||||
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ, data, data.length * 2);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a string value in registry.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param name
|
||||
* Name.
|
||||
* @param value
|
||||
* Value.
|
||||
*/
|
||||
public static void registrySetStringValue(HKEY root, String keyPath, String name, String value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
registrySetStringValue(phkKey.getValue(), name, value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a registry key.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param keyName
|
||||
* Name of the key to delete.
|
||||
*/
|
||||
public static void registryDeleteKey(HKEY hKey, String keyName) {
|
||||
int rc = Advapi32.INSTANCE.RegDeleteKey(hKey, keyName);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a registry key.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param keyName
|
||||
* Name of the key to delete.
|
||||
*/
|
||||
public static void registryDeleteKey(HKEY root, String keyPath, String keyName) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
registryDeleteKey(phkKey.getValue(), keyName);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a registry value.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param valueName
|
||||
* Name of the value to delete.
|
||||
*/
|
||||
public static void registryDeleteValue(HKEY hKey, String valueName) {
|
||||
int rc = Advapi32.INSTANCE.RegDeleteValue(hKey, valueName);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a registry value.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param valueName
|
||||
* Name of the value to delete.
|
||||
*/
|
||||
public static void registryDeleteValue(HKEY root, String keyPath, String valueName) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ | WinNT.KEY_WRITE, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
registryDeleteValue(phkKey.getValue(), valueName);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get names of the registry key's sub-keys.
|
||||
* @param hKey
|
||||
* Registry key.
|
||||
* @return
|
||||
* Array of registry key names.
|
||||
*/
|
||||
public static String[] registryGetKeys(HKEY hKey) {
|
||||
IntByReference lpcSubKeys = new IntByReference();
|
||||
IntByReference lpcMaxSubKeyLen = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null,
|
||||
lpcSubKeys, lpcMaxSubKeyLen, null, null, null, null, null, null);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
ArrayList<String> keys = new ArrayList<String>(lpcSubKeys.getValue());
|
||||
char[] name = new char[lpcMaxSubKeyLen.getValue() + 1];
|
||||
for (int i = 0; i < lpcSubKeys.getValue(); i++) {
|
||||
IntByReference lpcchValueName = new IntByReference(lpcMaxSubKeyLen.getValue() + 1);
|
||||
rc = Advapi32.INSTANCE.RegEnumKeyEx(hKey, i, name, lpcchValueName,
|
||||
null, null, null, null);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
keys.add(Native.toString(name));
|
||||
}
|
||||
return keys.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get names of the registry key's sub-keys.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to a registry key.
|
||||
* @return
|
||||
* Array of registry key names.
|
||||
*/
|
||||
public static String[] registryGetKeys(HKEY root, String keyPath) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
return registryGetKeys(phkKey.getValue());
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a table of registry values.
|
||||
* @param hKey
|
||||
* Registry key.
|
||||
* @return
|
||||
* Table of values.
|
||||
*/
|
||||
public static TreeMap<String, Object> registryGetValues(HKEY hKey) {
|
||||
IntByReference lpcValues = new IntByReference();
|
||||
IntByReference lpcMaxValueNameLen = new IntByReference();
|
||||
IntByReference lpcMaxValueLen = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null, null,
|
||||
null, null, lpcValues, lpcMaxValueNameLen, lpcMaxValueLen, null, null);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
TreeMap<String, Object> keyValues = new TreeMap<String, Object>();
|
||||
char[] name = new char[lpcMaxValueNameLen.getValue() + 1];
|
||||
byte[] data = new byte[lpcMaxValueLen.getValue()];
|
||||
for (int i = 0; i < lpcValues.getValue(); i++) {
|
||||
IntByReference lpcchValueName = new IntByReference(lpcMaxValueNameLen.getValue() + 1);
|
||||
IntByReference lpcbData = new IntByReference(lpcMaxValueLen.getValue());
|
||||
IntByReference lpType = new IntByReference();
|
||||
rc = Advapi32.INSTANCE.RegEnumValue(hKey, i, name, lpcchValueName, null,
|
||||
lpType, data, lpcbData);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
switch(lpType.getValue()) {
|
||||
case WinNT.REG_DWORD:
|
||||
keyValues.put(Native.toString(name),
|
||||
((int)(data[0] & 0xff)) +
|
||||
(((int)(data[1] & 0xff)) << 8) +
|
||||
(((int)(data[2] & 0xff)) << 16) +
|
||||
(((int)(data[3] & 0xff)) << 24));
|
||||
break;
|
||||
case WinNT.REG_SZ:
|
||||
try {
|
||||
keyValues.put(Native.toString(name),
|
||||
new String(data, 0, data.length - 2, "UTF-16LE"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported type: " + lpType.getValue());
|
||||
}
|
||||
}
|
||||
return keyValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a table of registry values.
|
||||
* @param root
|
||||
* Registry root.
|
||||
* @param keyPath
|
||||
* Regitry key path.
|
||||
* @return
|
||||
* Table of values.
|
||||
*/
|
||||
public static TreeMap<String, Object> registryGetValues(HKEY root, String keyPath) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, keyPath, 0, WinNT.KEY_READ, phkKey);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) { throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
return registryGetValues(phkKey.getValue());
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/* 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.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.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Crypt32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Crypt32 extends W32API {
|
||||
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
|
||||
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* The CryptProtectData function performs encryption on the data in a DATA_BLOB
|
||||
* structure. Typically, only a user with the same logon credential as the encrypter
|
||||
* can decrypt the data. In addition, the encryption and decryption usually must be
|
||||
* done on the same computer.
|
||||
* @param pDataIn
|
||||
* Pointer to a DATA_BLOB structure that contains the plaintext to be encrypted.
|
||||
* @param szDataDescr
|
||||
* String with a readable description of the data to be encrypted. This description
|
||||
* string is included with the encrypted data. This parameter is optional and can
|
||||
* be set to NULL, except on Windows 2000.
|
||||
* @param pOptionalEntropy
|
||||
* Pointer to a DATA_BLOB structure that contains a password or other additional
|
||||
* entropy used to encrypt the data. The DATA_BLOB structure used in the encryption
|
||||
* phase must also be used in the decryption phase. This parameter can be set to NULL
|
||||
* for no additional entropy.
|
||||
* @param pvReserved
|
||||
* Reserved for future use and must be set to NULL.
|
||||
* @param pPromptStruct
|
||||
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
|
||||
* where and when prompts are to be displayed and what the content of those prompts
|
||||
* should be. This parameter can be set to NULL in both the encryption and decryption
|
||||
* phases.
|
||||
* @param dwFlags
|
||||
* One of CRYPTPROTECT_LOCAL_MACHINE, CRYPTPROTECT_UI_FORBIDDEN, CRYPTPROTECT_AUDIT,
|
||||
* CRYPTPROTECT_VERIFY_PROTECTION.
|
||||
* @param pDataOut
|
||||
* Pointer to a DATA_BLOB structure that receives the encrypted data. When you have
|
||||
* finished using the DATA_BLOB structure, free its pbData member by calling the
|
||||
* LocalFree function.
|
||||
* @return
|
||||
* If the function succeeds, the function returns TRUE. If the function fails,
|
||||
* it returns FALSE. For extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean CryptProtectData(DATA_BLOB pDataIn, String szDataDescr,
|
||||
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
|
||||
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
|
||||
int dwFlags,
|
||||
DATA_BLOB pDataOut);
|
||||
|
||||
/**
|
||||
* The CryptUnprotectData function decrypts and does an integrity check of the data in
|
||||
* a DATA_BLOB structure. Usually, only a user with the same logon credentials as the
|
||||
* encrypter can decrypt the data. In addition, the encryption and decryption must be
|
||||
* done on the same computer.
|
||||
* @param pDataIn
|
||||
* Pointer to a DATA_BLOB structure that holds the encrypted data. The DATA_BLOB
|
||||
* structure's cbData member holds the length of the pbData member's byte string that
|
||||
* contains the text to be encrypted.
|
||||
* @param szDataDescr
|
||||
* Pointer to a string-readable description of the encrypted data included with the
|
||||
* encrypted data. This parameter can be set to NULL. When you have finished using
|
||||
* ppszDataDescr, free it by calling the LocalFree function.
|
||||
* @param pOptionalEntropy
|
||||
* Pointer to a DATA_BLOB structure that contains a password or other additional
|
||||
* entropy used when the data was encrypted. This parameter can be set to NULL;
|
||||
* however, if an optional entropy DATA_BLOB structure was used in the encryption
|
||||
* phase, that same DATA_BLOB structure must be used for the decryption phase.
|
||||
* @param pvReserved
|
||||
* Reserved for future use; must be set to NULL.
|
||||
* @param pPromptStruct
|
||||
* Pointer to a CRYPTPROTECT_PROMPTSTRUCT structure that provides information about
|
||||
* where and when prompts are to be displayed and what the content of those prompts
|
||||
* should be. This parameter can be set to NULL.
|
||||
* @param dwFlags
|
||||
* DWORD value that specifies options for this function. This parameter can be zero,
|
||||
* in which case no option is set, or CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @param pDataOut
|
||||
* Pointer to a DATA_BLOB structure where the function stores the decrypted data.
|
||||
* When you have finished using the DATA_BLOB structure, free its pbData member by
|
||||
* calling the LocalFree function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is TRUE. If the function fails, the
|
||||
* return value is FALSE.
|
||||
*/
|
||||
public boolean CryptUnprotectData(DATA_BLOB pDataIn, PointerByReference szDataDescr,
|
||||
DATA_BLOB pOptionalEntropy, Pointer pvReserved,
|
||||
CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
|
||||
int dwFlags,
|
||||
DATA_BLOB pDataOut);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/* Copyright (c) 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.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Crypt32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Crypt32Util {
|
||||
|
||||
/**
|
||||
* Protect a blob of data.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @return
|
||||
* Protected data.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data) {
|
||||
return cryptProtectData(data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a blob of data with optional flags.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @param flags
|
||||
* Optional flags, eg. CRYPTPROTECT_LOCAL_MACHINE | CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @return
|
||||
* Protected data.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data, int flags) {
|
||||
return cryptProtectData(data, null, flags, "", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect a blob of data.
|
||||
* @param data
|
||||
* Data to protect.
|
||||
* @param entropy
|
||||
* Optional entropy.
|
||||
* @param flags
|
||||
* Optional flags.
|
||||
* @param description
|
||||
* Optional description.
|
||||
* @param prompt
|
||||
* Prompt structure.
|
||||
* @return
|
||||
* Protected bytes.
|
||||
*/
|
||||
public static byte[] cryptProtectData(byte[] data, byte[] entropy, int flags,
|
||||
String description, CRYPTPROTECT_PROMPTSTRUCT prompt) {
|
||||
DATA_BLOB pDataIn = new DATA_BLOB(data);
|
||||
DATA_BLOB pDataProtected = new DATA_BLOB();
|
||||
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
|
||||
try {
|
||||
if (! Crypt32.INSTANCE.CryptProtectData(pDataIn, description,
|
||||
pEntropy, null, prompt, flags, pDataProtected)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pDataProtected.getData();
|
||||
} finally {
|
||||
if (pDataProtected.pbData != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDataProtected.pbData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data) {
|
||||
return cryptUnprotectData(data, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @param flags
|
||||
* Optional flags, eg. CRYPTPROTECT_UI_FORBIDDEN.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data, int flags) {
|
||||
return cryptUnprotectData(data, null, flags, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unprotect a blob of data.
|
||||
* @param data
|
||||
* Data to unprotect.
|
||||
* @param entropy
|
||||
* Optional entropy.
|
||||
* @param flags
|
||||
* Optional flags.
|
||||
* @param prompt
|
||||
* Optional prompt structure.
|
||||
* @return
|
||||
* Unprotected blob of data.
|
||||
*/
|
||||
public static byte[] cryptUnprotectData(byte[] data, byte[] entropy, int flags,
|
||||
CRYPTPROTECT_PROMPTSTRUCT prompt) {
|
||||
DATA_BLOB pDataIn = new DATA_BLOB(data);
|
||||
DATA_BLOB pDataUnprotected = new DATA_BLOB();
|
||||
DATA_BLOB pEntropy = (entropy == null) ? null : new DATA_BLOB(entropy);
|
||||
PointerByReference pDescription = new PointerByReference();
|
||||
try {
|
||||
if (! Crypt32.INSTANCE.CryptUnprotectData(pDataIn, pDescription,
|
||||
pEntropy, null, prompt, flags, pDataUnprotected)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pDataUnprotected.getData();
|
||||
} finally {
|
||||
if (pDataUnprotected.pbData != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDataUnprotected.pbData);
|
||||
}
|
||||
if (pDescription.getValue() != null) {
|
||||
Kernel32.INSTANCE.LocalFree(pDescription.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
|
||||
|
||||
/**
|
||||
* Ported from DsGetDC.h.
|
||||
* Windows SDK 6.0a
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class DsGetDC {
|
||||
|
||||
/**
|
||||
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
|
||||
* function to receive data about a domain controller.
|
||||
*/
|
||||
public static class DOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends DOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO() {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the computer name
|
||||
* of the discovered domain controller. The returned computer name is
|
||||
* prefixed with "\\". The DNS-style name, for example, "\\phoenix.fabrikam.com",
|
||||
* is returned, if available. If the DNS-style name is not available, the
|
||||
* flat-style name (for example, "\\phoenix") is returned. This example would apply
|
||||
* if the domain is a Windows NT 4.0 domain or if the domain does not support the
|
||||
* IP family of protocols.
|
||||
*/
|
||||
public WString DomainControllerName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the address of the discovered
|
||||
* domain controller. The address is prefixed with "\\". This WString is one of the
|
||||
* types defined by the DomainControllerAddressType member.
|
||||
*/
|
||||
public WString DomainControllerAddress;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the DomainControllerAddress member.
|
||||
*/
|
||||
public int DomainControllerAddressType;
|
||||
/**
|
||||
* The GUID of the domain. This member is zero if the domain controller does not have
|
||||
* a Domain GUID; for example, the domain controller is not a Windows 2000 domain
|
||||
* controller.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain. The
|
||||
* DNS-style name, for example, "fabrikam.com", is returned if available. Otherwise,
|
||||
* the flat-style name, for example, "fabrikam", is returned. This name may be different
|
||||
* than the requested domain name if the domain has been renamed.
|
||||
*/
|
||||
public WString DomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree. The DNS-style name, for example, "fabrikam.com", is returned if
|
||||
* available. Otherwise, the flat-style name, for example, "fabrikam" is returned.
|
||||
*/
|
||||
public WString DnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int Flags;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site where the
|
||||
* domain controller is located. This member may be NULL if the domain controller is
|
||||
* not in a site; for example, the domain controller is a Windows NT 4.0 domain
|
||||
* controller.
|
||||
*/
|
||||
public WString DcSiteName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the site that the
|
||||
* computer belongs to. The computer is specified in the ComputerName parameter passed
|
||||
* to DsGetDcName. This member may be NULL if the site that contains the computer
|
||||
* cannot be found; for example, if the DS administrator has not associated the
|
||||
* subnet that the computer is in with a valid site.
|
||||
*/
|
||||
public WString ClientSiteName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to DOMAIN_CONTROLLER_INFO.
|
||||
*/
|
||||
public static class PDOMAIN_CONTROLLER_INFO extends Structure {
|
||||
|
||||
public static class ByReference extends PDOMAIN_CONTROLLER_INFO implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DOMAIN_CONTROLLER_INFO.ByReference dci;
|
||||
}
|
||||
|
||||
/**
|
||||
* Domain is a member of the forest.
|
||||
*/
|
||||
public static final int DS_DOMAIN_IN_FOREST = 0x0001;
|
||||
/**
|
||||
* Domain is directly trusted.
|
||||
*/
|
||||
public static final int DS_DOMAIN_DIRECT_OUTBOUND = 0x0002;
|
||||
/**
|
||||
* Domain is root of a tree in the forest.
|
||||
*/
|
||||
public static final int DS_DOMAIN_TREE_ROOT = 0x0004;
|
||||
/**
|
||||
* Domain is the primary domain of queried server.
|
||||
*/
|
||||
public static final int DS_DOMAIN_PRIMARY = 0x0008;
|
||||
/**
|
||||
* Primary domain is running in native mode.
|
||||
*/
|
||||
public static final int DS_DOMAIN_NATIVE_MODE = 0x0010;
|
||||
/**
|
||||
* Domain is directly trusting.
|
||||
*/
|
||||
public static final int DS_DOMAIN_DIRECT_INBOUND = 0x0020;
|
||||
/**
|
||||
* Valid domain flags.
|
||||
*/
|
||||
public static final int DS_DOMAIN_VALID_FLAGS =
|
||||
DS_DOMAIN_IN_FOREST |
|
||||
DS_DOMAIN_DIRECT_OUTBOUND |
|
||||
DS_DOMAIN_TREE_ROOT |
|
||||
DS_DOMAIN_PRIMARY |
|
||||
DS_DOMAIN_NATIVE_MODE |
|
||||
DS_DOMAIN_DIRECT_INBOUND;
|
||||
|
||||
/**
|
||||
* The DS_DOMAIN_TRUSTS structure is used with the DsEnumerateDomainTrusts function to
|
||||
* contain trust data for a domain.
|
||||
*/
|
||||
public static class DS_DOMAIN_TRUSTS extends Structure {
|
||||
|
||||
public static class ByReference extends DS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the NetBIOS name of the domain.
|
||||
*/
|
||||
public WString NetbiosDomainName;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the DNS name of the domain. This member may be NULL.
|
||||
*/
|
||||
public WString DnsDomainName;
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
/**
|
||||
* Contains the index in the Domains array returned by the DsEnumerateDomainTrusts function that
|
||||
* corresponds to the parent domain of the domain represented by this structure.
|
||||
*/
|
||||
public NativeLong ParentIndex;
|
||||
/**
|
||||
* Contains a value that indicates the type of trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustType;
|
||||
/**
|
||||
* Contains a value that indicates the attributes of the trust represented by this structure.
|
||||
*/
|
||||
public NativeLong TrustAttributes;
|
||||
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID.ByReference DomainSid;
|
||||
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
};
|
||||
|
||||
/**
|
||||
* A pointer to an array of DS_DOMAIN_TRUSTS.
|
||||
*/
|
||||
public static class PDS_DOMAIN_TRUSTS extends Structure {
|
||||
public static class ByReference extends PDS_DOMAIN_TRUSTS implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public DS_DOMAIN_TRUSTS.ByReference t;
|
||||
|
||||
/**
|
||||
* Returns domain trusts.
|
||||
* @param count
|
||||
* Number of domain trusts.
|
||||
* @return
|
||||
*/
|
||||
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
|
||||
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -10,21 +10,21 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.win32;
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.examples.win32.User32.POINT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>gdi32.dll</code>. */
|
||||
public interface GDI32 extends W32API {
|
||||
|
||||
GDI32 INSTANCE = (GDI32)
|
||||
Native.loadLibrary("gdi32", GDI32.class, DEFAULT_OPTIONS);
|
||||
Native.loadLibrary("gdi32", GDI32.class, W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
class RECT extends Structure {
|
||||
public int left;
|
||||
@@ -79,7 +79,7 @@ public interface GDI32 extends W32API {
|
||||
int nHeightEllipse);
|
||||
int ALTERNATE = 1;
|
||||
int WINDING = 2;
|
||||
HRGN CreatePolyPolygonRgn(POINT[] lppt, int[] lpPolyCounts, int nCount, int fnPolyFillMode);
|
||||
HRGN CreatePolyPolygonRgn(User32.POINT[] lppt, int[] lpPolyCounts, int nCount, int fnPolyFillMode);
|
||||
|
||||
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* 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.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
|
||||
/**
|
||||
* Ported from Guid.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Guid {
|
||||
|
||||
public static class GUID extends Structure {
|
||||
|
||||
public static class ByReference extends GUID implements Structure.ByReference {
|
||||
public ByReference() {
|
||||
|
||||
}
|
||||
|
||||
public ByReference(Pointer memory) {
|
||||
super(memory);
|
||||
}
|
||||
}
|
||||
|
||||
public GUID() {
|
||||
|
||||
}
|
||||
|
||||
public GUID(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public int Data1;
|
||||
public short Data2;
|
||||
public short Data3;
|
||||
public byte[] Data4 = new byte[8];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,514 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>kernel32.dll</code>. */
|
||||
public interface Kernel32 extends W32API {
|
||||
|
||||
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Frees the specified local memory object and invalidates its handle.
|
||||
* @param hLocal
|
||||
* A handle to the local memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL.
|
||||
* If the function fails, the return value is equal to a handle to the local memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalFree(Pointer hLocal);
|
||||
|
||||
/**
|
||||
* Frees the specified global memory object and invalidates its handle.
|
||||
* @param hGlobal
|
||||
* A handle to the global memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL
|
||||
* If the function fails, the return value is equal to a handle to the global memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer GlobalFree(Pointer hGlobal);
|
||||
|
||||
/**
|
||||
* The GetModuleHandle function retrieves a module handle for the specified module
|
||||
* if the file has been mapped into the address space of the calling process.
|
||||
* @param name
|
||||
* Pointer to a null-terminated string that contains the name of the module
|
||||
* (either a .dll or .exe file).
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the specified module.
|
||||
* If the function fails, the return value is NULL. To get extended error
|
||||
* information, call GetLastError.
|
||||
*/
|
||||
HMODULE GetModuleHandle(String name);
|
||||
|
||||
/**
|
||||
* The GetSystemTime function retrieves the current system date and time.
|
||||
* The system time is expressed in Coordinated Universal Time (UTC).
|
||||
* @param lpSystemTime
|
||||
* Pointer to a SYSTEMTIME structure to receive the current system date and time.
|
||||
*/
|
||||
void GetSystemTime(WinBase.SYSTEMTIME lpSystemTime);
|
||||
|
||||
/**
|
||||
* The GetCurrentThreadId function retrieves the thread identifier of the calling thread.
|
||||
* @return The return value is the thread identifier of the calling thread.
|
||||
*/
|
||||
int GetCurrentThreadId();
|
||||
|
||||
/**
|
||||
* The GetCurrentThread function retrieves a pseudo handle for the current thread.
|
||||
* @return The return value is a pseudo handle for the current thread.
|
||||
*/
|
||||
HANDLE GetCurrentThread();
|
||||
|
||||
/**
|
||||
* This function returns the process identifier of the calling process.
|
||||
* @return The return value is the process identifier of the calling process.
|
||||
*/
|
||||
int GetCurrentProcessId();
|
||||
|
||||
/**
|
||||
* This function returns a pseudohandle for the current process.
|
||||
* @return The return value is a pseudohandle to the current process.
|
||||
*/
|
||||
HANDLE GetCurrentProcess();
|
||||
|
||||
/**
|
||||
* The GetProcessId function retrieves the process identifier of the
|
||||
* specified process.
|
||||
* @param process
|
||||
* Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the process identifier of the
|
||||
* specified process. If the function fails, the return value is zero. To get
|
||||
* extended error information, call GetLastError.
|
||||
*/
|
||||
int GetProcessId(HANDLE process);
|
||||
|
||||
/**
|
||||
* The GetProcessVersion function retrieves the major and minor version numbers of the system
|
||||
* on which the specified process expects to run.
|
||||
* @param processId
|
||||
* Process identifier of the process of interest. A value of zero specifies the
|
||||
* calling process.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the version of the system on
|
||||
* which the process expects to run. The high word of the return value contains
|
||||
* the major version number. The low word of the return value contains the minor
|
||||
* version number. If the function fails, the return value is zero. To get extended
|
||||
* error information, call GetLastError. The function fails if ProcessId is an
|
||||
* invalid value.
|
||||
*/
|
||||
int GetProcessVersion(int processId);
|
||||
|
||||
/**
|
||||
* The GetLastError function retrieves the calling thread's last-error code value.
|
||||
* The last-error code is maintained on a per-thread basis. Multiple threads do not
|
||||
* overwrite each other's last-error code.
|
||||
* @return
|
||||
* The return value is the calling thread's last-error code value.
|
||||
*/
|
||||
int GetLastError();
|
||||
|
||||
/**
|
||||
* The SetLastError function sets the last-error code for the calling thread.
|
||||
* @param dwErrCode
|
||||
* Last-error code for the thread.
|
||||
*/
|
||||
void SetLastError(int dwErrCode);
|
||||
|
||||
/**
|
||||
* The GetDriveType function determines whether a disk drive is a removable,
|
||||
* fixed, CD-ROM, RAM disk, or network drive.
|
||||
* @param rootPathName
|
||||
* Pointer to a null-terminated string that specifies the root directory of
|
||||
* the disk to return information about. A trailing backslash is required.
|
||||
* If this parameter is NULL, the function uses the root of the current directory.
|
||||
* @return
|
||||
* The return value specifies the type of drive.
|
||||
*/
|
||||
int GetDriveType(String rootPathName);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, PointerByReference lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, Buffer lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The CreateFile function creates or opens a file, file stream, directory, physical
|
||||
* disk, volume, console buffer, tape drive, communications resource, mailslot, or
|
||||
* named pipe. The function returns a handle that can be used to access an object.
|
||||
* @param lpFileName
|
||||
* A pointer to a null-terminated string that specifies the name of an object to create or open.
|
||||
* @param dwDesiredAccess
|
||||
* The access to the object, which can be read, write, or both.
|
||||
* @param dwShareMode
|
||||
* The sharing mode of an object, which can be read, write, both, or none.
|
||||
* @param lpSecurityAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not
|
||||
* the returned handle can be inherited by child processes. If lpSecurityAttributes
|
||||
* is NULL, the handle cannot be inherited.
|
||||
* @param dwCreationDisposition
|
||||
* An action to take on files that exist and do not exist.
|
||||
* @param dwFlagsAndAttributes
|
||||
* The file attributes and flags.
|
||||
* @param hTemplateFile
|
||||
* Handle to a template file with the GENERIC_READ access right. The template file
|
||||
* supplies file attributes and extended attributes for the file that is being
|
||||
* created. This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to a specified file.
|
||||
* If a specified file exists before the function call and dwCreationDisposition is
|
||||
* CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS,
|
||||
* even when the function succeeds. If a file does not exist before the call,
|
||||
* GetLastError returns 0 (zero). If the function fails, the return value is
|
||||
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode,
|
||||
WinNT.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition,
|
||||
int dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
|
||||
|
||||
/**
|
||||
* The CreateDirectory function creates a new directory. If the underlying file
|
||||
* system supports security on files and directories, the function applies a
|
||||
* specified security descriptor to the new directory.
|
||||
* @param lpPathName
|
||||
* Pointer to a null-terminated string that specifies the path of the directory
|
||||
* to be created.
|
||||
* @param lpSecurityAttributes
|
||||
* Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member
|
||||
* of the structure specifies a security descriptor for the new directory. If
|
||||
* lpSecurityAttributes is NULL, the directory gets a default security descriptor.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. If the function fails,
|
||||
* the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean CreateDirectory(String lpPathName,
|
||||
WinNT.SECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
|
||||
Pointer CompletionKey, int NumberOfConcurrentThreads);
|
||||
|
||||
boolean GetQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
IntByReference lpNumberOfBytes, ByReference lpCompletionKey,
|
||||
PointerByReference lpOverlapped, int dwMilliseconds);
|
||||
|
||||
boolean PostQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
int dwNumberOfBytesTransferred, Pointer dwCompletionKey,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Waits until the specified object is in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForSingleObjectEx function.
|
||||
* To wait for multiple objects, use the WaitForMultipleObjects.
|
||||
* @param hHandle
|
||||
* A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.
|
||||
* If this handle is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the object is signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForMultipleObjectsEx function.
|
||||
* @param nCount
|
||||
* The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS.
|
||||
* @param hHandle
|
||||
* An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types.
|
||||
* It may not contain multiple copies of the same handle.
|
||||
* If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param bWaitAll
|
||||
* If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled.
|
||||
* If FALSE, the function returns when the state of any one of the objects is set to signaled.
|
||||
* In the latter case, the return value indicates the object whose state caused the function to return.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForMultipleObjects(int nCount, HANDLE[] hHandle, boolean bWaitAll, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* The DuplicateHandle function duplicates an object handle.
|
||||
*
|
||||
* @param hSourceProcessHandle
|
||||
* Handle to the process with the handle to duplicate.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param hSourceHandle
|
||||
* Handle to duplicate. This is an open object handle that is valid in the
|
||||
* context of the source process.
|
||||
* @param hTargetProcessHandle
|
||||
* Handle to the process that is to receive the duplicated handle.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param lpTargetHandle
|
||||
* Pointer to a variable that receives the duplicate handle. This handle value is valid in
|
||||
* the context of the target process. If hSourceHandle is a pseudo handle returned by
|
||||
* GetCurrentProcess or GetCurrentThread, DuplicateHandle converts it to a real handle to
|
||||
* a process or thread, respectively.
|
||||
* @param dwDesiredAccess
|
||||
* Access requested for the new handle.
|
||||
* @param bInheritHandle
|
||||
* Indicates whether the handle is inheritable.
|
||||
* @param dwOptions
|
||||
* Optional actions.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle,
|
||||
HANDLE hTargetProcessHandle, HANDLEByReference lpTargetHandle,
|
||||
int dwDesiredAccess, boolean bInheritHandle, int dwOptions);
|
||||
|
||||
/**
|
||||
* The CloseHandle function closes an open object handle.
|
||||
*
|
||||
* @param hObject
|
||||
* Handle to an open object. This parameter can be a pseudo handle or INVALID_HANDLE_VALUE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean CloseHandle(HANDLE hObject);
|
||||
|
||||
// TODO: figure out how OVERLAPPED is used and apply an appropriate mapping
|
||||
interface OVERLAPPED_COMPLETION_ROUTINE extends StdCallCallback {
|
||||
void callback(int errorCode, int nBytesTransferred,
|
||||
WinBase.OVERLAPPED overlapped);
|
||||
}
|
||||
|
||||
/** NOTE: only exists in unicode form (W suffix). Define this method
|
||||
* explicitly with the W suffix to avoid inadvertent calls in ASCII mode.
|
||||
*/
|
||||
public boolean ReadDirectoryChangesW(HANDLE directory,
|
||||
WinNT.FILE_NOTIFY_INFORMATION info, int length, boolean watchSubtree,
|
||||
int notifyFilter, IntByReference bytesReturned, WinBase.OVERLAPPED overlapped,
|
||||
OVERLAPPED_COMPLETION_ROUTINE completionRoutine);
|
||||
|
||||
/** ASCII version. Use {@link Native#toString(byte[])} to obtain the short
|
||||
* path from the <code>byte</code> array.
|
||||
* Use only if <code>w32.ascii==true</code>.
|
||||
*/
|
||||
int GetShortPathName(String lpszLongPath, byte[] lpdzShortPath, int cchBuffer);
|
||||
|
||||
/** Unicode version (the default). Use {@link Native#toString(char[])} to
|
||||
* obtain the short path from the <code>char</code> array.
|
||||
*/
|
||||
int GetShortPathName(String lpszLongPath, char[] lpdzShortPath, int cchBuffer);
|
||||
|
||||
/**
|
||||
* The LocalAlloc function allocates the specified number of bytes from the heap.
|
||||
* Windows memory management does not provide a separate local heap and global heap.
|
||||
* @param type
|
||||
* Memory allocation attributes. The default is the LMEM_FIXED value.
|
||||
* @param cbInput
|
||||
* Number of bytes to allocate. If this parameter is zero and the uFlags parameter
|
||||
* specifies LMEM_MOVEABLE, the function returns a handle to a memory object that
|
||||
* is marked as discarded.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly allocated memory object.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalAlloc(int type, int cbInput);
|
||||
|
||||
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
|
||||
IntByReference lpNumberOfBytesWritten,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
HANDLE CreateEvent(WinNT.SECURITY_ATTRIBUTES lpEventAttributes,
|
||||
boolean bManualReset, boolean bInitialState,
|
||||
String lpName);
|
||||
|
||||
boolean SetEvent(HANDLE hEvent);
|
||||
|
||||
boolean PulseEvent(HANDLE hEvent);
|
||||
|
||||
HANDLE CreateFileMapping(HANDLE hFile, WinNT.SECURITY_ATTRIBUTES lpAttributes,
|
||||
int flProtect, int dwMaximumSizeHigh,
|
||||
int dwMaximumSizeLow, String lpName);
|
||||
|
||||
Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess,
|
||||
int dwFileOffsetHigh, int dwFileOffsetLow,
|
||||
int dwNumberOfBytesToMap);
|
||||
|
||||
boolean UnmapViewOfFile(Pointer lpBaseAddress);
|
||||
|
||||
/**
|
||||
* Retrieves only the NetBIOS name of the local computer.
|
||||
*
|
||||
* @param buffer
|
||||
* A pointer to a buffer that receives the computer name or the cluster virtual server
|
||||
* name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1
|
||||
* characters.
|
||||
* @param lpnSize
|
||||
* On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs
|
||||
* copied to the destination buffer, not including the terminating null character. If
|
||||
* the buffer is too small, the function fails and GetLastError returns
|
||||
* ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required,
|
||||
* including the terminating null character.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean GetComputerName(char[] buffer, IntByReference lpnSize);
|
||||
|
||||
/**
|
||||
* The OpenThread function opens an existing thread object.
|
||||
* @param dwDesiredAccess
|
||||
* Access to the thread object. This access right is checked against any security
|
||||
* descriptor for the thread.
|
||||
* @param bInheritHandle
|
||||
* If this parameter is TRUE, the new process inherits the handle. If the parameter
|
||||
* is FALSE, the handle is not inherited.
|
||||
* @param dwThreadId
|
||||
* Identifier of the thread to be opened.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to the specified process.
|
||||
* If the function fails, the return value is NULL. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
HANDLE OpenThread(int dwDesiredAccess, boolean bInheritHandle, int dwThreadId);
|
||||
|
||||
/**
|
||||
* This function returns a handle to an existing process object.
|
||||
* @param fdwAccess
|
||||
* Not supported; set to zero.
|
||||
* @param fInherit
|
||||
* Not supported; set to FALSE.
|
||||
* @param IDProcess
|
||||
* Specifies the process identifier of the process to open.
|
||||
* @return
|
||||
* An open handle to the specified process indicates success.
|
||||
* NULL indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE OpenProcess(int fdwAccess, boolean fInherit, int IDProcess);
|
||||
|
||||
/**
|
||||
* The GetTempPath function retrieves the path of the directory designated
|
||||
* for temporary files.
|
||||
* @param nBufferLength
|
||||
* Size of the string buffer identified by lpBuffer, in TCHARs.
|
||||
* @param buffer
|
||||
* Pointer to a string buffer that receives the null-terminated string specifying the
|
||||
* temporary file path. The returned string ends with a backslash, for example,
|
||||
* C:\TEMP\.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string
|
||||
* copied to lpBuffer, not including the terminating null character. If the return value
|
||||
* is greater than nBufferLength, the return value is the length, in TCHARs, of the
|
||||
* buffer required to hold the path.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
DWORD GetTempPath(DWORD nBufferLength, char[] buffer);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/* 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.LastErrorException;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.W32API.DWORD;
|
||||
import com.sun.jna.platform.win32.W32API.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Kernel32 utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Kernel32Util {
|
||||
|
||||
/**
|
||||
* Get current computer NetBIOS name.
|
||||
* @return
|
||||
* Netbios name.
|
||||
*/
|
||||
public static String getComputerName() {
|
||||
char buffer[] = new char[WinBase.MAX_COMPUTERNAME_LENGTH() + 1];
|
||||
IntByReference lpnSize = new IntByReference(buffer.length);
|
||||
if (! Kernel32.INSTANCE.GetComputerName(buffer, lpnSize)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a message from an HRESULT.
|
||||
* @param code
|
||||
* HRESULT
|
||||
* @return
|
||||
* Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromHR(HRESULT code) {
|
||||
PointerByReference buffer = new PointerByReference();
|
||||
if (0 == Kernel32.INSTANCE.FormatMessage(
|
||||
WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| WinBase.FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
null,
|
||||
code.intValue(),
|
||||
0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
|
||||
buffer,
|
||||
0,
|
||||
null)) {
|
||||
throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
|
||||
s = s.replace(".\r",".").replace(".\n",".");
|
||||
Kernel32.INSTANCE.LocalFree(buffer.getValue());
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a system message from an error code.
|
||||
* @param code
|
||||
* Error code, typically a result of GetLastError.
|
||||
* @return
|
||||
* Formatted message.
|
||||
*/
|
||||
public static String formatMessageFromLastErrorCode(int code) {
|
||||
return formatMessageFromHR(W32Errors.HRESULT_FROM_WIN32(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path designated for temporary files.
|
||||
* @return
|
||||
* Path.
|
||||
*/
|
||||
public static String getTempPath() {
|
||||
DWORD nBufferLength = new DWORD(WinDef.MAX_PATH);
|
||||
char[] buffer = new char[nBufferLength.intValue()];
|
||||
if (Kernel32.INSTANCE.GetTempPath(nBufferLength, buffer).intValue() == 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
/* 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.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
|
||||
/**
|
||||
* Ported from LMAccess.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMAccess {
|
||||
|
||||
public static class LOCALGROUP_INFO_0 extends Structure {
|
||||
public LOCALGROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public WString lgrui0_name;
|
||||
}
|
||||
|
||||
public static class LOCALGROUP_INFO_1 extends Structure {
|
||||
public LOCALGROUP_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
public WString lgrui1_name;
|
||||
public WString lgrui1_comment;
|
||||
}
|
||||
|
||||
//
|
||||
// bit masks for the NetUserEnum filter parameter.
|
||||
//
|
||||
|
||||
public static final int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001;
|
||||
public static final int FILTER_NORMAL_ACCOUNT = 0x0002;
|
||||
// public static final int FILTER_PROXY_ACCOUNT = 0x0004;
|
||||
public static final int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008;
|
||||
public static final int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010;
|
||||
public static final int FILTER_SERVER_TRUST_ACCOUNT = 0x0020;
|
||||
|
||||
/**
|
||||
* The USER_INFO_0 structure contains a user account name.
|
||||
*/
|
||||
public static class USER_INFO_0 extends Structure {
|
||||
public USER_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the name of the user account.
|
||||
*/
|
||||
public WString usri0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The USER_INFO_1 structure contains information about a user account, including
|
||||
* account name, password data, privilege level, and the path to the user's home
|
||||
* directory.
|
||||
*/
|
||||
public static class USER_INFO_1 extends Structure {
|
||||
public USER_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public USER_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the name of the user
|
||||
* account.
|
||||
*/
|
||||
public WString usri1_name;
|
||||
/**
|
||||
* Pointer to a Unicode string that specifies the password of the user
|
||||
* indicated by the usri1_name member.
|
||||
*/
|
||||
public WString usri1_password;
|
||||
/**
|
||||
* Specifies a DWORD value that indicates the number of seconds that have
|
||||
* elapsed since the usri1_password member was last changed.
|
||||
*/
|
||||
public int usri1_password_age;
|
||||
/**
|
||||
* Specifies a DWORD value that indicates the level of privilege assigned
|
||||
* to the usri1_name member.
|
||||
*/
|
||||
public int usri1_priv;
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the path of the home directory
|
||||
* for the user specified in the usri1_name member.
|
||||
*/
|
||||
public WString usri1_home_dir;
|
||||
/**
|
||||
* Pointer to a Unicode string that contains a comment to associate with
|
||||
* the user account.
|
||||
*/
|
||||
public WString usri1_comment;
|
||||
/**
|
||||
* Specifies a DWORD value that determines several features.
|
||||
*/
|
||||
public int usri1_flags;
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the path for the user's
|
||||
* logon script file.
|
||||
*/
|
||||
public WString usri1_script_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_USERS_INFO_0 structure contains global group member information.
|
||||
*/
|
||||
public static class GROUP_USERS_INFO_0 extends Structure {
|
||||
public GROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies a name.
|
||||
*/
|
||||
public WString grui0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The LOCALGROUP_USERS_INFO_0 structure contains local group member information.
|
||||
*/
|
||||
public static class LOCALGROUP_USERS_INFO_0 extends Structure {
|
||||
public LOCALGROUP_USERS_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public LOCALGROUP_USERS_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a Unicode string specifying the name of a local group to which the user belongs.
|
||||
*/
|
||||
public WString lgrui0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_0 structure contains the name of a global group in the security
|
||||
* database, which is the security accounts manager (SAM) database or, in the case
|
||||
* of domain controllers, the Active Directory.
|
||||
*/
|
||||
public static class GROUP_INFO_0 extends Structure {
|
||||
public GROUP_INFO_0() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_0(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi0_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_1 structure contains a global group name and a comment to
|
||||
* associate with the group.
|
||||
*/
|
||||
public static class GROUP_INFO_1 extends Structure {
|
||||
public GROUP_INFO_1() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_1(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* the name of the global group.
|
||||
*/
|
||||
public WString grpi1_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that specifies
|
||||
* a remark associated with the global group. This member can be a null
|
||||
* string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi1_comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_2 structure contains information about a global group, including
|
||||
* name, identifier, and resource attributes.
|
||||
*/
|
||||
public static class GROUP_INFO_2 extends Structure {
|
||||
public GROUP_INFO_2() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_2(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* specifies the name of the global group.
|
||||
*/
|
||||
public WString grpi2_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that contains a
|
||||
* remark associated with the global group. This member can be a null string.
|
||||
* The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi2_comment;
|
||||
/**
|
||||
* Specifies a DWORD value that contains the relative identifier (RID) of
|
||||
* the global group.
|
||||
*/
|
||||
public int grpi2_group_id;
|
||||
/**
|
||||
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED,
|
||||
* and SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi2_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The GROUP_INFO_3 structure contains information about a global group, including
|
||||
* name, security identifier (SID), and resource attributes.
|
||||
*/
|
||||
public static class GROUP_INFO_3 extends Structure {
|
||||
public GROUP_INFO_3() {
|
||||
super();
|
||||
}
|
||||
|
||||
public GROUP_INFO_3(Pointer memory) {
|
||||
useMemory(memory);
|
||||
read();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* specifies the name of the global group.
|
||||
*/
|
||||
public WString grpi3_name;
|
||||
/**
|
||||
* Pointer to a null-terminated Unicode character string that
|
||||
* contains a remark associated with the global group. This member can be
|
||||
* a null string. The comment can contain MAXCOMMENTSZ characters.
|
||||
*/
|
||||
public WString grpi3_comment;
|
||||
/**
|
||||
* Pointer to a SID structure that contains the security identifier (SID) that
|
||||
* uniquely identifies the global group.
|
||||
*/
|
||||
public PSID grpi3_group_sid;
|
||||
/**
|
||||
* These attributes are hard-coded to SE_GROUP_MANDATORY, SE_GROUP_ENABLED, and
|
||||
* SE_GROUP_ENABLED_BY_DEFAULT.
|
||||
*/
|
||||
public int grpi3_attributes;
|
||||
}
|
||||
|
||||
//
|
||||
// Privilege levels (USER_INFO_X field usriX_priv (X = 0/1)).
|
||||
//
|
||||
|
||||
public static final int USER_PRIV_MASK = 3;
|
||||
public static final int USER_PRIV_GUEST = 0;
|
||||
public static final int USER_PRIV_USER = 1;
|
||||
public static final int USER_PRIV_ADMIN = 2;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* 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;
|
||||
|
||||
/**
|
||||
* Ported from LMCons.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMCons {
|
||||
public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
|
||||
|
||||
/**
|
||||
* Value to be used with APIs which have a "preferred maximum length" parameter.
|
||||
* This value indicates that the API should just allocate "as much as it takes."
|
||||
*/
|
||||
public static final int MAX_PREFERRED_LENGTH = -1;
|
||||
}
|
||||
@@ -0,0 +1,564 @@
|
||||
/* 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;
|
||||
|
||||
/**
|
||||
* Ported from LMErr.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMErr {
|
||||
public static final int NERR_Success = 0;
|
||||
public static final int NERR_BASE = 2100;
|
||||
|
||||
public static final int NERR_NetNotStarted = NERR_BASE + 2; /* The workstation driver is not installed. */
|
||||
public static final int NERR_UnknownServer = NERR_BASE + 3; /* The server could not be located. */
|
||||
public static final int NERR_ShareMem = NERR_BASE + 4; /* An internal error occurred. The network cannot access a shared memory segment. */
|
||||
|
||||
public static final int NERR_NoNetworkResource = NERR_BASE + 5; /* A network resource shortage occurred . */
|
||||
public static final int NERR_RemoteOnly = NERR_BASE + 6; /* This operation is not supported on workstations. */
|
||||
public static final int NERR_DevNotRedirected = NERR_BASE + 7; /* The device is not connected. */
|
||||
/* NERR_BASE + 8 is used for ERROR_CONNECTED_OTHER_PASSWORD */
|
||||
/* NERR_BASE + 9 is used for ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT */
|
||||
/* UNUSED BASE + 10 */
|
||||
/* UNUSED BASE + 11 */
|
||||
/* UNUSED BASE + 12 */
|
||||
/* UNUSED BASE + 13 */
|
||||
public static final int NERR_ServerNotStarted = NERR_BASE + 14; /* The Server service is not started. */
|
||||
public static final int NERR_ItemNotFound = NERR_BASE + 15; /* The queue is empty. */
|
||||
public static final int NERR_UnknownDevDir = NERR_BASE + 16; /* The device or directory does not exist. */
|
||||
public static final int NERR_RedirectedPath = NERR_BASE + 17; /* The operation is invalid on a redirected resource. */
|
||||
public static final int NERR_DuplicateShare = NERR_BASE + 18; /* The name has already been shared. */
|
||||
public static final int NERR_NoRoom = NERR_BASE + 19; /* The server is currently out of the requested resource. */
|
||||
/* UNUSED BASE + 20 */
|
||||
public static final int NERR_TooManyItems = NERR_BASE + 21; /* Requested addition of items exceeds the maximum allowed. */
|
||||
public static final int NERR_InvalidMaxUsers = NERR_BASE + 22; /* The Peer service supports only two simultaneous users. */
|
||||
public static final int NERR_BufTooSmall = NERR_BASE + 23; /* The API return buffer is too small. */
|
||||
/* UNUSED BASE + 24 */
|
||||
/* UNUSED BASE + 25 */
|
||||
/* UNUSED BASE + 26 */
|
||||
public static final int NERR_RemoteErr = NERR_BASE + 27; /* A remote API error occurred. */
|
||||
/* UNUSED BASE + 28 */
|
||||
/* UNUSED BASE + 29 */
|
||||
/* UNUSED BASE + 30 */
|
||||
public static final int NERR_LanmanIniError = NERR_BASE + 31; /* An error occurred when opening or reading the configuration file. */
|
||||
/* UNUSED BASE + 32 */
|
||||
/* UNUSED BASE + 33 */
|
||||
/* UNUSED BASE + 34 */
|
||||
/* UNUSED BASE + 35 */
|
||||
public static final int NERR_NetworkError = NERR_BASE + 36; /* A general network error occurred. */
|
||||
public static final int NERR_WkstaInconsistentState = NERR_BASE + 37;
|
||||
/* The Workstation service is in an inconsistent state. Restart the computer before restarting the Workstation service. */
|
||||
public static final int NERR_WkstaNotStarted = NERR_BASE + 38; /* The Workstation service has not been started. */
|
||||
public static final int NERR_BrowserNotStarted = NERR_BASE + 39; /* The requested information is not available. */
|
||||
public static final int NERR_InternalError = NERR_BASE + 40; /* An internal Windows error occurred.*/
|
||||
public static final int NERR_BadTransactConfig = NERR_BASE + 41; /* The server is not configured for transactions. */
|
||||
public static final int NERR_InvalidAPI = NERR_BASE + 42; /* The requested API is not supported on the remote server. */
|
||||
public static final int NERR_BadEventName = NERR_BASE + 43; /* The event name is invalid. */
|
||||
public static final int NERR_DupNameReboot = NERR_BASE + 44; /* The computer name already exists on the network. Change it and restart the computer. */
|
||||
/*
|
||||
* Config API related
|
||||
* Error codes from BASE + 45 to BASE + 49
|
||||
*/
|
||||
|
||||
/* UNUSED BASE + 45 */
|
||||
public static final int NERR_CfgCompNotFound = NERR_BASE + 46; /* The specified component could not be found in the configuration information. */
|
||||
public static final int NERR_CfgParamNotFound = NERR_BASE + 47; /* The specified parameter could not be found in the configuration information. */
|
||||
public static final int NERR_LineTooLong = NERR_BASE + 49; /* A line in the configuration file is too long. */
|
||||
|
||||
/*
|
||||
* Spooler API related
|
||||
* Error codes from BASE + 50 to BASE + 79
|
||||
*/
|
||||
|
||||
public static final int NERR_QNotFound = NERR_BASE + 50; /* The printer does not exist. */
|
||||
public static final int NERR_JobNotFound = NERR_BASE + 51; /* The print job does not exist. */
|
||||
public static final int NERR_DestNotFound = NERR_BASE + 52; /* The printer destination cannot be found. */
|
||||
public static final int NERR_DestExists = NERR_BASE + 53; /* The printer destination already exists. */
|
||||
public static final int NERR_QExists = NERR_BASE + 54; /* The printer queue already exists. */
|
||||
public static final int NERR_QNoRoom = NERR_BASE + 55; /* No more printers can be added. */
|
||||
public static final int NERR_JobNoRoom = NERR_BASE + 56; /* No more print jobs can be added. */
|
||||
public static final int NERR_DestNoRoom = NERR_BASE + 57; /* No more printer destinations can be added. */
|
||||
public static final int NERR_DestIdle = NERR_BASE + 58; /* This printer destination is idle and cannot accept control operations. */
|
||||
public static final int NERR_DestInvalidOp = NERR_BASE + 59; /* This printer destination request contains an invalid control function. */
|
||||
public static final int NERR_ProcNoRespond = NERR_BASE + 60; /* The print processor is not responding. */
|
||||
public static final int NERR_SpoolerNotLoaded = NERR_BASE + 61; /* The spooler is not running. */
|
||||
public static final int NERR_DestInvalidState = NERR_BASE + 62; /* This operation cannot be performed on the print destination in its current state. */
|
||||
public static final int NERR_QInvalidState = NERR_BASE + 63; /* This operation cannot be performed on the printer queue in its current state. */
|
||||
public static final int NERR_JobInvalidState = NERR_BASE + 64; /* This operation cannot be performed on the print job in its current state. */
|
||||
public static final int NERR_SpoolNoMemory = NERR_BASE + 65; /* A spooler memory allocation failure occurred. */
|
||||
public static final int NERR_DriverNotFound = NERR_BASE + 66; /* The device driver does not exist. */
|
||||
public static final int NERR_DataTypeInvalid = NERR_BASE + 67; /* The data type is not supported by the print processor. */
|
||||
public static final int NERR_ProcNotFound = NERR_BASE + 68; /* The print processor is not installed. */
|
||||
|
||||
/*
|
||||
* Service API related
|
||||
* Error codes from BASE + 80 to BASE + 99
|
||||
*/
|
||||
|
||||
public static final int NERR_ServiceTableLocked = NERR_BASE + 80; /* The service database is locked. */
|
||||
public static final int NERR_ServiceTableFull = NERR_BASE + 81; /* The service table is full. */
|
||||
public static final int NERR_ServiceInstalled = NERR_BASE + 82; /* The requested service has already been started. */
|
||||
public static final int NERR_ServiceEntryLocked = NERR_BASE + 83; /* The service does not respond to control actions. */
|
||||
public static final int NERR_ServiceNotInstalled = NERR_BASE + 84; /* The service has not been started. */
|
||||
public static final int NERR_BadServiceName = NERR_BASE + 85; /* The service name is invalid. */
|
||||
public static final int NERR_ServiceCtlTimeout = NERR_BASE + 86; /* The service is not responding to the control function. */
|
||||
public static final int NERR_ServiceCtlBusy = NERR_BASE + 87; /* The service control is busy. */
|
||||
public static final int NERR_BadServiceProgName = NERR_BASE + 88; /* The configuration file contains an invalid service program name. */
|
||||
public static final int NERR_ServiceNotCtrl = NERR_BASE + 89; /* The service could not be controlled in its present state. */
|
||||
public static final int NERR_ServiceKillProc = NERR_BASE + 90; /* The service ended abnormally. */
|
||||
public static final int NERR_ServiceCtlNotValid = NERR_BASE + 91; /* The requested pause, continue, or stop is not valid for this service. */
|
||||
public static final int NERR_NotInDispatchTbl = NERR_BASE + 92; /* The service control dispatcher could not find the service name in the dispatch table. */
|
||||
public static final int NERR_BadControlRecv = NERR_BASE + 93; /* The service control dispatcher pipe read failed. */
|
||||
public static final int NERR_ServiceNotStarting = NERR_BASE + 94; /* A thread for the new service could not be created. */
|
||||
|
||||
/*
|
||||
* Wksta and Logon API related
|
||||
* Error codes from BASE + 100 to BASE + 118
|
||||
*/
|
||||
|
||||
public static final int NERR_AlreadyLoggedOn = NERR_BASE + 100; /* This workstation is already logged on to the local-area network. */
|
||||
public static final int NERR_NotLoggedOn = NERR_BASE + 101; /* The workstation is not logged on to the local-area network. */
|
||||
public static final int NERR_BadUsername = NERR_BASE + 102; /* The user name or group name parameter is invalid. */
|
||||
public static final int NERR_BadPassword = NERR_BASE + 103; /* The password parameter is invalid. */
|
||||
public static final int NERR_UnableToAddName_W = NERR_BASE + 104; /* @W The logon processor did not add the message alias. */
|
||||
public static final int NERR_UnableToAddName_F = NERR_BASE + 105; /* The logon processor did not add the message alias. */
|
||||
public static final int NERR_UnableToDelName_W = NERR_BASE + 106; /* @W The logoff processor did not delete the message alias. */
|
||||
public static final int NERR_UnableToDelName_F = NERR_BASE + 107; /* The logoff processor did not delete the message alias. */
|
||||
/* UNUSED BASE + 108 */
|
||||
public static final int NERR_LogonsPaused = NERR_BASE + 109; /* Network logons are paused. */
|
||||
public static final int NERR_LogonServerConflict = NERR_BASE + 110;/* A centralized logon-server conflict occurred. */
|
||||
public static final int NERR_LogonNoUserPath = NERR_BASE + 111; /* The server is configured without a valid user path. */
|
||||
public static final int NERR_LogonScriptError = NERR_BASE + 112; /* An error occurred while loading or running the logon script. */
|
||||
/* UNUSED BASE + 113 */
|
||||
public static final int NERR_StandaloneLogon = NERR_BASE + 114; /* The logon server was not specified. Your computer will be logged on as STANDALONE. */
|
||||
public static final int NERR_LogonServerNotFound = NERR_BASE + 115; /* The logon server could not be found. */
|
||||
public static final int NERR_LogonDomainExists = NERR_BASE + 116; /* There is already a logon domain for this computer. */
|
||||
public static final int NERR_NonValidatedLogon = NERR_BASE + 117; /* The logon server could not validate the logon. */
|
||||
|
||||
/*
|
||||
* ACF API related = access, user, group;
|
||||
* Error codes from BASE + 119 to BASE + 149
|
||||
*/
|
||||
|
||||
public static final int NERR_ACFNotFound = NERR_BASE + 119; /* The security database could not be found. */
|
||||
public static final int NERR_GroupNotFound = NERR_BASE + 120; /* The group name could not be found. */
|
||||
public static final int NERR_UserNotFound = NERR_BASE + 121; /* The user name could not be found. */
|
||||
public static final int NERR_ResourceNotFound = NERR_BASE + 122; /* The resource name could not be found. */
|
||||
public static final int NERR_GroupExists = NERR_BASE + 123; /* The group already exists. */
|
||||
public static final int NERR_UserExists = NERR_BASE + 124; /* The account already exists. */
|
||||
public static final int NERR_ResourceExists = NERR_BASE + 125; /* The resource permission list already exists. */
|
||||
public static final int NERR_NotPrimary = NERR_BASE + 126; /* This operation is only allowed on the primary domain controller of the domain. */
|
||||
public static final int NERR_ACFNotLoaded = NERR_BASE + 127; /* The security database has not been started. */
|
||||
public static final int NERR_ACFNoRoom = NERR_BASE + 128; /* There are too many names in the user accounts database. */
|
||||
public static final int NERR_ACFFileIOFail = NERR_BASE + 129; /* A disk I/O failure occurred.*/
|
||||
public static final int NERR_ACFTooManyLists = NERR_BASE + 130; /* The limit of 64 entries per resource was exceeded. */
|
||||
public static final int NERR_UserLogon = NERR_BASE + 131; /* Deleting a user with a session is not allowed. */
|
||||
public static final int NERR_ACFNoParent = NERR_BASE + 132; /* The parent directory could not be located. */
|
||||
public static final int NERR_CanNotGrowSegment = NERR_BASE + 133; /* Unable to add to the security database session cache segment. */
|
||||
public static final int NERR_SpeGroupOp = NERR_BASE + 134; /* This operation is not allowed on this special group. */
|
||||
public static final int NERR_NotInCache = NERR_BASE + 135; /* This user is not cached in user accounts database session cache. */
|
||||
public static final int NERR_UserInGroup = NERR_BASE + 136; /* The user already belongs to this group. */
|
||||
public static final int NERR_UserNotInGroup = NERR_BASE + 137; /* The user does not belong to this group. */
|
||||
public static final int NERR_AccountUndefined = NERR_BASE + 138; /* This user account is undefined. */
|
||||
public static final int NERR_AccountExpired = NERR_BASE + 139; /* This user account has expired. */
|
||||
public static final int NERR_InvalidWorkstation = NERR_BASE + 140; /* The user is not allowed to log on from this workstation. */
|
||||
public static final int NERR_InvalidLogonHours = NERR_BASE + 141; /* The user is not allowed to log on at this time. */
|
||||
public static final int NERR_PasswordExpired = NERR_BASE + 142; /* The password of this user has expired. */
|
||||
public static final int NERR_PasswordCantChange = NERR_BASE + 143; /* The password of this user cannot change. */
|
||||
public static final int NERR_PasswordHistConflict = NERR_BASE + 144; /* This password cannot be used now. */
|
||||
public static final int NERR_PasswordTooShort = NERR_BASE + 145; /* The password does not meet the password policy requirements. Check the minimum password length, password complexity and password history requirements. */
|
||||
public static final int NERR_PasswordTooRecent = NERR_BASE + 146; /* The password of this user is too recent to change. */
|
||||
public static final int NERR_InvalidDatabase = NERR_BASE + 147; /* The security database is corrupted. */
|
||||
public static final int NERR_DatabaseUpToDate = NERR_BASE + 148; /* No updates are necessary to this replicant network/local security database. */
|
||||
public static final int NERR_SyncRequired = NERR_BASE + 149; /* This replicant database is outdated; synchronization is required. */
|
||||
|
||||
/*
|
||||
* Use API related
|
||||
* Error codes from BASE + 150 to BASE + 169
|
||||
*/
|
||||
|
||||
public static final int NERR_UseNotFound = NERR_BASE + 150; /* The network connection could not be found. */
|
||||
public static final int NERR_BadAsgType = NERR_BASE + 151; /* This asg_type is invalid. */
|
||||
public static final int NERR_DeviceIsShared = NERR_BASE + 152; /* This device is currently being shared. */
|
||||
public static final int NERR_SameAsComputerName = NERR_BASE + 153; /* The user name may not be same as computer name. */
|
||||
|
||||
|
||||
/*
|
||||
* Message Server related
|
||||
* Error codes BASE + 170 to BASE + 209
|
||||
*/
|
||||
|
||||
public static final int NERR_NoComputerName = NERR_BASE + 170; /* The computer name could not be added as a message alias. The name may already exist on the network. */
|
||||
public static final int NERR_MsgAlreadyStarted = NERR_BASE + 171; /* The Messenger service is already started. */
|
||||
public static final int NERR_MsgInitFailed = NERR_BASE + 172; /* The Messenger service failed to start. */
|
||||
public static final int NERR_NameNotFound = NERR_BASE + 173; /* The message alias could not be found on the network. */
|
||||
public static final int NERR_AlreadyForwarded = NERR_BASE + 174; /* This message alias has already been forwarded. */
|
||||
public static final int NERR_AddForwarded = NERR_BASE + 175; /* This message alias has been added but is still forwarded. */
|
||||
public static final int NERR_AlreadyExists = NERR_BASE + 176; /* This message alias already exists locally. */
|
||||
public static final int NERR_TooManyNames = NERR_BASE + 177; /* The maximum number of added message aliases has been exceeded. */
|
||||
public static final int NERR_DelComputerName = NERR_BASE + 178; /* The computer name could not be deleted.*/
|
||||
public static final int NERR_LocalForward = NERR_BASE + 179; /* Messages cannot be forwarded back to the same workstation. */
|
||||
public static final int NERR_GrpMsgProcessor = NERR_BASE + 180; /* An error occurred in the domain message processor. */
|
||||
public static final int NERR_PausedRemote = NERR_BASE + 181; /* The message was sent, but the recipient has paused the Messenger service. */
|
||||
public static final int NERR_BadReceive = NERR_BASE + 182; /* The message was sent but not received. */
|
||||
public static final int NERR_NameInUse = NERR_BASE + 183; /* The message alias is currently in use. Try again later. */
|
||||
public static final int NERR_MsgNotStarted = NERR_BASE + 184; /* The Messenger service has not been started. */
|
||||
public static final int NERR_NotLocalName = NERR_BASE + 185; /* The name is not on the local computer. */
|
||||
public static final int NERR_NoForwardName = NERR_BASE + 186; /* The forwarded message alias could not be found on the network. */
|
||||
public static final int NERR_RemoteFull = NERR_BASE + 187; /* The message alias table on the remote station is full. */
|
||||
public static final int NERR_NameNotForwarded = NERR_BASE + 188; /* Messages for this alias are not currently being forwarded. */
|
||||
public static final int NERR_TruncatedBroadcast = NERR_BASE + 189; /* The broadcast message was truncated. */
|
||||
public static final int NERR_InvalidDevice = NERR_BASE + 194; /* This is an invalid device name. */
|
||||
public static final int NERR_WriteFault = NERR_BASE + 195; /* A write fault occurred. */
|
||||
/* UNUSED BASE + 196 */
|
||||
public static final int NERR_DuplicateName = NERR_BASE + 197; /* A duplicate message alias exists on the network. */
|
||||
public static final int NERR_DeleteLater = NERR_BASE + 198; /* @W This message alias will be deleted later. */
|
||||
public static final int NERR_IncompleteDel = NERR_BASE + 199; /* The message alias was not successfully deleted from all networks. */
|
||||
public static final int NERR_MultipleNets = NERR_BASE + 200; /* This operation is not supported on computers with multiple networks. */
|
||||
|
||||
/*
|
||||
* Server API related
|
||||
* Error codes BASE + 210 to BASE + 229
|
||||
*/
|
||||
|
||||
public static final int NERR_NetNameNotFound = NERR_BASE + 210; /* This shared resource does not exist.*/
|
||||
public static final int NERR_DeviceNotShared = NERR_BASE + 211; /* This device is not shared. */
|
||||
public static final int NERR_ClientNameNotFound = NERR_BASE + 212; /* A session does not exist with that computer name. */
|
||||
public static final int NERR_FileIdNotFound = NERR_BASE + 214; /* There is not an open file with that identification number. */
|
||||
public static final int NERR_ExecFailure = NERR_BASE + 215; /* A failure occurred when executing a remote administration command. */
|
||||
public static final int NERR_TmpFile = NERR_BASE + 216; /* A failure occurred when opening a remote temporary file. */
|
||||
public static final int NERR_TooMuchData = NERR_BASE + 217; /* The data returned from a remote administration command has been truncated to 64K. */
|
||||
public static final int NERR_DeviceShareConflict = NERR_BASE + 218; /* This device cannot be shared as both a spooled and a non-spooled resource. */
|
||||
public static final int NERR_BrowserTableIncomplete = NERR_BASE + 219; /* The information in the list of servers may be incorrect. */
|
||||
public static final int NERR_NotLocalDomain = NERR_BASE + 220; /* The computer is not active in this domain. */
|
||||
public static final int NERR_IsDfsShare = NERR_BASE + 221; /* The share must be removed from the Distributed File System before it can be deleted. */
|
||||
|
||||
/*
|
||||
* CharDev API related
|
||||
* Error codes BASE + 230 to BASE + 249
|
||||
*/
|
||||
|
||||
/* UNUSED BASE + 230 */
|
||||
public static final int NERR_DevInvalidOpCode = NERR_BASE + 231; /* The operation is invalid for this device. */
|
||||
public static final int NERR_DevNotFound = NERR_BASE + 232; /* This device cannot be shared. */
|
||||
public static final int NERR_DevNotOpen = NERR_BASE + 233; /* This device was not open. */
|
||||
public static final int NERR_BadQueueDevString = NERR_BASE + 234; /* This device name list is invalid. */
|
||||
public static final int NERR_BadQueuePriority = NERR_BASE + 235; /* The queue priority is invalid. */
|
||||
public static final int NERR_NoCommDevs = NERR_BASE + 237; /* There are no shared communication devices. */
|
||||
public static final int NERR_QueueNotFound = NERR_BASE + 238; /* The queue you specified does not exist. */
|
||||
public static final int NERR_BadDevString = NERR_BASE + 240; /* This list of devices is invalid. */
|
||||
public static final int NERR_BadDev = NERR_BASE + 241; /* The requested device is invalid. */
|
||||
public static final int NERR_InUseBySpooler = NERR_BASE + 242; /* This device is already in use by the spooler. */
|
||||
public static final int NERR_CommDevInUse = NERR_BASE + 243; /* This device is already in use as a communication device. */
|
||||
|
||||
/*
|
||||
* NetICanonicalize and NetIType and NetIMakeLMFileName
|
||||
* NetIListCanon and NetINameCheck
|
||||
* Error codes BASE + 250 to BASE + 269
|
||||
*/
|
||||
|
||||
public static final int NERR_InvalidComputer = NERR_BASE + 251; /* This computer name is invalid. */
|
||||
/* UNUSED BASE + 252 */
|
||||
/* UNUSED BASE + 253 */
|
||||
public static final int NERR_MaxLenExceeded = NERR_BASE + 254; /* The string and prefix specified are too long. */
|
||||
/* UNUSED BASE + 255 */
|
||||
public static final int NERR_BadComponent = NERR_BASE + 256; /* This path component is invalid. */
|
||||
public static final int NERR_CantType = NERR_BASE + 257; /* Could not determine the type of input. */
|
||||
/* UNUSED BASE + 258 */
|
||||
/* UNUSED BASE + 259 */
|
||||
public static final int NERR_TooManyEntries = NERR_BASE + 262; /* The buffer for types is not big enough. */
|
||||
|
||||
/*
|
||||
* NetProfile
|
||||
* Error codes BASE + 270 to BASE + 276
|
||||
*/
|
||||
|
||||
public static final int NERR_ProfileFileTooBig = NERR_BASE + 270; /* Profile files cannot exceed 64K. */
|
||||
public static final int NERR_ProfileOffset = NERR_BASE + 271; /* The start offset is out of range. */
|
||||
public static final int NERR_ProfileCleanup = NERR_BASE + 272; /* The system cannot delete current connections to network resources. */
|
||||
public static final int NERR_ProfileUnknownCmd = NERR_BASE + 273; /* The system was unable to parse the command line in this file.*/
|
||||
public static final int NERR_ProfileLoadErr = NERR_BASE + 274; /* An error occurred while loading the profile file. */
|
||||
public static final int NERR_ProfileSaveErr = NERR_BASE + 275; /* @W Errors occurred while saving the profile file. The profile was partially saved. */
|
||||
|
||||
|
||||
/*
|
||||
* NetAudit and NetErrorLog
|
||||
* Error codes BASE + 277 to BASE + 279
|
||||
*/
|
||||
|
||||
public static final int NERR_LogOverflow = NERR_BASE + 277; /* Log file %1 is full. */
|
||||
public static final int NERR_LogFileChanged = NERR_BASE + 278; /* This log file has changed between reads. */
|
||||
public static final int NERR_LogFileCorrupt = NERR_BASE + 279; /* Log file %1 is corrupt. */
|
||||
|
||||
|
||||
/*
|
||||
* NetRemote
|
||||
* Error codes BASE + 280 to BASE + 299
|
||||
*/
|
||||
public static final int NERR_SourceIsDir = NERR_BASE + 280; /* The source path cannot be a directory. */
|
||||
public static final int NERR_BadSource = NERR_BASE + 281; /* The source path is illegal. */
|
||||
public static final int NERR_BadDest = NERR_BASE + 282; /* The destination path is illegal. */
|
||||
public static final int NERR_DifferentServers = NERR_BASE + 283; /* The source and destination paths are on different servers. */
|
||||
/* UNUSED BASE + 284 */
|
||||
public static final int NERR_RunSrvPaused = NERR_BASE + 285; /* The Run server you requested is paused. */
|
||||
/* UNUSED BASE + 286 */
|
||||
/* UNUSED BASE + 287 */
|
||||
/* UNUSED BASE + 288 */
|
||||
public static final int NERR_ErrCommRunSrv = NERR_BASE + 289; /* An error occurred when communicating with a Run server. */
|
||||
/* UNUSED BASE + 290 */
|
||||
public static final int NERR_ErrorExecingGhost = NERR_BASE + 291; /* An error occurred when starting a background process. */
|
||||
public static final int NERR_ShareNotFound = NERR_BASE + 292; /* The shared resource you are connected to could not be found.*/
|
||||
/* UNUSED BASE + 293 */
|
||||
/* UNUSED BASE + 294 */
|
||||
|
||||
|
||||
/*
|
||||
* NetWksta.sys = redir; returned error codes.
|
||||
*
|
||||
* NERR_BASE + = 300-329;
|
||||
*/
|
||||
|
||||
public static final int NERR_InvalidLana = NERR_BASE + 300; /* The LAN adapter number is invalid. */
|
||||
public static final int NERR_OpenFiles = NERR_BASE + 301; /* There are open files on the connection. */
|
||||
public static final int NERR_ActiveConns = NERR_BASE + 302; /* Active connections still exist. */
|
||||
public static final int NERR_BadPasswordCore = NERR_BASE + 303; /* This share name or password is invalid. */
|
||||
public static final int NERR_DevInUse = NERR_BASE + 304; /* The device is being accessed by an active process. */
|
||||
public static final int NERR_LocalDrive = NERR_BASE + 305; /* The drive letter is in use locally. */
|
||||
|
||||
/*
|
||||
* Alert error codes.
|
||||
*
|
||||
* NERR_BASE + = 330-339;
|
||||
*/
|
||||
public static final int NERR_AlertExists = NERR_BASE + 330; /* The specified client is already registered for the specified event. */
|
||||
public static final int NERR_TooManyAlerts = NERR_BASE + 331; /* The alert table is full. */
|
||||
public static final int NERR_NoSuchAlert = NERR_BASE + 332; /* An invalid or nonexistent alert name was raised. */
|
||||
public static final int NERR_BadRecipient = NERR_BASE + 333; /* The alert recipient is invalid.*/
|
||||
public static final int NERR_AcctLimitExceeded = NERR_BASE + 334; /* A user's session with this server has been deleted
|
||||
* because the user's logon hours are no longer valid. */
|
||||
|
||||
/*
|
||||
* Additional Error and Audit log codes.
|
||||
*
|
||||
* NERR_BASE + (340-343;
|
||||
*/
|
||||
public static final int NERR_InvalidLogSeek = NERR_BASE + 340; /* The log file does not contain the requested record number. */
|
||||
/* UNUSED BASE + 341 */
|
||||
/* UNUSED BASE + 342 */
|
||||
/* UNUSED BASE + 343 */
|
||||
|
||||
/*
|
||||
* Additional UAS and NETLOGON codes
|
||||
*
|
||||
* NERR_BASE + (350-359;
|
||||
*/
|
||||
public static final int NERR_BadUasConfig = NERR_BASE + 350; /* The user accounts database is not configured correctly. */
|
||||
public static final int NERR_InvalidUASOp = NERR_BASE + 351; /* This operation is not permitted when the Netlogon service is running. */
|
||||
public static final int NERR_LastAdmin = NERR_BASE + 352; /* This operation is not allowed on the last administrative account. */
|
||||
public static final int NERR_DCNotFound = NERR_BASE + 353; /* Could not find domain controller for this domain. */
|
||||
public static final int NERR_LogonTrackingError = NERR_BASE + 354; /* Could not set logon information for this user. */
|
||||
public static final int NERR_NetlogonNotStarted = NERR_BASE + 355; /* The Netlogon service has not been started. */
|
||||
public static final int NERR_CanNotGrowUASFile = NERR_BASE + 356; /* Unable to add to the user accounts database. */
|
||||
public static final int NERR_TimeDiffAtDC = NERR_BASE + 357; /* This server's clock is not synchronized with the primary domain controller's clock. */
|
||||
public static final int NERR_PasswordMismatch = NERR_BASE + 358; /* A password mismatch has been detected. */
|
||||
|
||||
|
||||
/*
|
||||
* Server Integration error codes.
|
||||
*
|
||||
* NERR_BASE + (360-369;
|
||||
*/
|
||||
public static final int NERR_NoSuchServer = NERR_BASE + 360; /* The server identification does not specify a valid server. */
|
||||
public static final int NERR_NoSuchSession = NERR_BASE + 361; /* The session identification does not specify a valid session. */
|
||||
public static final int NERR_NoSuchConnection = NERR_BASE + 362; /* The connection identification does not specify a valid connection. */
|
||||
public static final int NERR_TooManyServers = NERR_BASE + 363; /* There is no space for another entry in the table of available servers. */
|
||||
public static final int NERR_TooManySessions = NERR_BASE + 364; /* The server has reached the maximum number of sessions it supports. */
|
||||
public static final int NERR_TooManyConnections = NERR_BASE + 365; /* The server has reached the maximum number of connections it supports. */
|
||||
public static final int NERR_TooManyFiles = NERR_BASE + 366; /* The server cannot open more files because it has reached its maximum number. */
|
||||
public static final int NERR_NoAlternateServers = NERR_BASE + 367; /* There are no alternate servers registered on this server. */
|
||||
/* UNUSED BASE + 368 */
|
||||
/* UNUSED BASE + 369 */
|
||||
|
||||
public static final int NERR_TryDownLevel = NERR_BASE + 370; /* Try down-level = remote admin protocol; version of API instead. */
|
||||
|
||||
/*
|
||||
* UPS error codes.
|
||||
*
|
||||
* NERR_BASE + = 380-384;
|
||||
*/
|
||||
public static final int NERR_UPSDriverNotStarted = NERR_BASE + 380; /* The UPS driver could not be accessed by the UPS service. */
|
||||
public static final int NERR_UPSInvalidConfig = NERR_BASE + 381; /* The UPS service is not configured correctly. */
|
||||
public static final int NERR_UPSInvalidCommPort = NERR_BASE + 382; /* The UPS service could not access the specified Comm Port. */
|
||||
public static final int NERR_UPSSignalAsserted = NERR_BASE + 383; /* The UPS indicated a line fail or low battery situation. Service not started. */
|
||||
public static final int NERR_UPSShutdownFailed = NERR_BASE + 384; /* The UPS service failed to perform a system shut down. */
|
||||
|
||||
/*
|
||||
* Remoteboot error codes.
|
||||
*
|
||||
* NERR_BASE + = 400-419;
|
||||
* Error codes 400 - 405 are used by RPLBOOT.SYS.
|
||||
* Error codes 403, 407 - 416 are used by RPLLOADR.COM,
|
||||
* Error code 417 is the alerter message of REMOTEBOOT = RPLSERVR.EXE;.
|
||||
* Error code 418 is for when REMOTEBOOT can't start
|
||||
* Error code 419 is for a disallowed 2nd rpl connection
|
||||
*
|
||||
*/
|
||||
public static final int NERR_BadDosRetCode = NERR_BASE + 400; /* The program below returned an MS-DOS error code:*/
|
||||
public static final int NERR_ProgNeedsExtraMem = NERR_BASE + 401; /* The program below needs more memory:*/
|
||||
public static final int NERR_BadDosFunction = NERR_BASE + 402; /* The program below called an unsupported MS-DOS function:*/
|
||||
public static final int NERR_RemoteBootFailed = NERR_BASE + 403; /* The workstation failed to boot.*/
|
||||
public static final int NERR_BadFileCheckSum = NERR_BASE + 404; /* The file below is corrupt.*/
|
||||
public static final int NERR_NoRplBootSystem = NERR_BASE + 405; /* No loader is specified in the boot-block definition file.*/
|
||||
public static final int NERR_RplLoadrNetBiosErr = NERR_BASE + 406; /* NetBIOS returned an error: The NCB and SMB are dumped above.*/
|
||||
public static final int NERR_RplLoadrDiskErr = NERR_BASE + 407; /* A disk I/O error occurred.*/
|
||||
public static final int NERR_ImageParamErr = NERR_BASE + 408; /* Image parameter substitution failed.*/
|
||||
public static final int NERR_TooManyImageParams = NERR_BASE + 409; /* Too many image parameters cross disk sector boundaries.*/
|
||||
public static final int NERR_NonDosFloppyUsed = NERR_BASE + 410; /* The image was not generated from an MS-DOS diskette formatted with /S.*/
|
||||
public static final int NERR_RplBootRestart = NERR_BASE + 411; /* Remote boot will be restarted later.*/
|
||||
public static final int NERR_RplSrvrCallFailed = NERR_BASE + 412; /* The call to the Remoteboot server failed.*/
|
||||
public static final int NERR_CantConnectRplSrvr = NERR_BASE + 413; /* Cannot connect to the Remoteboot server.*/
|
||||
public static final int NERR_CantOpenImageFile = NERR_BASE + 414; /* Cannot open image file on the Remoteboot server.*/
|
||||
public static final int NERR_CallingRplSrvr = NERR_BASE + 415; /* Connecting to the Remoteboot server...*/
|
||||
public static final int NERR_StartingRplBoot = NERR_BASE + 416; /* Connecting to the Remoteboot server...*/
|
||||
public static final int NERR_RplBootServiceTerm = NERR_BASE + 417; /* Remote boot service was stopped; check the error log for the cause of the problem.*/
|
||||
public static final int NERR_RplBootStartFailed = NERR_BASE + 418; /* Remote boot startup failed; check the error log for the cause of the problem.*/
|
||||
public static final int NERR_RPL_CONNECTED = NERR_BASE + 419; /* A second connection to a Remoteboot resource is not allowed.*/
|
||||
|
||||
/*
|
||||
* FTADMIN API error codes
|
||||
*
|
||||
* NERR_BASE + = 425-434;
|
||||
*
|
||||
* = Currently not used in NT;
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Browser service API error codes
|
||||
*
|
||||
* NERR_BASE + = 450-475;
|
||||
*
|
||||
*/
|
||||
public static final int NERR_BrowserConfiguredToNotRun = NERR_BASE + 450; /* The browser service was configured with MaintainServerList = No. */
|
||||
|
||||
/*
|
||||
* Additional Remoteboot error codes.
|
||||
*
|
||||
* NERR_BASE + = 510-550;
|
||||
*/
|
||||
public static final int NERR_RplNoAdaptersStarted = NERR_BASE + 510; /*Service failed to start since none of the network adapters started with this service.*/
|
||||
public static final int NERR_RplBadRegistry = NERR_BASE + 511; /*Service failed to start due to bad startup information in the registry.*/
|
||||
public static final int NERR_RplBadDatabase = NERR_BASE + 512; /*Service failed to start because its database is absent or corrupt.*/
|
||||
public static final int NERR_RplRplfilesShare = NERR_BASE + 513; /*Service failed to start because RPLFILES share is absent.*/
|
||||
public static final int NERR_RplNotRplServer = NERR_BASE + 514; /*Service failed to start because RPLUSER group is absent.*/
|
||||
public static final int NERR_RplCannotEnum = NERR_BASE + 515; /*Cannot enumerate service records.*/
|
||||
public static final int NERR_RplWkstaInfoCorrupted = NERR_BASE + 516; /*Workstation record information has been corrupted.*/
|
||||
public static final int NERR_RplWkstaNotFound = NERR_BASE + 517; /*Workstation record was not found.*/
|
||||
public static final int NERR_RplWkstaNameUnavailable = NERR_BASE + 518; /*Workstation name is in use by some other workstation.*/
|
||||
public static final int NERR_RplProfileInfoCorrupted = NERR_BASE + 519; /*Profile record information has been corrupted.*/
|
||||
public static final int NERR_RplProfileNotFound = NERR_BASE + 520; /*Profile record was not found.*/
|
||||
public static final int NERR_RplProfileNameUnavailable = NERR_BASE + 521; /*Profile name is in use by some other profile.*/
|
||||
public static final int NERR_RplProfileNotEmpty = NERR_BASE + 522; /*There are workstations using this profile.*/
|
||||
public static final int NERR_RplConfigInfoCorrupted = NERR_BASE + 523; /*Configuration record information has been corrupted.*/
|
||||
public static final int NERR_RplConfigNotFound = NERR_BASE + 524; /*Configuration record was not found.*/
|
||||
public static final int NERR_RplAdapterInfoCorrupted = NERR_BASE + 525; /*Adapter id record information has been corrupted.*/
|
||||
public static final int NERR_RplInternal = NERR_BASE + 526; /*An internal service error has occurred.*/
|
||||
public static final int NERR_RplVendorInfoCorrupted = NERR_BASE + 527; /*Vendor id record information has been corrupted.*/
|
||||
public static final int NERR_RplBootInfoCorrupted = NERR_BASE + 528; /*Boot block record information has been corrupted.*/
|
||||
public static final int NERR_RplWkstaNeedsUserAcct = NERR_BASE + 529; /*The user account for this workstation record is missing.*/
|
||||
public static final int NERR_RplNeedsRPLUSERAcct = NERR_BASE + 530; /*The RPLUSER local group could not be found.*/
|
||||
public static final int NERR_RplBootNotFound = NERR_BASE + 531; /*Boot block record was not found.*/
|
||||
public static final int NERR_RplIncompatibleProfile = NERR_BASE + 532; /*Chosen profile is incompatible with this workstation.*/
|
||||
public static final int NERR_RplAdapterNameUnavailable = NERR_BASE + 533; /*Chosen network adapter id is in use by some other workstation.*/
|
||||
public static final int NERR_RplConfigNotEmpty = NERR_BASE + 534; /*There are profiles using this configuration.*/
|
||||
public static final int NERR_RplBootInUse = NERR_BASE + 535; /*There are workstations, profiles or configurations using this boot block.*/
|
||||
public static final int NERR_RplBackupDatabase = NERR_BASE + 536; /*Service failed to backup Remoteboot database.*/
|
||||
public static final int NERR_RplAdapterNotFound = NERR_BASE + 537; /*Adapter record was not found.*/
|
||||
public static final int NERR_RplVendorNotFound = NERR_BASE + 538; /*Vendor record was not found.*/
|
||||
public static final int NERR_RplVendorNameUnavailable = NERR_BASE + 539; /*Vendor name is in use by some other vendor record.*/
|
||||
public static final int NERR_RplBootNameUnavailable = NERR_BASE + 540; /*(boot name, vendor id; is in use by some other boot block record.*/
|
||||
public static final int NERR_RplConfigNameUnavailable = NERR_BASE + 541; /*Configuration name is in use by some other configuration.*/
|
||||
|
||||
/**INTERNAL_ONLY**/
|
||||
|
||||
/*
|
||||
* Dfs API error codes.
|
||||
*
|
||||
* NERR_BASE + = 560-590;
|
||||
*/
|
||||
|
||||
public static final int NERR_DfsInternalCorruption = NERR_BASE + 560; /*The internal database maintained by the DFS service is corrupt*/
|
||||
public static final int NERR_DfsVolumeDataCorrupt = NERR_BASE + 561; /*One of the records in the internal DFS database is corrupt*/
|
||||
public static final int NERR_DfsNoSuchVolume = NERR_BASE + 562; /*There is no DFS name whose entry path matches the input Entry Path*/
|
||||
public static final int NERR_DfsVolumeAlreadyExists = NERR_BASE + 563; /*A root or link with the given name already exists*/
|
||||
public static final int NERR_DfsAlreadyShared = NERR_BASE + 564; /*The server share specified is already shared in the DFS*/
|
||||
public static final int NERR_DfsNoSuchShare = NERR_BASE + 565; /*The indicated server share does not support the indicated DFS namespace*/
|
||||
public static final int NERR_DfsNotALeafVolume = NERR_BASE + 566; /*The operation is not valid on this portion of the namespace*/
|
||||
public static final int NERR_DfsLeafVolume = NERR_BASE + 567; /*The operation is not valid on this portion of the namespace*/
|
||||
public static final int NERR_DfsVolumeHasMultipleServers = NERR_BASE + 568; /*The operation is ambiguous because the link has multiple servers*/
|
||||
public static final int NERR_DfsCantCreateJunctionPoint = NERR_BASE + 569; /*Unable to create a link*/
|
||||
public static final int NERR_DfsServerNotDfsAware = NERR_BASE + 570; /*The server is not DFS Aware*/
|
||||
public static final int NERR_DfsBadRenamePath = NERR_BASE + 571; /*The specified rename target path is invalid*/
|
||||
public static final int NERR_DfsVolumeIsOffline = NERR_BASE + 572; /*The specified DFS link is offline*/
|
||||
public static final int NERR_DfsNoSuchServer = NERR_BASE + 573; /*The specified server is not a server for this link*/
|
||||
public static final int NERR_DfsCyclicalName = NERR_BASE + 574; /*A cycle in the DFS name was detected*/
|
||||
public static final int NERR_DfsNotSupportedInServerDfs = NERR_BASE + 575; /*The operation is not supported on a server-based DFS*/
|
||||
public static final int NERR_DfsDuplicateService = NERR_BASE + 576; /*This link is already supported by the specified server-share*/
|
||||
public static final int NERR_DfsCantRemoveLastServerShare = NERR_BASE + 577; /*Can't remove the last server-share supporting this root or link*/
|
||||
public static final int NERR_DfsVolumeIsInterDfs = NERR_BASE + 578; /*The operation is not supported for an Inter-DFS link*/
|
||||
public static final int NERR_DfsInconsistent = NERR_BASE + 579; /*The internal state of the DFS Service has become inconsistent*/
|
||||
public static final int NERR_DfsServerUpgraded = NERR_BASE + 580; /*The DFS Service has been installed on the specified server*/
|
||||
public static final int NERR_DfsDataIsIdentical = NERR_BASE + 581; /*The DFS data being reconciled is identical*/
|
||||
public static final int NERR_DfsCantRemoveDfsRoot = NERR_BASE + 582; /*The DFS root cannot be deleted - Uninstall DFS if required*/
|
||||
public static final int NERR_DfsChildOrParentInDfs = NERR_BASE + 583; /*A child or parent directory of the share is already in a DFS*/
|
||||
public static final int NERR_DfsInternalError = NERR_BASE + 590; /*DFS internal error*/
|
||||
|
||||
/*
|
||||
* Net setup error codes.
|
||||
*
|
||||
* NERR_BASE + = 591-600;
|
||||
*/
|
||||
public static final int NERR_SetupAlreadyJoined = NERR_BASE + 591; /*This machine is already joined to a domain.*/
|
||||
public static final int NERR_SetupNotJoined = NERR_BASE + 592; /*This machine is not currently joined to a domain.*/
|
||||
public static final int NERR_SetupDomainController = NERR_BASE + 593; /*This machine is a domain controller and cannot be unjoined from a domain.*/
|
||||
public static final int NERR_DefaultJoinRequired = NERR_BASE + 594; /*The destination domain controller does not support creating machine accounts in OUs.*/
|
||||
public static final int NERR_InvalidWorkgroupName = NERR_BASE + 595; /*The specified workgroup name is invalid.*/
|
||||
public static final int NERR_NameUsesIncompatibleCodePage = NERR_BASE + 596; /*The specified computer name is incompatible with the default language used on the domain controller.*/
|
||||
public static final int NERR_ComputerAccountNotFound = NERR_BASE + 597; /*The specified computer account could not be found. Contact an administrator to verify the account is in the domain. If the account has been deleted unjoin, reboot, and rejoin the domain.*/
|
||||
public static final int NERR_PersonalSku = NERR_BASE + 598; /*This version of Windows cannot be joined to a domain.*/
|
||||
public static final int NERR_SetupCheckDNSConfig = NERR_BASE + 599; /*An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain.*/
|
||||
|
||||
/*
|
||||
* Some Password and account error results
|
||||
*
|
||||
* NERR_BASE + = 601 - 608;
|
||||
*/
|
||||
public static final int NERR_PasswordMustChange = NERR_BASE + 601; /* Password must change at next logon */
|
||||
public static final int NERR_AccountLockedOut = NERR_BASE + 602; /* Account is locked out */
|
||||
public static final int NERR_PasswordTooLong = NERR_BASE + 603; /* Password is too long */
|
||||
public static final int NERR_PasswordNotComplexEnough = NERR_BASE + 604; /* Password doesn't meet the complexity policy */
|
||||
public static final int NERR_PasswordFilterError = NERR_BASE + 605; /* Password doesn't meet the requirements of the filter dll's */
|
||||
|
||||
/***********WARNING ****************
|
||||
*The range 2750-2799 has been *
|
||||
*allocated to the IBM LAN Server *
|
||||
***********************************/
|
||||
|
||||
/***********WARNING ****************
|
||||
*The range 2900-2999 has been *
|
||||
*reserved for Microsoft OEMs *
|
||||
***********************************/
|
||||
|
||||
public static final int MAX_NERR = NERR_BASE + 899; /* This is the last error in NERR range. */
|
||||
}
|
||||
+22
-16
@@ -1,26 +1,32 @@
|
||||
/* 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.examples;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
|
||||
/** Sample implementation of C library access. */
|
||||
public interface CLibrary extends Library {
|
||||
|
||||
CLibrary INSTANCE = (CLibrary)
|
||||
Native.loadLibrary((System.getProperty("os.name").startsWith("Windows")
|
||||
? "msvcrt" : "c"), CLibrary.class);
|
||||
|
||||
int atol(String s);
|
||||
}
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
/**
|
||||
* Ported from LMJoin.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMJoin {
|
||||
|
||||
/**
|
||||
* Status of a workstation.
|
||||
*/
|
||||
public abstract class NETSETUP_JOIN_STATUS {
|
||||
public static final int NetSetupUnknownStatus = 0;
|
||||
public static final int NetSetupUnjoined = 1;
|
||||
public static final int NetSetupWorkgroupName = 2;
|
||||
public static final int NetSetupDomainName = 3;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
/* 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.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
|
||||
/**
|
||||
* Ported from NTSecApi.h
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class NTSecApi {
|
||||
|
||||
/**
|
||||
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
|
||||
* functions to specify a Unicode string.
|
||||
*/
|
||||
public static class LSA_UNICODE_STRING extends Structure {
|
||||
public static class ByReference extends LSA_UNICODE_STRING implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the length, in bytes, of the string pointed to by the Buffer member,
|
||||
* not including the terminating null character, if any.
|
||||
*/
|
||||
public short Length;
|
||||
/**
|
||||
* Specifies the total size, in bytes, of the memory allocated for Buffer. Up to
|
||||
* MaximumLength bytes can be written into the buffer without trampling memory.
|
||||
*/
|
||||
public short MaximumLength;
|
||||
/**
|
||||
* Pointer to a wide character string. Note that the strings returned by the
|
||||
* various LSA functions might not be null terminated.
|
||||
*/
|
||||
public Pointer Buffer;
|
||||
|
||||
/**
|
||||
* String representation of the buffer.
|
||||
* @return
|
||||
* Unicode string.
|
||||
*/
|
||||
public String getString() {
|
||||
byte[] data = Buffer.getByteArray(0, Length);
|
||||
if (data.length < 2 || data[data.length - 1] != 0) {
|
||||
Memory newdata = new Memory(data.length + 2);
|
||||
newdata.write(0, data, 0, data.length);
|
||||
return newdata.getString(0, true);
|
||||
}
|
||||
return Buffer.getString(0, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pointer to an LSA_UNICODE_STRING.
|
||||
*/
|
||||
public static class PLSA_UNICODE_STRING {
|
||||
public static class ByReference extends PLSA_UNICODE_STRING
|
||||
implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_UNICODE_STRING.ByReference s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record contains an included top-level name.
|
||||
*/
|
||||
public static final int ForestTrustTopLevelName = 0;
|
||||
/**
|
||||
* Record contains an excluded top-level name.
|
||||
*/
|
||||
public static final int ForestTrustTopLevelNameEx = 1;
|
||||
/**
|
||||
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
|
||||
*/
|
||||
public static final int ForestTrustDomainInfo = 2;
|
||||
|
||||
public static class LSA_FOREST_TRUST_DOMAIN_INFO extends Structure {
|
||||
public PSID.ByReference Sid;
|
||||
public LSA_UNICODE_STRING DnsName;
|
||||
public LSA_UNICODE_STRING NetbiosName;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_BINARY_DATA extends Structure {
|
||||
public NativeLong Length;
|
||||
public Pointer Buffer;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_RECORD extends Structure {
|
||||
|
||||
public static class ByReference extends LSA_FOREST_TRUST_RECORD implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public static class UNION extends Union {
|
||||
public static class ByReference extends UNION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_UNICODE_STRING TopLevelName;
|
||||
public LSA_FOREST_TRUST_DOMAIN_INFO DomainInfo;
|
||||
public LSA_FOREST_TRUST_BINARY_DATA Data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags that control the behavior of the operation.
|
||||
*/
|
||||
public NativeLong Flags;
|
||||
|
||||
/**
|
||||
* LSA_FOREST_TRUST_RECORD_TYPE enumeration that indicates the type of the record.
|
||||
* The following table shows the possible values.
|
||||
* ForestTrustTopLevelName
|
||||
* Record contains an included top-level name.
|
||||
* ForestTrustTopLevelNameEx
|
||||
* Record contains an excluded top-level name.
|
||||
* ForestTrustDomainInfo
|
||||
* Record contains an LSA_FOREST_TRUST_DOMAIN_INFO structure.
|
||||
* ForestTrustRecordTypeLast
|
||||
* Marks the end of an enumeration.
|
||||
*/
|
||||
public int ForestTrustType;
|
||||
public LARGE_INTEGER Time;
|
||||
|
||||
/**
|
||||
* Data type depending on ForestTrustType.
|
||||
*/
|
||||
public UNION u;
|
||||
|
||||
public void read() {
|
||||
super.read();
|
||||
|
||||
switch(ForestTrustType) {
|
||||
case NTSecApi.ForestTrustTopLevelName:
|
||||
case NTSecApi.ForestTrustTopLevelNameEx:
|
||||
u.setType(LSA_UNICODE_STRING.class);
|
||||
break;
|
||||
case NTSecApi.ForestTrustDomainInfo:
|
||||
u.setType(LSA_FOREST_TRUST_DOMAIN_INFO.class);
|
||||
break;
|
||||
default:
|
||||
u.setType(LSA_FOREST_TRUST_BINARY_DATA.class);
|
||||
break;
|
||||
}
|
||||
|
||||
u.read();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PLSA_FOREST_TRUST_RECORD extends Structure {
|
||||
public static class ByReference extends PLSA_FOREST_TRUST_RECORD implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_RECORD.ByReference tr;
|
||||
}
|
||||
|
||||
public static class LSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
|
||||
public static class ByReference extends LSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of LSA_FOREST_TRUST_RECORD structures in the array pointed to by the
|
||||
* Entries member.
|
||||
*/
|
||||
public NativeLong RecordCount;
|
||||
/**
|
||||
* Pointer to a pointer to an array of LSA_FOREST_TRUST_RECORD structures,
|
||||
* each of which contains one piece of forest trust information.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD.ByReference Entries;
|
||||
|
||||
/**
|
||||
* Get an array of LSA_FOREST_TRUST_RECORD entries.
|
||||
* @return
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
|
||||
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The LSA_FOREST_TRUST_INFORMATION structure contains Local Security Authority
|
||||
* forest trust information.
|
||||
*/
|
||||
public static class PLSA_FOREST_TRUST_INFORMATION extends Structure {
|
||||
|
||||
public static class ByReference extends PLSA_FOREST_TRUST_INFORMATION implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
public LSA_FOREST_TRUST_INFORMATION.ByReference fti;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/* 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 abstract class NTStatus {
|
||||
|
||||
public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth
|
||||
public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_0
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_0
|
||||
//
|
||||
public static final int STATUS_WAIT_0 = 0x00000000; // winnt
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_1
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_1
|
||||
//
|
||||
public static final int STATUS_WAIT_1 = 0x00000001;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_2
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_2
|
||||
//
|
||||
public static final int STATUS_WAIT_2 = 0x00000002;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_3
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_3
|
||||
//
|
||||
public static final int STATUS_WAIT_3 = 0x00000003;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_WAIT_63
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_WAIT_63
|
||||
//
|
||||
public static final int STATUS_WAIT_63 = 0x0000003F;
|
||||
|
||||
//
|
||||
// The success status codes 128 - 191 are reserved for wait completion
|
||||
// status with an abandoned mutant object.
|
||||
//
|
||||
public static final int STATUS_ABANDONED = 0x00000080;
|
||||
|
||||
//
|
||||
// MessageId: STATUS_ABANDONED_WAIT_0
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_ABANDONED_WAIT_0
|
||||
//
|
||||
public static final int STATUS_ABANDONED_WAIT_0 = 0x00000080; // winnt
|
||||
|
||||
//
|
||||
// MessageId: STATUS_ABANDONED_WAIT_63
|
||||
//
|
||||
// MessageText:
|
||||
//
|
||||
// STATUS_ABANDONED_WAIT_63
|
||||
//
|
||||
public static final int STATUS_ABANDONED_WAIT_63 = 0x000000BF;
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Netapi32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Netapi32 extends W32API {
|
||||
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
|
||||
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Retrieves join status information for the specified computer.
|
||||
*
|
||||
* @param lpServer
|
||||
* Specifies the DNS or NetBIOS name of the computer on which to
|
||||
* call the function.
|
||||
* @param lpNameBuffer
|
||||
* Receives the NetBIOS name of the domain or workgroup to which
|
||||
* the computer is joined.
|
||||
* @param BufferType
|
||||
* Join status of the specified computer.
|
||||
* @return If the function succeeds, the return value is NERR_Success. If
|
||||
* the function fails, the return value is a system error code.
|
||||
*/
|
||||
public int NetGetJoinInformation(String lpServer,
|
||||
PointerByReference lpNameBuffer, IntByReference BufferType);
|
||||
|
||||
/**
|
||||
* Frees the memory that the NetApiBufferAllocate function allocates.
|
||||
*
|
||||
* @param buffer
|
||||
* @return If the function succeeds, the return value is NERR_Success. If
|
||||
* the function fails, the return value is a system error code.
|
||||
*/
|
||||
public int NetApiBufferFree(Pointer buffer);
|
||||
|
||||
/**
|
||||
* Returns information about each local group account on the specified
|
||||
* server.
|
||||
*
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on
|
||||
* which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the address of the buffer that receives the
|
||||
* information structure.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in
|
||||
* bytes.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements
|
||||
* actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the approximate total number
|
||||
* of entries that could have been enumerated from the current
|
||||
* resume position.
|
||||
* @param resume_handle
|
||||
* Pointer to a value that contains a resume handle that is used
|
||||
* to continue an existing local group search.
|
||||
* @return If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetLocalGroupEnum(String serverName, int level,
|
||||
PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC).
|
||||
*
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on which the function is
|
||||
* to execute. If this parameter is NULL, the local computer is used.
|
||||
* @param domainName
|
||||
* Specifies the name of the domain.
|
||||
* @param bufptr
|
||||
* Receives a string that specifies the server name of the PDC of the domain.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetGetDCName(String serverName, String domainName,
|
||||
PointerByReference bufptr);
|
||||
|
||||
/**
|
||||
* The NetGroupEnum function retrieves information about each global group
|
||||
* in the security database, which is the security accounts manager (SAM) database or,
|
||||
* in the case of domain controllers, the Active Directory.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
|
||||
* remote server on which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the buffer to receive the global group information structure.
|
||||
* The format of this data depends on the value of the level parameter.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of the returned data, in bytes.
|
||||
* If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of
|
||||
* memory required to hold the data. If you specify another value in this
|
||||
* parameter, it can restrict the number of bytes that the function returns.
|
||||
* If the buffer size is insufficient to hold all entries, the function
|
||||
* returns ERROR_MORE_DATA.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have
|
||||
* been enumerated from the current resume position. The total number of entries
|
||||
* is only a hint.
|
||||
* @param resume_handle
|
||||
* Pointer to a variable that contains a resume handle that is used to continue
|
||||
* the global group enumeration. The handle should be zero on the first call and
|
||||
* left unchanged for subsequent calls. If resume_handle is NULL, no resume handle
|
||||
* is stored.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetGroupEnum(String servername, int level, PointerByReference bufptr,
|
||||
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/**
|
||||
* The NetUserEnum function provides information about all user accounts on a server.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
|
||||
* remote server on which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param filter
|
||||
* Specifies a value that filters the account types for enumeration.
|
||||
* @param bufptr
|
||||
* Pointer to the buffer that receives the data. The format of this data depends
|
||||
* on the value of the level parameter. This buffer is allocated by the system and
|
||||
* must be freed using the NetApiBufferFree function. Note that you must free the
|
||||
* buffer even if the function fails with ERROR_MORE_DATA.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length, in 8-bit bytes of returned data. If you
|
||||
* specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory
|
||||
* required for the data. If you specify another value in this parameter, it can
|
||||
* restrict the number of bytes that the function returns. If the buffer size is
|
||||
* insufficient to hold all entries, the function returns ERROR_MORE_DATA.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have
|
||||
* been enumerated from the current resume position. Note that applications should
|
||||
* consider this value only as a hint.
|
||||
* @param resume_handle
|
||||
* Pointer to a value that contains a resume handle which is used to continue an
|
||||
* existing user search. The handle should be zero on the first call and left
|
||||
* unchanged for subsequent calls. If resume_handle is NULL, then no resume
|
||||
* handle is stored.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserEnum(String servername, int level, int filter, PointerByReference bufptr,
|
||||
int prefmaxlen, IntByReference entriesread, IntByReference totalentries,
|
||||
IntByReference resume_handle);
|
||||
|
||||
/**
|
||||
* The NetUserGetGroups function retrieves a list of global groups to which a
|
||||
* specified user belongs.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the
|
||||
* remote server on which the function is to execute. If this parameter is NULL,
|
||||
* the local computer is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies the name of the user to search for
|
||||
* in each group account. For more information, see the following Remarks section.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the buffer that receives the data. This buffer is allocated by the
|
||||
* system and must be freed using the NetApiBufferFree function. Note that you must
|
||||
* free the buffer even if the function fails with ERROR_MORE_DATA.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in bytes. If you specify
|
||||
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
|
||||
* data. If you specify another value in this parameter, it can restrict the number
|
||||
* of bytes that the function returns. If the buffer size is insufficient to hold
|
||||
* all entries, the function returns ERROR_MORE_DATA.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually retrieved.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have been retrieved.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserGetGroups(String servername, String username, int level,
|
||||
PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries);
|
||||
|
||||
/**
|
||||
* The NetUserGetLocalGroups function retrieves a list of local groups to which a
|
||||
* specified user belongs.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
|
||||
* server on which the function is to execute. If this parameter is NULL, the local
|
||||
* computer is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies the name of the user for which to return
|
||||
* local group membership information. If the string is of the form DomainName\UserName
|
||||
* the user name is expected to be found on that domain. If the string is of the form
|
||||
* UserName, the user name is expected to be found on the server specified by the
|
||||
* servername parameter.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param flags
|
||||
* Specifies a bitmask of flags. Currently, only the value LG_INCLUDE_INDIRECT is
|
||||
* defined. If this bit is set, the function also returns the names of the local
|
||||
* groups in which the user is indirectly a member (that is, the user has membership
|
||||
* in a global group that is itself a member of one or more local groups).
|
||||
* @param bufptr
|
||||
* Pointer to the buffer that receives the data. The format of this data depends on
|
||||
* the value of the level parameter. This buffer is allocated by the system and must
|
||||
* be freed using the NetApiBufferFree function. Note that you must free the buffer
|
||||
* even if the function fails with ERROR_MORE_DATA.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in bytes. If you specify
|
||||
* MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the
|
||||
* data. If you specify another value in this parameter, it can restrict the number of
|
||||
* bytes that the function returns. If the buffer size is insufficient to hold all
|
||||
* entries, the function returns ERROR_MORE_DATA. For more information, see Network
|
||||
* Management Function Buffers and Network Management Function Buffer Lengths.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements actually enumerated.
|
||||
* @param totalentries
|
||||
* Pointer to a value that receives the total number of entries that could have been enumerated.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserGetLocalGroups(String servername, String username, int level,
|
||||
int flags, PointerByReference bufptr, int prefmaxlen,
|
||||
IntByReference entriesread, IntByReference totalentries);
|
||||
|
||||
/**
|
||||
* The NetUserAdd function adds a user account and assigns a password and privilege level.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote server
|
||||
* on which the function is to execute.
|
||||
* @param level
|
||||
* Specifies the information level of the data.
|
||||
* @param buf
|
||||
* Pointer to the buffer that specifies the data. The format of this data depends on the
|
||||
* value of the level parameter.
|
||||
* @param parm_err
|
||||
* Pointer to a value that receives the index of the first member of the user information
|
||||
* structure that causes ERROR_INVALID_PARAMETER. If this parameter is NULL, the index is
|
||||
* not returned on error.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserAdd(String servername, int level,
|
||||
Structure buf, IntByReference parm_err);
|
||||
|
||||
|
||||
/**
|
||||
* The NetUserDel function deletes a user account from a server.
|
||||
* @param servername
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of the remote
|
||||
* server on which the function is to execute. If this parameter is NULL, the local
|
||||
* computer is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies the name of the user account to delete.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserDel(String servername, String username);
|
||||
|
||||
/**
|
||||
* The NetUserChangePassword function changes a user's password for a specified
|
||||
* network server or domain.
|
||||
* @param domainname
|
||||
* Pointer to a constant string that specifies the DNS or NetBIOS name of a remote
|
||||
* server or domain on which the function is to execute. If this parameter is NULL,
|
||||
* the logon domain of the caller is used.
|
||||
* @param username
|
||||
* Pointer to a constant string that specifies a user name. The NetUserChangePassword
|
||||
* function changes the password for the specified user. If this parameter is NULL,
|
||||
* the logon name of the caller is used.
|
||||
* @param oldpassword
|
||||
* Pointer to a constant string that specifies the user's old password.
|
||||
* @param newpassword
|
||||
* Pointer to a constant string that specifies the user's new password.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NERR_Success.
|
||||
*/
|
||||
public int NetUserChangePassword(String domainname, String username,
|
||||
String oldpassword, String newpassword);
|
||||
|
||||
/**
|
||||
* The DsGetDcName function returns the name of a domain controller in a specified domain.
|
||||
* This function accepts additional domain controller selection criteria to indicate
|
||||
* preference for a domain controller with particular characteristics.
|
||||
* @param ComputerName
|
||||
* Pointer to a null-terminated string that specifies the name of the server to process
|
||||
* this function. Typically, this parameter is NULL, which indicates that the local
|
||||
* computer is used.
|
||||
* @param DomainName
|
||||
* Pointer to a null-terminated string that specifies the name of the domain or application
|
||||
* partition to query. This name can either be a DNS style name, for example, fabrikam.com,
|
||||
* or a flat-style name, for example, Fabrikam. If a DNS style name is specified, the name
|
||||
* may be specified with or without a trailing period.
|
||||
* @param DomainGuid
|
||||
* Pointer to a GUID structure that specifies the GUID of the domain queried. If DomainGuid
|
||||
* is not NULL and the domain specified by DomainName or ComputerName cannot be found,
|
||||
* DsGetDcName attempts to locate a domain controller in the domain having the GUID specified
|
||||
* by DomainGuid.
|
||||
* @param SiteName
|
||||
* Pointer to a null-terminated string that specifies the name of the site where the returned
|
||||
* domain controller should physically exist. If this parameter is NULL, DsGetDcName attempts
|
||||
* to return a domain controller in the site closest to the site of the computer specified by
|
||||
* ComputerName. This parameter should be NULL, by default.
|
||||
* @param Flags
|
||||
* Contains a set of flags that provide additional data used to process the request.
|
||||
* @param DomainControllerInfo
|
||||
* Pointer to a PDOMAIN_CONTROLLER_INFO value that receives a pointer to a
|
||||
* DOMAIN_CONTROLLER_INFO structure that contains data about the domain controller selected.
|
||||
* This structure is allocated by DsGetDcName. The caller must free the structure using
|
||||
* the NetApiBufferFree function when it is no longer required.
|
||||
* @return
|
||||
* If the function returns domain controller data, the return value is ERROR_SUCCESS.
|
||||
* If the function fails, the return code is one of ERROR_* values.
|
||||
*/
|
||||
public int DsGetDcName(String ComputerName, String DomainName, GUID DomainGuid,
|
||||
String SiteName, int Flags, PDOMAIN_CONTROLLER_INFO.ByReference DomainControllerInfo);
|
||||
|
||||
/**
|
||||
* The DsGetForestTrustInformationW function obtains forest trust data for a specified domain.
|
||||
* @param serverName
|
||||
* Contains the name of the domain controller that DsGetForestTrustInformationW
|
||||
* is connected to remotely. The caller must be an authenticated user on this server.
|
||||
* If this parameter is NULL, the local server is used.
|
||||
* @param trustedDomainName
|
||||
* Contains the NETBIOS or DNS name of the trusted domain that the forest trust data
|
||||
* is to be retrieved for. This domain must have the TRUST_ATTRIBUTE_FOREST_TRANSITIVE
|
||||
* trust attribute. If this parameter is NULL, the forest trust data for the domain
|
||||
* hosted by ServerName is retrieved.
|
||||
* @param Flags
|
||||
* Contains a set of flags that modify the behavior of this function.
|
||||
* DS_GFTI_UPDATE_TDO: If this flag is set, DsGetForestTrustInformationW will update the
|
||||
* forest trust data of the trusted domain identified by the TrustedDomainName parameter.
|
||||
* @param ForestTrustInfo
|
||||
* Pointer to an LSA_FOREST_TRUST_INFORMATION structure pointer that receives the forest
|
||||
* trust data that describes the namespaces claimed by the domain specified by
|
||||
* TrustedDomainName. The Time member of all returned records will be zero.
|
||||
* @return
|
||||
* Returns NO_ERROR if successful or a Win32 error code otherwise.
|
||||
*/
|
||||
public int DsGetForestTrustInformation(String serverName, String trustedDomainName, int Flags,
|
||||
PLSA_FOREST_TRUST_INFORMATION.ByReference ForestTrustInfo);
|
||||
|
||||
/**
|
||||
* The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
|
||||
* @param serverName
|
||||
* Pointer to a null-terminated string that specifies the name of a computer in the domain to
|
||||
* obtain the trust information for. This computer must be running the Windows 2000 or later
|
||||
* operating system. If this parameter is NULL, the name of the local computer is used.
|
||||
* The caller must be an authenticated user in this domain.
|
||||
* @param Flags
|
||||
* Contains a set of flags that determines which domain trusts to enumerate.
|
||||
* @param Domains
|
||||
* Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures.
|
||||
* Each structure in this array contains trust data about a domain. The caller must free this
|
||||
* memory when it is no longer required by calling NetApiBufferFree.
|
||||
* @param DomainCount
|
||||
* Pointer to a ULONG value that receives the number of elements returned in the Domains array.
|
||||
* @return
|
||||
* Returns ERROR_SUCCESS if successful or a Win32 error code otherwise.
|
||||
*/
|
||||
public int DsEnumerateDomainTrusts(String serverName, NativeLong Flags,
|
||||
PDS_DOMAIN_TRUSTS.ByReference Domains, NativeLongByReference DomainCount);
|
||||
}
|
||||
@@ -0,0 +1,605 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.DsGetDC.DS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO;
|
||||
import com.sun.jna.platform.win32.DsGetDC.PDS_DOMAIN_TRUSTS;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.LMAccess.GROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_INFO_1;
|
||||
import com.sun.jna.platform.win32.LMAccess.LOCALGROUP_USERS_INFO_0;
|
||||
import com.sun.jna.platform.win32.Secur32.EXTENDED_NAME_FORMAT;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
/**
|
||||
* Netapi32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Netapi32Util {
|
||||
|
||||
/**
|
||||
* A group.
|
||||
*/
|
||||
public static class Group {
|
||||
/**
|
||||
* Group name.
|
||||
*/
|
||||
public String name;
|
||||
}
|
||||
|
||||
/**
|
||||
* A user.
|
||||
*/
|
||||
public static class User {
|
||||
/**
|
||||
* The name of the user account.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Contains a comment associated with the user account.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
/**
|
||||
* A local group.
|
||||
*/
|
||||
public static class LocalGroup extends Group {
|
||||
/**
|
||||
* Group comment.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC) on the current computer.
|
||||
* @return The name of the primary domain controller.
|
||||
*/
|
||||
public static String getDCName() {
|
||||
return getDCName(null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the primary domain controller (PDC).
|
||||
* @param serverName
|
||||
* Specifies the DNS or NetBIOS name of the remote server on which the function is
|
||||
* to execute.
|
||||
* @param domainName
|
||||
* Specifies the name of the domain.
|
||||
* @return
|
||||
* Name of the primary domain controller.
|
||||
*/
|
||||
public static String getDCName(String serverName, String domainName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufptr.getValue().getString(0, true);
|
||||
} finally {
|
||||
if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain/workgroup join status for a computer.
|
||||
* @return Join status.
|
||||
*/
|
||||
public static int getJoinStatus() {
|
||||
return getJoinStatus(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain/workgroup join status for a computer.
|
||||
* @param computerName Computer name.
|
||||
* @return Join status.
|
||||
*/
|
||||
public static int getJoinStatus(String computerName) {
|
||||
PointerByReference lpNameBuffer = new PointerByReference();
|
||||
IntByReference bufferType = new IntByReference();
|
||||
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return bufferType.getValue();
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a computer.
|
||||
* @param computerName
|
||||
* @return Domain or workgroup name.
|
||||
*/
|
||||
public static String getDomainName(String computerName) {
|
||||
PointerByReference lpNameBuffer = new PointerByReference();
|
||||
IntByReference bufferType = new IntByReference();
|
||||
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
// type of domain: bufferType.getValue()
|
||||
return lpNameBuffer.getValue().getString(0, true);
|
||||
} finally {
|
||||
if (lpNameBuffer.getPointer() != null) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of local groups on the current computer.
|
||||
* @return An array of local group names.
|
||||
*/
|
||||
public static LocalGroup[] getLocalGroups() {
|
||||
return getLocalGroups(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of local groups on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of local group names.
|
||||
*/
|
||||
public static LocalGroup[] getLocalGroups(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue());
|
||||
LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LOCALGROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui1_name.toString();
|
||||
lgp.comment = lgpi.lgrui1_comment.toString();;
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of global groups on a computer.
|
||||
* @return An array of group names.
|
||||
*/
|
||||
public static Group[] getGlobalGroups() {
|
||||
return getGlobalGroups(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of global groups on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of group names.
|
||||
*/
|
||||
public static Group[] getGlobalGroups(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
|
||||
LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
|
||||
for(LMAccess.GROUP_INFO_1 lgpi : groups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.grpi1_name.toString();
|
||||
lgp.comment = lgpi.grpi1_comment.toString();;
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new LocalGroup[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of users on a local computer.
|
||||
* @return Users.
|
||||
*/
|
||||
public static User[] getUsers() {
|
||||
return getUsers(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the names of users on a computer.
|
||||
* @param serverName Name of the computer.
|
||||
* @return An array of users.
|
||||
*/
|
||||
public static User[] getUsers(String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesRead = new IntByReference();
|
||||
IntByReference totalEntries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
|
||||
LMCons.MAX_PREFERRED_LENGTH, entriesRead,
|
||||
totalEntries, null);
|
||||
if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
|
||||
LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
|
||||
|
||||
ArrayList<User> result = new ArrayList<User>();
|
||||
for(LMAccess.USER_INFO_1 lu : users) {
|
||||
User auser = new User();
|
||||
auser.name = lu.usri1_name.toString();
|
||||
result.add(auser);
|
||||
}
|
||||
return result.toArray(new User[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of the current user.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getCurrentUserLocalGroups() {
|
||||
return getUserLocalGroups(Secur32Util.getUserNameEx(
|
||||
EXTENDED_NAME_FORMAT.NameSamCompatible));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of a given user.
|
||||
* @param userName User name.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getUserLocalGroups(String userName) {
|
||||
return getUserLocalGroups(userName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get local groups of a given user on a given system.
|
||||
* @param userName User name.
|
||||
* @param serverName Server name.
|
||||
* @return Local groups.
|
||||
*/
|
||||
public static Group[] getUserLocalGroups(String userName, String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetLocalGroups(serverName, userName,
|
||||
0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
|
||||
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (LOCALGROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
LocalGroup lgp = new LocalGroup();
|
||||
lgp.name = lgpi.lgrui0_name.toString();
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of a given user.
|
||||
* @param userName User name.
|
||||
* @return Groups.
|
||||
*/
|
||||
public static Group[] getUserGroups(String userName) {
|
||||
return getUserGroups(userName, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of a given user on a given system.
|
||||
* @param userName User name.
|
||||
* @param serverName Server name.
|
||||
* @return Groups.
|
||||
*/
|
||||
public static Group[] getUserGroups(String userName, String serverName) {
|
||||
PointerByReference bufptr = new PointerByReference();
|
||||
IntByReference entriesread = new IntByReference();
|
||||
IntByReference totalentries = new IntByReference();
|
||||
try {
|
||||
int rc = Netapi32.INSTANCE.NetUserGetGroups(serverName, userName,
|
||||
0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries);
|
||||
if (rc != LMErr.NERR_Success) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());
|
||||
GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
|
||||
ArrayList<Group> result = new ArrayList<Group>();
|
||||
for (GROUP_USERS_INFO_0 lgpi : lgroups) {
|
||||
Group lgp = new Group();
|
||||
lgp.name = lgpi.grui0_name.toString();
|
||||
result.add(lgp);
|
||||
}
|
||||
return result.toArray(new Group[0]);
|
||||
} finally {
|
||||
if (bufptr.getValue() != Pointer.NULL) {
|
||||
int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A domain controller.
|
||||
*/
|
||||
public static class DomainController {
|
||||
/**
|
||||
* Specifies the computer name of the discovered domain controller.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Specifies the address of the discovered domain controller.
|
||||
*/
|
||||
public String address;
|
||||
/**
|
||||
* Indicates the type of WString that is contained in the
|
||||
* DomainControllerAddress member.
|
||||
*/
|
||||
public int addressType;
|
||||
/**
|
||||
* The GUID of the domain.
|
||||
*/
|
||||
public GUID domainGuid;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain.
|
||||
*/
|
||||
public String domainName;
|
||||
/**
|
||||
* Pointer to a null-terminated WString that specifies the name of the domain at the root
|
||||
* of the DS tree.
|
||||
*/
|
||||
public String dnsForestName;
|
||||
/**
|
||||
* Contains a set of flags that describe the domain controller.
|
||||
*/
|
||||
public int flags;
|
||||
/**
|
||||
* The name of the site that the computer belongs to.
|
||||
*/
|
||||
public String clientSiteName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the domain controller for a current computer.
|
||||
* @return
|
||||
* Domain controller information.
|
||||
*/
|
||||
public static DomainController getDC() {
|
||||
PDOMAIN_CONTROLLER_INFO.ByReference pdci = new PDOMAIN_CONTROLLER_INFO.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
|
||||
if (W32Errors.ERROR_SUCCESS != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
DomainController dc = new DomainController();
|
||||
dc.address = pdci.dci.DomainControllerAddress.toString();
|
||||
dc.addressType = pdci.dci.DomainControllerAddressType;
|
||||
dc.clientSiteName = pdci.dci.ClientSiteName.toString();
|
||||
dc.dnsForestName = pdci.dci.DnsForestName.toString();
|
||||
dc.domainGuid = pdci.dci.DomainGuid;
|
||||
dc.domainName = pdci.dci.DomainName.toString();
|
||||
dc.flags = pdci.dci.Flags;
|
||||
dc.name = pdci.dci.DomainControllerName.toString();
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.getPointer());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return dc;
|
||||
}
|
||||
|
||||
/**
|
||||
* A domain trust relationship.
|
||||
*/
|
||||
public static class DomainTrust {
|
||||
/**
|
||||
* NetBIOS name of the domain.
|
||||
*/
|
||||
public String NetbiosDomainName;
|
||||
/**
|
||||
* DNS name of the domain.
|
||||
*/
|
||||
public String DnsDomainName;
|
||||
/**
|
||||
* Contains the security identifier of the domain represented by this structure.
|
||||
*/
|
||||
public PSID DomainSid;
|
||||
/**
|
||||
* Contains the string representation of the security identifier of the domain
|
||||
* represented by this structure.
|
||||
*/
|
||||
public String DomainSidString;
|
||||
/**
|
||||
* Contains the GUID of the domain represented by this structure.
|
||||
*/
|
||||
public GUID DomainGuid;
|
||||
/**
|
||||
* Contains the string representation of the GUID of the domain represented by
|
||||
* this structure.
|
||||
*/
|
||||
public String DomainGuidString;
|
||||
|
||||
/**
|
||||
* Contains a set of flags that specify more data about the domain trust.
|
||||
*/
|
||||
private int flags;
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is a member of the same forest
|
||||
* as the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isInForest() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_IN_FOREST) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is directly trusted by the domain
|
||||
* that the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function is a member of.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isOutbound() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_DIRECT_OUTBOUND) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is the root of a tree and a member
|
||||
* of the same forest as the server specified in the ServerName parameter of the
|
||||
* DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isRoot() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_TREE_ROOT) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is the primary domain of the server
|
||||
* specified in the ServerName parameter of the DsEnumerateDomainTrusts function.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isPrimary() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_PRIMARY) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure is running in the Windows 2000 native mode.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isNativeMode() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_NATIVE_MODE) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The domain represented by this structure directly trusts the domain that
|
||||
* the server specified in the ServerName parameter of the DsEnumerateDomainTrusts
|
||||
* function is a member of.
|
||||
* @return
|
||||
* True or false.
|
||||
*/
|
||||
public boolean isInbound() {
|
||||
return (flags & DsGetDC.DS_DOMAIN_DIRECT_INBOUND) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts() {
|
||||
return getDomainTrusts(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all domain trusts for a given server.
|
||||
* @param serverName
|
||||
* Server name.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public static DomainTrust[] getDomainTrusts(String serverName) {
|
||||
NativeLongByReference domainCount = new NativeLongByReference();
|
||||
PDS_DOMAIN_TRUSTS.ByReference domains = new PDS_DOMAIN_TRUSTS.ByReference();
|
||||
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(
|
||||
serverName, new NativeLong(DsGetDC.DS_DOMAIN_VALID_FLAGS), domains, domainCount);
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
try {
|
||||
int domainCountValue = domainCount.getValue().intValue();
|
||||
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainCountValue);
|
||||
for(DS_DOMAIN_TRUSTS trust : domains.getTrusts(domainCountValue)) {
|
||||
DomainTrust t = new DomainTrust();
|
||||
t.DnsDomainName = trust.DnsDomainName.toString();
|
||||
t.NetbiosDomainName = trust.NetbiosDomainName.toString();
|
||||
t.DomainSid = trust.DomainSid;
|
||||
t.DomainSidString = Advapi32Util.convertSidToStringSid(trust.DomainSid);
|
||||
t.DomainGuid = trust.DomainGuid;
|
||||
t.DomainGuidString = Ole32Util.getStringFromGUID(trust.DomainGuid);
|
||||
t.flags = trust.Flags.intValue();
|
||||
trusts.add(t);
|
||||
}
|
||||
return trusts.toArray(new DomainTrust[0]);
|
||||
} finally {
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(domains.getPointer());
|
||||
if(W32Errors.NO_ERROR != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* ntdll.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface NtDll extends W32API {
|
||||
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
|
||||
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* The ZwQueryKey routine provides information about the class of a registry key,
|
||||
* and the number and sizes of its subkeys.
|
||||
* @param KeyHandle
|
||||
* Handle to the registry key to obtain information about. This handle is created by
|
||||
* a successful call to ZwCreateKey or ZwOpenKey.
|
||||
* @param KeyInformationClass
|
||||
* Specifies a KEY_INFORMATION_CLASS value that determines the type of information
|
||||
* returned in the KeyInformation buffer.
|
||||
* @param KeyInformation
|
||||
* Pointer to a caller-allocated buffer that receives the requested information.
|
||||
* @param Length
|
||||
* Specifies the size, in bytes, of the KeyInformation buffer.
|
||||
* @param ResultLength
|
||||
* Pointer to a variable that receives the size, in bytes, of the requested key
|
||||
* information. If ZwQueryKey returns STATUS_SUCCESS, the variable contains the amount
|
||||
* of data returned. If ZwQueryKey returns STATUS_BUFFER_OVERFLOW or
|
||||
* STATUS_BUFFER_TOO_SMALL, you can use the value of the variable to determine the
|
||||
* required buffer size.
|
||||
* @return
|
||||
* ZwQueryKey returns STATUS_SUCCESS on success, or the appropriate error code on failure.
|
||||
*/
|
||||
public int ZwQueryKey(HANDLE KeyHandle, int KeyInformationClass,
|
||||
Structure KeyInformation, int Length, IntByReference ResultLength);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/* Copyright (c) 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.platform.win32.Wdm.KEY_BASIC_INFORMATION;
|
||||
import com.sun.jna.platform.win32.Wdm.KEY_INFORMATION_CLASS;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEY;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* NtDll Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class NtDllUtil {
|
||||
|
||||
/**
|
||||
* Retrieve the name of an opened registry key.
|
||||
* @param hkey Opened registry key.
|
||||
* @return Basic key name, not including node information.
|
||||
*/
|
||||
public static String getKeyName(HKEY hkey) {
|
||||
IntByReference resultLength = new IntByReference();
|
||||
int rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
|
||||
null, 0, resultLength);
|
||||
if (rc != NTStatus.STATUS_BUFFER_TOO_SMALL || resultLength.getValue() <= 0) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
KEY_BASIC_INFORMATION keyInformation = new KEY_BASIC_INFORMATION(
|
||||
resultLength.getValue());
|
||||
rc = NtDll.INSTANCE.ZwQueryKey(hkey, KEY_INFORMATION_CLASS.KeyBasicInformation,
|
||||
keyInformation, resultLength.getValue(), resultLength);
|
||||
if (rc != NTStatus.STATUS_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return keyInformation.getName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Ole32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Ole32 extends W32API {
|
||||
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
|
||||
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
|
||||
* @param pguid
|
||||
* A pointer to the requested GUID.
|
||||
* @return
|
||||
* S_OK if the GUID was successfully created.
|
||||
*/
|
||||
HRESULT CoCreateGuid(GUID.ByReference pguid);
|
||||
|
||||
/**
|
||||
* Converts a globally unique identifier (GUID) into a string of printable characters.
|
||||
* @param rguid
|
||||
* The GUID to be converted.
|
||||
* @param lpsz
|
||||
* A pointer to a caller-allocated string variable to receive the resulting string.
|
||||
* @param cchMax
|
||||
* The number of characters available in the lpsz buffer.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of characters in the
|
||||
* returned string, including the null terminator. If the buffer is too small to contain
|
||||
* the string, the return value is 0.
|
||||
*/
|
||||
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromIID function back into the
|
||||
* original interface identifier (IID).
|
||||
* @param lpsz
|
||||
* A pointer to the string representation of the IID.
|
||||
* @param lpiid
|
||||
* A pointer to the requested IID on return.
|
||||
* @return
|
||||
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
|
||||
* and S_OK.
|
||||
*/
|
||||
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.W32API.HRESULT;
|
||||
|
||||
/**
|
||||
* Ole32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Ole32Util {
|
||||
|
||||
/**
|
||||
* Convert a string to a GUID.
|
||||
* @param guidString
|
||||
* String representation of a GUID, including { }.
|
||||
* @return
|
||||
* A GUID.
|
||||
*/
|
||||
public static GUID getGUIDFromString(String guidString) {
|
||||
GUID.ByReference lpiid = new GUID.ByReference();
|
||||
HRESULT hr = Ole32.INSTANCE.IIDFromString(guidString, lpiid);
|
||||
if (! hr.equals(W32Errors.S_OK)) {
|
||||
throw new RuntimeException(hr.toString());
|
||||
}
|
||||
return lpiid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a GUID into a string.
|
||||
* @param guid
|
||||
* GUID.
|
||||
* @return
|
||||
* String representation of a GUID.
|
||||
*/
|
||||
public static String getStringFromGUID(GUID guid) {
|
||||
GUID.ByReference pguid = new GUID.ByReference(guid.getPointer());
|
||||
int max = 39;
|
||||
char[] lpsz = new char[max];
|
||||
int len = Ole32.INSTANCE.StringFromGUID2(pguid, lpsz, max);
|
||||
if (len == 0) {
|
||||
throw new RuntimeException("StringFromGUID2");
|
||||
}
|
||||
lpsz[len - 1] = 0;
|
||||
return Native.toString(lpsz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new GUID.
|
||||
* @return
|
||||
* New GUID.
|
||||
*/
|
||||
public static GUID generateGUID() {
|
||||
GUID.ByReference pguid = new GUID.ByReference();
|
||||
HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
|
||||
if (! hr.equals(W32Errors.S_OK)) {
|
||||
throw new RuntimeException(hr.toString());
|
||||
}
|
||||
return pguid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Sspi.CredHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
|
||||
import com.sun.jna.platform.win32.Sspi.PSecHandle;
|
||||
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.LUID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Secur32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Secur32 extends W32API {
|
||||
Secur32 INSTANCE = (Secur32) Native.loadLibrary(
|
||||
"Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Specifies a format for a directory service object name.
|
||||
* http://msdn.microsoft.com/en-us/library/ms724268(VS.85).aspx
|
||||
*/
|
||||
public abstract class EXTENDED_NAME_FORMAT {
|
||||
public static final int NameUnknown = 0;
|
||||
public static final int NameFullyQualifiedDN = 1;
|
||||
public static final int NameSamCompatible = 2;
|
||||
public static final int NameDisplay = 3;
|
||||
public static final int NameUniqueId = 6;
|
||||
public static final int NameCanonical = 7;
|
||||
public static final int NameUserPrincipal = 8;
|
||||
public static final int NameCanonicalEx = 9;
|
||||
public static final int NameServicePrincipal = 10;
|
||||
public static final int NameDnsDomain = 12;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user or other security principal associated with
|
||||
* the calling thread. You can specify the format of the returned name.
|
||||
* @param nameFormat The format of the name.
|
||||
* @param lpNameBuffer A pointer to a buffer that receives the name in the specified format.
|
||||
* @param len On input, the size of the buffer, on output the number of characters copied into the buffer, not including the terminating null character.
|
||||
* @return True if the function succeeds. False otherwise.
|
||||
*/
|
||||
public boolean GetUserNameEx(int nameFormat, char[] lpNameBuffer, IntByReference len);
|
||||
|
||||
/**
|
||||
* The AcquireCredentialsHandle function acquires a handle to preexisting credentials
|
||||
* of a security principal. This handle is required by the AcceptSecurityContext
|
||||
* and InitializeSecurityContext functions. These can be either preexisting credentials,
|
||||
* which are established through a system logon that is not described here, or the
|
||||
* caller can provide alternative credentials.
|
||||
* @param pszPrincipal
|
||||
* A pointer to a null-terminated string that specifies the name of the principal whose
|
||||
* credentials the handle will reference.
|
||||
* @param pszPackage
|
||||
* A pointer to a null-terminated string that specifies the name of the security package
|
||||
* with which these credentials will be used.
|
||||
* @param fCredentialUse
|
||||
* A flag that indicates how these credentials will be used.
|
||||
* @param pvLogonID
|
||||
* A pointer to a locally unique identifier (LUID) that identifies the user.
|
||||
* @param pAuthData
|
||||
* A pointer to package-specific data. This parameter can be NULL, which indicates
|
||||
* that the default credentials for that package must be used. To use supplied
|
||||
* credentials, pass a SEC_WINNT_AUTH_IDENTITY structure that includes those credentials
|
||||
* in this parameter.
|
||||
* @param pGetKeyFn
|
||||
* This parameter is not used and should be set to NULL.
|
||||
* @param pvGetKeyArgument
|
||||
* This parameter is not used and should be set to NULL.
|
||||
* @param phCredential
|
||||
* A pointer to a CredHandle structure to receive the credential handle.
|
||||
* @param ptsExpiry
|
||||
* A pointer to a TimeStamp structure that receives the time at which the returned
|
||||
* credentials expire. The value returned in this TimeStamp structure depends on
|
||||
* the security package. The security package must return this value in local time.
|
||||
* @return
|
||||
* If the function succeeds, the function returns one of the SEC_I_ success codes.
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int AcquireCredentialsHandle(String pszPrincipal, String pszPackage,
|
||||
NativeLong fCredentialUse, LUID pvLogonID,
|
||||
Pointer pAuthData, Pointer pGetKeyFn, // TODO: SEC_GET_KEY_FN
|
||||
Pointer pvGetKeyArgument, CredHandle phCredential,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
* The InitializeSecurityContext function initiates the client side, outbound security
|
||||
* context from a credential handle. The function is used to build a security context
|
||||
* between the client application and a remote peer. InitializeSecurityContext returns
|
||||
* a token that the client must pass to the remote peer, which the peer in turn submits
|
||||
* to the local security implementation through the AcceptSecurityContext call. The
|
||||
* token generated should be considered opaque by all callers.
|
||||
*
|
||||
* Typically, the InitializeSecurityContext function is called in a loop until a
|
||||
* sufficient security context is established.
|
||||
*
|
||||
* @param phCredential
|
||||
* A handle to the credentials returned by AcquireCredentialsHandle. This handle is
|
||||
* used to build the security context. The InitializeSecurityContext function requires
|
||||
* at least OUTBOUND credentials.
|
||||
* @param phContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
|
||||
* this pointer is NULL. On the second call, this parameter is a pointer to the handle
|
||||
* to the partially formed context returned in the phNewContext parameter by the first
|
||||
* call.
|
||||
* @param pszTargetName
|
||||
* A pointer to a null-terminated string that indicates the target of the context.
|
||||
* The string contents are security-package specific.
|
||||
* @param fContextReq
|
||||
* Bit flags that indicate requests for the context. Not all packages can support all
|
||||
* requirements. Flags used for this parameter are prefixed with ISC_REQ_, for example,
|
||||
* ISC_REQ_DELEGATE.
|
||||
* @param Reserved1
|
||||
* This parameter is reserved and must be set to zero.
|
||||
* @param TargetDataRep
|
||||
* The data representation, such as byte ordering, on the target. This parameter can be
|
||||
* either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
|
||||
* @param pInput
|
||||
* A pointer to a SecBufferDesc structure that contains pointers to the buffers supplied
|
||||
* as input to the package. The pointer must be NULL on the first call to the function.
|
||||
* On subsequent calls to the function, it is a pointer to a buffer allocated with enough
|
||||
* memory to hold the token returned by the remote peer.
|
||||
* @param Reserved2
|
||||
* This parameter is reserved and must be set to zero.
|
||||
* @param phNewContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to InitializeSecurityContext,
|
||||
* this pointer receives the new context handle. On the second call, phNewContext can be
|
||||
* the same as the handle specified in the phContext parameter.
|
||||
* @param pOutput
|
||||
* A pointer to a SecBufferDesc structure that contains pointers to the SecBuffer structure
|
||||
* that receives the output data. If a buffer was typed as SEC_READWRITE in the input, it
|
||||
* will be there on output. The system will allocate a buffer for the security token if
|
||||
* requested (through ISC_REQ_ALLOCATE_MEMORY) and fill in the address in the buffer
|
||||
* descriptor for the security token.
|
||||
* @param pfContextAttr
|
||||
* A pointer to a variable to receive a set of bit flags that indicate the attributes of
|
||||
* the established context. Flags used for this parameter are prefixed with ISC_RET,
|
||||
* such as ISC_RET_DELEGATE.
|
||||
* @param ptsExpiry
|
||||
* A pointer to a TimeStamp structure that receives the expiration time of the context.
|
||||
* It is recommended that the security package always return this value in local time.
|
||||
* This parameter is optional and NULL should be passed for short-lived clients.
|
||||
* @return
|
||||
* If the function succeeds, the function returns one of the SEC_I_ success codes.
|
||||
* If the function fails, the function returns one of the SEC_E_ error codes.
|
||||
*/
|
||||
public int InitializeSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
String pszTargetName, NativeLong fContextReq, NativeLong Reserved1,
|
||||
NativeLong TargetDataRep, SecBufferDesc pInput, NativeLong Reserved2,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
TimeStamp ptsExpiry);
|
||||
|
||||
/**
|
||||
* The DeleteSecurityContext function deletes the local data structures associated
|
||||
* with the specified security context.
|
||||
* @param phContext
|
||||
* Handle of the security context to delete.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
|
||||
*/
|
||||
public int DeleteSecurityContext(CtxtHandle phContext);
|
||||
|
||||
/**
|
||||
* The FreeCredentialsHandle function notifies the security system that the
|
||||
* credentials are no longer needed. An application calls this function to free
|
||||
* the credential handle acquired in the call to the AcquireCredentialsHandle
|
||||
* function. When all references to this credential set have been removed, the
|
||||
* credentials themselves can be removed.
|
||||
* @param phCredential
|
||||
* A pointer to the credential handle obtained by using the AcquireCredentialsHandle
|
||||
* function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value is SEC_E_INVALID_HANDLE;
|
||||
*/
|
||||
public int FreeCredentialsHandle(CredHandle phCredential);
|
||||
|
||||
/**
|
||||
* The AcceptSecurityContext function enables the server component of a transport
|
||||
* application to establish a security context between the server and a remote client.
|
||||
* The remote client uses the InitializeSecurityContext function to start the process
|
||||
* of establishing a security context. The server can require one or more reply tokens
|
||||
* from the remote client to complete establishing the security context.
|
||||
* @param phCredential
|
||||
* A handle to the credentials of the server. The server calls the AcquireCredentialsHandle
|
||||
* function with either the SECPKG_CRED_INBOUND or SECPKG_CRED_BOTH flag set to retrieve
|
||||
* this handle.
|
||||
* @param phContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
|
||||
* this pointer is NULL. On subsequent calls, phContext is the handle to the partially
|
||||
* formed context that was returned in the phNewContext parameter by the first call.
|
||||
* @param pInput
|
||||
* A pointer to a SecBufferDesc structure generated by a client call to
|
||||
* InitializeSecurityContext that contains the input buffer descriptor.
|
||||
* @param fContextReq
|
||||
* Bit flags that specify the attributes required by the server to establish the
|
||||
* context. Bit flags can be combined by using bitwise-OR operations.
|
||||
* @param TargetDataRep
|
||||
* The data representation, such as byte ordering, on the target. This parameter can
|
||||
* be either SECURITY_NATIVE_DREP or SECURITY_NETWORK_DREP.
|
||||
* @param phNewContext
|
||||
* A pointer to a CtxtHandle structure. On the first call to AcceptSecurityContext,
|
||||
* this pointer receives the new context handle. On subsequent calls, phNewContext
|
||||
* can be the same as the handle specified in the phContext parameter.
|
||||
* @param pOutput
|
||||
* A pointer to a SecBufferDesc structure that contains the output buffer descriptor.
|
||||
* This buffer is sent to the client for input into additional calls to
|
||||
* InitializeSecurityContext. An output buffer may be generated even if the function
|
||||
* returns SEC_E_OK. Any buffer generated must be sent back to the client application.
|
||||
* @param pfContextAttr
|
||||
* A pointer to a variable that receives a set of bit flags that indicate the
|
||||
* attributes of the established context. For a description of the various attributes,
|
||||
* see Context Requirements. Flags used for this parameter are prefixed with ASC_RET,
|
||||
* for example, ASC_RET_DELEGATE.
|
||||
* @param ptsTimeStamp
|
||||
* A pointer to a TimeStamp structure that receives the expiration time of the context.
|
||||
* @return
|
||||
* This function returns one of SEC_* values.
|
||||
*/
|
||||
public int AcceptSecurityContext(CredHandle phCredential, CtxtHandle phContext,
|
||||
SecBufferDesc pInput, NativeLong fContextReq, NativeLong TargetDataRep,
|
||||
CtxtHandle phNewContext, SecBufferDesc pOutput, NativeLongByReference pfContextAttr,
|
||||
TimeStamp ptsTimeStamp);
|
||||
|
||||
/**
|
||||
* The EnumerateSecurityPackages function returns an array of SecPkgInfo structures that
|
||||
* describe the security packages available to the client.
|
||||
* @param pcPackages
|
||||
* A pointer to a ULONG variable that receives the number of packages returned.
|
||||
* @param ppPackageInfo
|
||||
* A pointer to a variable that receives a pointer to an array of SecPkgInfo structures.
|
||||
* Each structure contains information from the security support provider (SSP) that
|
||||
* describes a security package that is available within that SSP.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code.
|
||||
*/
|
||||
public int EnumerateSecurityPackages(IntByReference pcPackages,
|
||||
PSecPkgInfo.ByReference ppPackageInfo);
|
||||
|
||||
/**
|
||||
* The FreeContextBuffer function enables callers of security package functions to free a memory
|
||||
* buffer that was allocated by the security package as a result of calls to InitializeSecurityContext
|
||||
* and AcceptSecurityContext.
|
||||
* @param buffer
|
||||
* A pointer to memory allocated by the security package.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code.
|
||||
*/
|
||||
public int FreeContextBuffer(Pointer buffer);
|
||||
|
||||
/**
|
||||
* The QuerySecurityContextToken function obtains the access token for a client security context
|
||||
* and uses it directly.
|
||||
* @param phContext
|
||||
* Handle of the context to query.
|
||||
* @param phToken
|
||||
* Returned handle to the access token.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a nonzero error code. One possible error code return is
|
||||
* SEC_E_INVALID_HANDLE.
|
||||
*/
|
||||
public int QuerySecurityContextToken(PSecHandle phContext,
|
||||
HANDLEByReference phToken);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Sspi.PSecPkgInfo;
|
||||
import com.sun.jna.platform.win32.Sspi.SecPkgInfo;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* Secur32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Secur32Util {
|
||||
|
||||
/**
|
||||
* An SSPI package.
|
||||
*/
|
||||
public static class SecurityPackage {
|
||||
/**
|
||||
* Package name.
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* Package comment.
|
||||
*/
|
||||
public String comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name of the user or other security principal associated
|
||||
* with the calling thread.
|
||||
*
|
||||
* @param format User name format.
|
||||
* @return User name in a given format.
|
||||
*/
|
||||
public static String getUserNameEx(int format) {
|
||||
char[] buffer = new char[128];
|
||||
IntByReference len = new IntByReference(buffer.length);
|
||||
boolean result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
|
||||
|
||||
if (! result) {
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
switch(rc) {
|
||||
case W32Errors.ERROR_MORE_DATA:
|
||||
buffer = new char[len.getValue() + 1];
|
||||
break;
|
||||
default:
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
result = Secur32.INSTANCE.GetUserNameEx(format, buffer, len);
|
||||
}
|
||||
|
||||
if (! result) {
|
||||
throw new Win32Exception(Native.getLastError());
|
||||
}
|
||||
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the security packages installed on the current computer.
|
||||
* @return
|
||||
* An array of SSPI security packages.
|
||||
*/
|
||||
public static SecurityPackage[] getSecurityPackages() {
|
||||
IntByReference pcPackages = new IntByReference();
|
||||
PSecPkgInfo.ByReference pPackageInfo = new PSecPkgInfo.ByReference();
|
||||
int rc = Secur32.INSTANCE.EnumerateSecurityPackages(pcPackages, pPackageInfo);
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
SecPkgInfo.ByReference[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
|
||||
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
|
||||
for(SecPkgInfo.ByReference packageInfo : packagesInfo) {
|
||||
SecurityPackage securityPackage = new SecurityPackage();
|
||||
securityPackage.name = packageInfo.Name.toString();
|
||||
securityPackage.comment = packageInfo.Comment.toString();
|
||||
packages.add(securityPackage);
|
||||
}
|
||||
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.getPointer());
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return packages.toArray(new SecurityPackage[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Mapping for Shell32.dll API.
|
||||
*/
|
||||
public interface Shell32 extends W32API {
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/* 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.Native;
|
||||
import com.sun.jna.platform.win32.W32API.DWORD;
|
||||
import com.sun.jna.platform.win32.W32API.HRESULT;
|
||||
import com.sun.jna.platform.win32.W32API.HWND;
|
||||
|
||||
|
||||
/**
|
||||
* Shell32 Utility API.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Shell32Util {
|
||||
|
||||
/**
|
||||
* Get a special folder path.
|
||||
* @param hwnd
|
||||
* Parent window.
|
||||
* @param nFolder
|
||||
* Folder CSLID.
|
||||
* @param dwFlags
|
||||
* Flags.
|
||||
* @return
|
||||
* Special folder.
|
||||
*/
|
||||
public static String getFolderPath(HWND hwnd, int nFolder, DWORD dwFlags) {
|
||||
char[] pszPath = new char[WinDef.MAX_PATH];
|
||||
HRESULT hr = Shell32.INSTANCE.SHGetFolderPath(hwnd,
|
||||
nFolder, null, dwFlags,
|
||||
pszPath);
|
||||
if (! hr.equals(W32Errors.S_OK)) {
|
||||
throw new Win32Exception(hr);
|
||||
}
|
||||
return Native.toString(pszPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a special folder path.
|
||||
* @param nFolder
|
||||
* Folder CSLID.
|
||||
* @return
|
||||
* Special folder path.
|
||||
*/
|
||||
public static String getFolderPath(int nFolder) {
|
||||
return getFolderPath(null, nFolder, ShlObj.SHGFP_TYPE_CURRENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/* Copyright (c) 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.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLE;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from ShellAPI.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract interface ShellAPI extends StdCallLibrary {
|
||||
|
||||
int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE;
|
||||
|
||||
public static final int FO_MOVE = 0x0001;
|
||||
public static final int FO_COPY = 0x0002;
|
||||
public static final int FO_DELETE = 0x0003;
|
||||
public static final int FO_RENAME = 0x0004;
|
||||
|
||||
public static final int FOF_MULTIDESTFILES = 0x0001;
|
||||
public static final int FOF_CONFIRMMOUSE = 0x0002;
|
||||
public static final int FOF_SILENT = 0x0004; // don't display progress UI (confirm prompts may be displayed still)
|
||||
public static final int FOF_RENAMEONCOLLISION = 0x0008; // automatically rename the source files to avoid the collisions
|
||||
public static final int FOF_NOCONFIRMATION = 0x0010; // don't display confirmation UI, assume "yes" for cases that can be bypassed, "no" for those that can not
|
||||
public static final int FOF_WANTMAPPINGHANDLE = 0x0020; // Fill in SHFILEOPSTRUCT.hNameMappings
|
||||
public static final int FOF_ALLOWUNDO = 0x0040; // enable undo including Recycle behavior for IFileOperation::Delete()
|
||||
public static final int FOF_FILESONLY = 0x0080; // only operate on the files (non folders), both files and folders are assumed without this
|
||||
public static final int FOF_SIMPLEPROGRESS = 0x0100; // means don't show names of files
|
||||
public static final int FOF_NOCONFIRMMKDIR = 0x0200; // don't dispplay confirmatino UI before making any needed directories, assume "Yes" in these cases
|
||||
public static final int FOF_NOERRORUI = 0x0400; // don't put up error UI, other UI may be displayed, progress, confirmations
|
||||
public static final int FOF_NOCOPYSECURITYATTRIBS = 0x0800; // dont copy file security attributes (ACLs)
|
||||
public static final int FOF_NORECURSION = 0x1000; // don't recurse into directories for operations that would recurse
|
||||
public static final int FOF_NO_CONNECTED_ELEMENTS = 0x2000; // don't operate on connected elements ("xxx_files" folders that go with .htm files)
|
||||
public static final int FOF_WANTNUKEWARNING = 0x4000; // during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION)
|
||||
public static final int FOF_NORECURSEREPARSE = 0x8000; // deprecated; the operations engine always does the right thing on FolderLink objects (symlinks, reparse points, folder shortcuts)
|
||||
public static final int FOF_NO_UI = (FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR); // don't display any UI at all
|
||||
|
||||
public static final int PO_DELETE = 0x0013; // printer is being deleted
|
||||
public static final int PO_RENAME = 0x0014; // printer is being renamed
|
||||
public static final int PO_PORTCHANGE = 0x0020; // port this printer connected to is being changed
|
||||
public static final int PO_REN_PORT = 0x0034; // PO_RENAME and PO_PORTCHANGE at same time.
|
||||
|
||||
/**
|
||||
* Contains information that the SHFileOperation function uses to perform file operations.
|
||||
*/
|
||||
public static class SHFILEOPSTRUCT extends Structure {
|
||||
/**
|
||||
* A window handle to the dialog box to display information about
|
||||
* the status of the file operation.
|
||||
*/
|
||||
public HANDLE hwnd;
|
||||
/**
|
||||
* An FO_* value that indicates which operation to perform.
|
||||
*/
|
||||
public int wFunc;
|
||||
/**
|
||||
* A pointer to one or more source file names, double null-terminated.
|
||||
*/
|
||||
public WString pFrom;
|
||||
/**
|
||||
* A pointer to the destination file or directory name.
|
||||
*/
|
||||
public WString pTo;
|
||||
/**
|
||||
* Flags that control the file operation.
|
||||
*/
|
||||
public short fFlags;
|
||||
/**
|
||||
* When the function returns, this member contains TRUE if any file operations
|
||||
* were aborted before they were completed; otherwise, FALSE. An operation can
|
||||
* be manually aborted by the user through UI or it can be silently aborted by
|
||||
* the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set.
|
||||
*/
|
||||
public boolean fAnyOperationsAborted;
|
||||
/**
|
||||
* When the function returns, this member contains a handle to a name mapping
|
||||
* object that contains the old and new names of the renamed files. This member
|
||||
* is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag.
|
||||
*/
|
||||
public Pointer pNameMappings;
|
||||
/**
|
||||
* A pointer to the title of a progress dialog box. This is a null-terminated string.
|
||||
*/
|
||||
public WString lpszProgressTitle;
|
||||
|
||||
/** Use this to encode <code>pFrom/pTo</code> paths. */
|
||||
public String encodePaths(String[] paths) {
|
||||
String encoded = "";
|
||||
for (int i=0; i < paths.length;i++) {
|
||||
encoded += paths[i];
|
||||
encoded += "\0";
|
||||
}
|
||||
return encoded + "\0";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/* 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.platform.win32.W32API.DWORD;
|
||||
|
||||
/**
|
||||
* Ported from ShlObj.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class ShlObj {
|
||||
|
||||
public static final DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
|
||||
public static final DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
|
||||
|
||||
public static final int CSIDL_DESKTOP = 0x0000; // <desktop>
|
||||
public static final int CSIDL_INTERNET = 0x0001; // Internet Explorer (icon on desktop)
|
||||
public static final int CSIDL_PROGRAMS = 0x0002; // Start Menu\Programs
|
||||
public static final int CSIDL_CONTROLS = 0x0003; // My Computer\Control Panel
|
||||
public static final int CSIDL_PRINTERS = 0x0004; // My Computer\Printers
|
||||
public static final int CSIDL_PERSONAL = 0x0005; // My Documents
|
||||
public static final int CSIDL_FAVORITES = 0x0006; // <user name>\Favorites
|
||||
public static final int CSIDL_STARTUP = 0x0007; // Start Menu\Programs\Startup
|
||||
public static final int CSIDL_RECENT = 0x0008; // <user name>\Recent
|
||||
public static final int CSIDL_SENDTO = 0x0009; // <user name>\SendTo
|
||||
public static final int CSIDL_BITBUCKET = 0x000a; // <desktop>\Recycle Bin
|
||||
public static final int CSIDL_STARTMENU = 0x000b; // <user name>\Start Menu
|
||||
public static final int CSIDL_MYDOCUMENTS = CSIDL_PERSONAL; // Personal was just a silly name for My Documents
|
||||
public static final int CSIDL_MYMUSIC = 0x000d; // "My Music" folder
|
||||
public static final int CSIDL_MYVIDEO = 0x000e; // "My Videos" folder
|
||||
public static final int CSIDL_DESKTOPDIRECTORY = 0x0010; // <user name>\Desktop
|
||||
public static final int CSIDL_DRIVES = 0x0011; // My Computer
|
||||
public static final int CSIDL_NETWORK = 0x0012; // Network Neighborhood (My Network Places)
|
||||
public static final int CSIDL_NETHOOD = 0x0013; // <user name>\nethood
|
||||
public static final int CSIDL_FONTS = 0x0014; // windows\fonts
|
||||
public static final int CSIDL_TEMPLATES = 0x0015;
|
||||
public static final int CSIDL_COMMON_STARTMENU = 0x0016; // All Users\Start Menu
|
||||
public static final int CSIDL_COMMON_PROGRAMS = 0X0017; // All Users\Start Menu\Programs
|
||||
public static final int CSIDL_COMMON_STARTUP = 0x0018; // All Users\Startup
|
||||
public static final int CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019; // All Users\Desktop
|
||||
public static final int CSIDL_APPDATA = 0x001a; // <user name>\Application Data
|
||||
public static final int CSIDL_PRINTHOOD = 0x001b; // <user name>\PrintHood
|
||||
public static final int CSIDL_LOCAL_APPDATA = 0x001c; // <user name>\Local Settings\Applicaiton Data (non roaming)
|
||||
public static final int CSIDL_ALTSTARTUP = 0x001d; // non localized startup
|
||||
public static final int CSIDL_COMMON_ALTSTARTUP = 0x001e; // non localized common startup
|
||||
public static final int CSIDL_COMMON_FAVORITES = 0x001f;
|
||||
public static final int CSIDL_INTERNET_CACHE = 0x0020;
|
||||
public static final int CSIDL_COOKIES = 0x0021;
|
||||
public static final int CSIDL_HISTORY = 0x0022;
|
||||
public static final int CSIDL_COMMON_APPDATA = 0x0023; // All Users\Application Data
|
||||
public static final int CSIDL_WINDOWS = 0x0024; // GetWindowsDirectory()
|
||||
public static final int CSIDL_SYSTEM = 0x0025; // GetSystemDirectory()
|
||||
public static final int CSIDL_PROGRAM_FILES = 0x0026; // C:\Program Files
|
||||
public static final int CSIDL_MYPICTURES = 0x0027; // C:\Program Files\My Pictures
|
||||
public static final int CSIDL_PROFILE = 0x0028; // USERPROFILE
|
||||
public static final int CSIDL_SYSTEMX86 = 0x0029; // x86 system directory on RISC
|
||||
public static final int CSIDL_PROGRAM_FILESX86 = 0x002a; // x86 C:\Program Files on RISC
|
||||
public static final int CSIDL_PROGRAM_FILES_COMMON = 0x002b; // C:\Program Files\Common
|
||||
public static final int CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c; // x86 Program Files\Common on RISC
|
||||
public static final int CSIDL_COMMON_TEMPLATES = 0x002d; // All Users\Templates
|
||||
public static final int CSIDL_COMMON_DOCUMENTS = 0x002e; // All Users\Documents
|
||||
public static final int CSIDL_COMMON_ADMINTOOLS = 0x002f; // All Users\Start Menu\Programs\Administrative Tools
|
||||
public static final int CSIDL_ADMINTOOLS = 0x0030; // <user name>\Start Menu\Programs\Administrative Tools
|
||||
public static final int CSIDL_CONNECTIONS = 0x0031; // Network and Dial-up Connections
|
||||
public static final int CSIDL_COMMON_MUSIC = 0x0035; // All Users\My Music
|
||||
public static final int CSIDL_COMMON_PICTURES = 0x0036; // All Users\My Pictures
|
||||
public static final int CSIDL_COMMON_VIDEO = 0x0037; // All Users\My Video
|
||||
public static final int CSIDL_RESOURCES = 0x0038; // Resource Direcotry
|
||||
public static final int CSIDL_RESOURCES_LOCALIZED = 0x0039; // Localized Resource Direcotry
|
||||
public static final int CSIDL_COMMON_OEM_LINKS = 0x003a; // Links to All Users OEM specific apps
|
||||
public static final int CSIDL_CDBURN_AREA = 0x003b; // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning
|
||||
public static final int CSIDL_COMPUTERSNEARME = 0x003d; // Computers Near Me (computered from Workgroup membership)
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
/* 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.Memory;
|
||||
import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
|
||||
/**
|
||||
* Ported from Sspi.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Sspi {
|
||||
|
||||
/**
|
||||
* Maximum size in bytes of a security token.
|
||||
*/
|
||||
public static final int MAX_TOKEN_SIZE = 12288;
|
||||
|
||||
// Flags for the fCredentialUse parameter of AcquireCredentialsHandle
|
||||
|
||||
/**
|
||||
* Validate an incoming server credential. Inbound credentials might be validated
|
||||
* by using an authenticating authority when InitializeSecurityContext or
|
||||
* AcceptSecurityContext is called. If such an authority is not available, the function will
|
||||
* fail and return SEC_E_NO_AUTHENTICATING_AUTHORITY. Validation is package specific.
|
||||
*/
|
||||
public static final int SECPKG_CRED_INBOUND = 1;
|
||||
|
||||
/**
|
||||
* Allow a local client credential to prepare an outgoing token.
|
||||
*/
|
||||
public static final int SECPKG_CRED_OUTBOUND = 2;
|
||||
|
||||
|
||||
// Flags for the TargetDataRep parameter of AcceptSecurityContext and InitializeSecurityContext
|
||||
|
||||
/**
|
||||
* Specifies Native data representation.
|
||||
*/
|
||||
public static final int SECURITY_NATIVE_DREP = 0x10;
|
||||
|
||||
|
||||
// Flags for the fContextReq parameter of InitializeSecurityContext or AcceptSecurityContext.
|
||||
|
||||
/**
|
||||
* The security package allocates output buffers for you.
|
||||
* When you have finished using the output buffers, free them by calling the FreeContextBuffer function.
|
||||
*/
|
||||
public static final int ISC_REQ_ALLOCATE_MEMORY = 0x00000100;
|
||||
|
||||
/**
|
||||
* Encrypt messages by using the EncryptMessage function.
|
||||
*/
|
||||
public static final int ISC_REQ_CONFIDENTIALITY = 0x00000010;
|
||||
|
||||
/**
|
||||
* The security context will not handle formatting messages. This value is the default.
|
||||
*/
|
||||
public static final int ISC_REQ_CONNECTION = 0x00000800;
|
||||
|
||||
/**
|
||||
* The server can use the context to authenticate to other servers as the client.
|
||||
* The ISC_REQ_MUTUAL_AUTH flag must be set for this flag to work. Valid for Kerberos.
|
||||
* Ignore this flag for constrained delegation.
|
||||
*/
|
||||
public static final int ISC_REQ_DELEGATE = 0x00000001;
|
||||
|
||||
/**
|
||||
* When errors occur, the remote party will be notified.
|
||||
*/
|
||||
public static final int ISC_REQ_EXTENDED_ERROR = 0x00004000;
|
||||
|
||||
/**
|
||||
* Sign messages and verify signatures by using the EncryptMessage and MakeSignature functions.
|
||||
*/
|
||||
public static final int ISC_REQ_INTEGRITY = 0x00010000;
|
||||
|
||||
/**
|
||||
* The mutual authentication policy of the service will be satisfied.
|
||||
*/
|
||||
public static final int ISC_REQ_MUTUAL_AUTH = 0x00000002;
|
||||
|
||||
/**
|
||||
* Detect replayed messages that have been encoded by using the
|
||||
* EncryptMessage or MakeSignature functions.
|
||||
*/
|
||||
public static final int ISC_REQ_REPLAY_DETECT = 0x00000004;
|
||||
|
||||
/**
|
||||
* Detect messages received out of sequence.
|
||||
*/
|
||||
public static final int ISC_REQ_SEQUENCE_DETECT = 0x00000008;
|
||||
|
||||
/**
|
||||
* Support a stream-oriented connection.
|
||||
*/
|
||||
public static final int ISC_REQ_STREAM = 0x00008000;
|
||||
|
||||
/**
|
||||
* Version of the SecBuffer struct.
|
||||
*/
|
||||
public static final int SECBUFFER_VERSION = 0;
|
||||
|
||||
/**
|
||||
* This is a placeholder in the buffer array.
|
||||
*/
|
||||
public static final int SECBUFFER_EMPTY = 0;
|
||||
/**
|
||||
* This buffer type is used for common data. The security package can read
|
||||
* and write this data.
|
||||
*/
|
||||
public static final int SECBUFFER_DATA = 1;
|
||||
/**
|
||||
* This buffer type is used to indicate the security token portion of the message.
|
||||
* This is read-only for input parameters or read/write for output parameters.
|
||||
*/
|
||||
public static final int SECBUFFER_TOKEN = 2;
|
||||
|
||||
/**
|
||||
* Security handle.
|
||||
*/
|
||||
public static class SecHandle extends Structure {
|
||||
public Pointer dwLower;
|
||||
public Pointer dwUpper;
|
||||
|
||||
public static class ByReference extends SecHandle implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An empty SecHandle.
|
||||
*/
|
||||
public SecHandle() {
|
||||
dwLower = null;
|
||||
dwUpper = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the handle is NULL.
|
||||
* @return
|
||||
* True if NULL, False otherwise.
|
||||
*/
|
||||
public boolean isNull() {
|
||||
return dwLower == null && dwUpper == null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A pointer to a SecHandle
|
||||
*/
|
||||
public static class PSecHandle extends Structure {
|
||||
|
||||
public static class ByReference extends PSecHandle implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first entry in an array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecHandle.ByReference secHandle;
|
||||
|
||||
public PSecHandle() {
|
||||
|
||||
}
|
||||
|
||||
public PSecHandle(SecHandle h) {
|
||||
useMemory(h.getPointer());
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Credentials handle.
|
||||
*/
|
||||
public static class CredHandle extends SecHandle {
|
||||
}
|
||||
|
||||
/**
|
||||
* Security context handle.
|
||||
*/
|
||||
public static class CtxtHandle extends SecHandle {
|
||||
}
|
||||
|
||||
/**
|
||||
* The SecBuffer structure describes a buffer allocated by a transport application
|
||||
* to pass to a security package.
|
||||
*/
|
||||
public static class SecBuffer extends Structure {
|
||||
|
||||
/**
|
||||
* A ByReference SecBuffer.
|
||||
*/
|
||||
public static class ByReference extends SecBuffer implements Structure.ByReference {
|
||||
/**
|
||||
* Create a SECBUFFER_EMPTY SecBuffer.
|
||||
*/
|
||||
public ByReference() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SecBuffer of a given type and size.
|
||||
* @param type
|
||||
* Buffer type, one of SECBUFFER_EMTPY, etc.
|
||||
* @param size
|
||||
* Buffer size, eg. MAX_TOKEN_SIZE.
|
||||
*/
|
||||
public ByReference(int type, int size) {
|
||||
super(type, size);
|
||||
}
|
||||
|
||||
public ByReference(int type, byte[] token) {
|
||||
super(type, token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buffer bytes.
|
||||
* @return
|
||||
* Raw buffer bytes.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return super.getBytes();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the size, in bytes, of the buffer pointed to by the pvBuffer member.
|
||||
*/
|
||||
public NativeLong cbBuffer;
|
||||
/**
|
||||
* Bit flags that indicate the type of buffer. Must be one of the values of
|
||||
* the SecBufferType enumeration.
|
||||
*/
|
||||
public NativeLong BufferType;
|
||||
/**
|
||||
* A pointer to a buffer.
|
||||
*/
|
||||
public Pointer pvBuffer;
|
||||
|
||||
/**
|
||||
* Create a new SECBUFFER_EMPTY buffer.
|
||||
*/
|
||||
public SecBuffer() {
|
||||
cbBuffer = new NativeLong(0);
|
||||
pvBuffer = null;
|
||||
BufferType = new NativeLong(SECBUFFER_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SecBuffer of a given type and size.
|
||||
* @param type
|
||||
* Buffer type, one of SECBUFFER_EMTPY, etc.
|
||||
* @param size
|
||||
* Buffer size, eg. MAX_TOKEN_SIZE.
|
||||
*/
|
||||
public SecBuffer(int type, int size) {
|
||||
cbBuffer = new NativeLong(size);
|
||||
pvBuffer = new Memory(size);
|
||||
BufferType = new NativeLong(type);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SecBuffer of a given type with initial data.
|
||||
* @param type
|
||||
* Buffer type, one of SECBUFFER_EMTPY, etc.
|
||||
* @param token
|
||||
* Existing token.
|
||||
*/
|
||||
public SecBuffer(int type, byte[] token) {
|
||||
cbBuffer = new NativeLong(token.length);
|
||||
pvBuffer = new Memory(token.length);
|
||||
pvBuffer.write(0, token, 0, token.length);
|
||||
BufferType = new NativeLong(type);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buffer bytes.
|
||||
* @return
|
||||
* Raw buffer bytes.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return pvBuffer.getByteArray(0, cbBuffer.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static class SecBufferDesc extends Structure {
|
||||
|
||||
/**
|
||||
* Version number.
|
||||
*/
|
||||
public NativeLong ulVersion;
|
||||
/**
|
||||
* Number of buffers.
|
||||
*/
|
||||
public NativeLong cBuffers;
|
||||
/**
|
||||
* Pointer to array of buffers.
|
||||
*/
|
||||
public SecBuffer.ByReference[] pBuffers;
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with one SECBUFFER_EMPTY buffer.
|
||||
*/
|
||||
public SecBufferDesc() {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference();
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with initial data.
|
||||
* @param type
|
||||
* Token type.
|
||||
* @param token
|
||||
* Initial token data.
|
||||
*/
|
||||
public SecBufferDesc(int type, byte[] token) {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, token);
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new SecBufferDesc with one SecBuffer of a given type and size.
|
||||
* @param type
|
||||
* @param tokenSize
|
||||
*/
|
||||
public SecBufferDesc(int type, int tokenSize) {
|
||||
ulVersion = new NativeLong(SECBUFFER_VERSION);
|
||||
cBuffers = new NativeLong(1);
|
||||
SecBuffer.ByReference secBuffer = new SecBuffer.ByReference(type, tokenSize);
|
||||
pBuffers = (SecBuffer.ByReference[]) secBuffer.toArray(1);
|
||||
allocateMemory();
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
if (pBuffers == null || cBuffers == null) {
|
||||
throw new RuntimeException("pBuffers | cBuffers");
|
||||
}
|
||||
if (cBuffers.intValue() == 1) {
|
||||
return pBuffers[0].getBytes();
|
||||
}
|
||||
throw new RuntimeException("cBuffers > 1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A security integer.
|
||||
*/
|
||||
public static class SECURITY_INTEGER extends Structure {
|
||||
public NativeLong dwLower;
|
||||
public NativeLong dwUpper;
|
||||
|
||||
/**
|
||||
* An security integer of 0.
|
||||
*/
|
||||
public SECURITY_INTEGER() {
|
||||
dwLower = new NativeLong(0);
|
||||
dwUpper = new NativeLong(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A timestamp.
|
||||
*/
|
||||
public static class TimeStamp extends SECURITY_INTEGER {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A pointer to an array of SecPkgInfo structures.
|
||||
*/
|
||||
public static class PSecPkgInfo extends Structure {
|
||||
|
||||
public static class ByReference extends PSecPkgInfo implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The first entry in an array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecPkgInfo.ByReference pPkgInfo;
|
||||
|
||||
public PSecPkgInfo() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of SecPkgInfo structures.
|
||||
*/
|
||||
public SecPkgInfo.ByReference[] toArray(int size) {
|
||||
return (SecPkgInfo.ByReference[]) pPkgInfo.toArray(size);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The SecPkgInfo structure provides general information about a security package,
|
||||
* such as its name and capabilities.
|
||||
*/
|
||||
public static class SecPkgInfo extends Structure {
|
||||
|
||||
/**
|
||||
* A reference pointer to a SecPkgInfo structure.
|
||||
*/
|
||||
public static class ByReference extends SecPkgInfo implements Structure.ByReference {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set of bit flags that describes the capabilities of the security package.
|
||||
*/
|
||||
public NativeLong fCapabilities;
|
||||
/**
|
||||
* Specifies the version of the package protocol. Must be 1.
|
||||
*/
|
||||
public short wVersion;
|
||||
/**
|
||||
* Specifies a DCE RPC identifier, if appropriate. If the package does not implement one of
|
||||
* the DCE registered security systems, the reserved value SECPKG_ID_NONE is used.
|
||||
*/
|
||||
public short wRPCID;
|
||||
/**
|
||||
* Specifies the maximum size, in bytes, of the token.
|
||||
*/
|
||||
public NativeLong cbMaxToken;
|
||||
/**
|
||||
* Pointer to a null-terminated string that contains the name of the security package.
|
||||
*/
|
||||
public WString Name;
|
||||
/**
|
||||
* Pointer to a null-terminated string. This can be any additional string passed
|
||||
* back by the package.
|
||||
*/
|
||||
public WString Comment;
|
||||
|
||||
/**
|
||||
* Create a new package info.
|
||||
*/
|
||||
public SecPkgInfo() {
|
||||
fCapabilities = new NativeLong(0);
|
||||
wVersion = 1;
|
||||
wRPCID = 0;
|
||||
cbMaxToken = new NativeLong(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-8
@@ -10,14 +10,13 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.win32;
|
||||
|
||||
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.examples.win32.GDI32.RECT;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Provides access to the w32 user32 library.
|
||||
* Incomplete implementation to support demos.
|
||||
@@ -28,7 +27,7 @@ import com.sun.jna.ptr.IntByReference;
|
||||
public interface User32 extends W32API {
|
||||
|
||||
User32 INSTANCE = (User32)
|
||||
Native.loadLibrary("user32", User32.class, DEFAULT_OPTIONS);
|
||||
Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
HDC GetDC(HWND hWnd);
|
||||
int ReleaseDC(HWND hWnd, HDC hDC);
|
||||
@@ -81,14 +80,14 @@ public interface User32 extends W32API {
|
||||
public HWND hwndMenuOwner;
|
||||
public HWND hwndMoveSize;
|
||||
public HWND hwndCaret;
|
||||
public RECT rcCaret;
|
||||
public GDI32.RECT rcCaret;
|
||||
}
|
||||
boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
|
||||
|
||||
class WINDOWINFO extends Structure {
|
||||
public int cbSize = size();
|
||||
public RECT rcWindow;
|
||||
public RECT rcClient;
|
||||
public GDI32.RECT rcWindow;
|
||||
public GDI32.RECT rcClient;
|
||||
public int dwStyle;
|
||||
public int dwExStyle;
|
||||
public int dwWindowStatus;
|
||||
@@ -98,7 +97,7 @@ public interface User32 extends W32API {
|
||||
public short wCreatorVersion;
|
||||
}
|
||||
boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi);
|
||||
boolean GetWindowRect(HWND hWnd, RECT rect);
|
||||
boolean GetWindowRect(HWND hWnd, GDI32.RECT rect);
|
||||
/** ASCII version. */
|
||||
int GetWindowText(HWND hWnd, byte[] lpString, int nMaxCount);
|
||||
/** Unicode version. */
|
||||
+36
-30
@@ -10,10 +10,7 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.examples.win32;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.FromNativeContext;
|
||||
import com.sun.jna.IntegerType;
|
||||
@@ -23,35 +20,18 @@ import com.sun.jna.Pointer;
|
||||
import com.sun.jna.PointerType;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIFunctionMapper;
|
||||
import com.sun.jna.win32.W32APITypeMapper;
|
||||
|
||||
/** Base type for most W32 API libraries. Provides standard options
|
||||
* for unicode/ASCII mappings. Set the system property <code>w32.ascii</code>
|
||||
* to <code>true</code> to default to the ASCII mappings.
|
||||
*/
|
||||
public interface W32API extends StdCallLibrary, W32Errors {
|
||||
|
||||
/** Standard options to use the unicode version of a w32 API. */
|
||||
Map UNICODE_OPTIONS = new HashMap() {
|
||||
{
|
||||
put(OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE);
|
||||
put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE);
|
||||
}
|
||||
};
|
||||
/** Standard options to use the ASCII/MBCS version of a w32 API. */
|
||||
Map ASCII_OPTIONS = new HashMap() {
|
||||
{
|
||||
put(OPTION_TYPE_MAPPER, W32APITypeMapper.ASCII);
|
||||
put(OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.ASCII);
|
||||
}
|
||||
};
|
||||
Map DEFAULT_OPTIONS = Boolean.getBoolean("w32.ascii") ? ASCII_OPTIONS : UNICODE_OPTIONS;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public interface W32API extends StdCallLibrary {
|
||||
class HANDLE extends PointerType {
|
||||
private boolean immutable;
|
||||
public HANDLE() { }
|
||||
public HANDLE(Pointer p) { setPointer(p); immutable = true; }
|
||||
|
||||
/** Override to the appropriate object for INVALID_HANDLE_VALUE. */
|
||||
public Object fromNative(Object nativeValue, FromNativeContext context) {
|
||||
Object o = super.fromNative(nativeValue, context);
|
||||
@@ -59,6 +39,7 @@ public interface W32API extends StdCallLibrary, W32Errors {
|
||||
return INVALID_HANDLE_VALUE;
|
||||
return o;
|
||||
}
|
||||
|
||||
public void setPointer(Pointer p) {
|
||||
if (immutable)
|
||||
throw new UnsupportedOperationException("immutable reference");
|
||||
@@ -66,15 +47,17 @@ public interface W32API extends StdCallLibrary, W32Errors {
|
||||
}
|
||||
}
|
||||
|
||||
class WORD extends IntegerType {
|
||||
class WORD extends IntegerType {
|
||||
public WORD() { this(0); }
|
||||
public WORD(long value) { super(2, value); }
|
||||
}
|
||||
class DWORD extends IntegerType {
|
||||
|
||||
class DWORD extends IntegerType {
|
||||
public DWORD() { this(0); }
|
||||
public DWORD(long value) { super(4, value); }
|
||||
}
|
||||
class LONG extends IntegerType {
|
||||
|
||||
class LONG extends IntegerType {
|
||||
public LONG() { this(0); }
|
||||
public LONG(long value) { super(Native.LONG_SIZE, value); }
|
||||
}
|
||||
@@ -89,26 +72,42 @@ public interface W32API extends StdCallLibrary, W32Errors {
|
||||
}
|
||||
class HINSTANCE extends HANDLE { }
|
||||
class HMODULE extends HINSTANCE { }
|
||||
class HRESULT extends NativeLong { }
|
||||
|
||||
/**
|
||||
* The HRESULT data type is a 32-bit value is used to describe an error or warning.
|
||||
*/
|
||||
class HRESULT extends NativeLong {
|
||||
public HRESULT() {
|
||||
|
||||
}
|
||||
|
||||
public HRESULT(int value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
||||
/** Constant value representing an invalid HANDLE. */
|
||||
HANDLE INVALID_HANDLE_VALUE = new HANDLE(Pointer.createConstant(-1));
|
||||
HANDLE INVALID_HANDLE_VALUE = new HANDLE(Pointer.createConstant(Pointer.SIZE==8?-1:0xFFFFFFFFL));
|
||||
|
||||
/** Special HWND value. */
|
||||
HWND HWND_BROADCAST = new HWND(Pointer.createConstant(0xFFFF));
|
||||
|
||||
/** LPHANDLE */
|
||||
class HANDLEByReference extends ByReference {
|
||||
public HANDLEByReference() {
|
||||
|
||||
public HANDLEByReference() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public HANDLEByReference(HANDLE h) {
|
||||
super(Pointer.SIZE);
|
||||
setValue(h);
|
||||
}
|
||||
|
||||
public void setValue(HANDLE h) {
|
||||
getPointer().setPointer(0, h != null ? h.getPointer() : null);
|
||||
}
|
||||
|
||||
public HANDLE getValue() {
|
||||
Pointer p = getPointer().getPointer(0);
|
||||
if (p == null)
|
||||
@@ -125,31 +124,38 @@ public interface W32API extends StdCallLibrary, W32Errors {
|
||||
public LONG_PTR() { this(0); }
|
||||
public LONG_PTR(long value) { super(Pointer.SIZE, value); }
|
||||
}
|
||||
|
||||
class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() { this(0); }
|
||||
public SSIZE_T(long value) { super(value); }
|
||||
}
|
||||
|
||||
class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() { this(0); }
|
||||
public ULONG_PTR(long value) { super(Pointer.SIZE, value); }
|
||||
}
|
||||
|
||||
class SIZE_T extends ULONG_PTR {
|
||||
public SIZE_T() { this(0); }
|
||||
public SIZE_T(long value) { super(value); }
|
||||
}
|
||||
|
||||
class LPARAM extends LONG_PTR {
|
||||
public LPARAM() { this(0); }
|
||||
public LPARAM(long value) { super(value); }
|
||||
}
|
||||
|
||||
class LRESULT extends LONG_PTR {
|
||||
public LRESULT() { this(0); }
|
||||
public LRESULT(long value) { super(value); }
|
||||
}
|
||||
|
||||
class UINT_PTR extends IntegerType {
|
||||
public UINT_PTR() { super(Pointer.SIZE); }
|
||||
public UINT_PTR(long value) { super(Pointer.SIZE, value); }
|
||||
public Pointer toPointer() { return Pointer.createConstant(longValue()); }
|
||||
}
|
||||
|
||||
class WPARAM extends UINT_PTR {
|
||||
public WPARAM() { this(0); }
|
||||
public WPARAM(long value) { super(value); }
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais
Referência em uma Nova Issue
Bloquear um usuário