Comparar commits
129 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| b7fb1b7e5a | |||
| eb60877793 | |||
| 5907ce0a02 | |||
| 5a1d431e51 | |||
| 0552c4a001 | |||
| 96d017869a | |||
| ddc2688af8 | |||
| baa60b6198 | |||
| 8abdddf11a | |||
| 9141018b27 | |||
| 3370fecdf2 | |||
| 5e91f76f0f | |||
| 557b3e1c93 | |||
| 3f65e56ccd | |||
| 5bd2cba2c2 | |||
| 3de7eb58a7 | |||
| 41eb294ce6 | |||
| ba94f2ebe0 | |||
| 7912248950 | |||
| 5d27c255b3 | |||
| 80e86e3b83 | |||
| 3a759f1eea | |||
| a09e503f19 | |||
| da4524b05c | |||
| 1a98283709 | |||
| acca8c5ac9 | |||
| 55eabb84e4 | |||
| 90ba9fce2a | |||
| 76b3982ddd | |||
| c946f80d5b | |||
| 8d350c7d99 | |||
| 7cd7fb8d6c | |||
| b12e563340 | |||
| 9c0aadce1e | |||
| b8d538b1b4 | |||
| 0219cd71b9 | |||
| 899fcbdfcc | |||
| 79fed6e32f | |||
| 55263ca11d | |||
| fe1f4a3bac | |||
| dd4fda55b5 | |||
| 2aae506110 | |||
| aae54a6f41 | |||
| 89da58adec | |||
| 57ef003eb9 | |||
| d378a64096 | |||
| 58ac91bc10 | |||
| 97602c0bf8 | |||
| 8523c487c1 | |||
| 3580b58bf6 | |||
| 9b26a4d5ce | |||
| c43fc68bc8 | |||
| df07539331 | |||
| 563931750b | |||
| 6b090de7b1 | |||
| d8863ef95f | |||
| 36f9595ce7 | |||
| 48565e6305 | |||
| 3727f9583b | |||
| 4a6bbf0b3c | |||
| 7513a7157f | |||
| e7dbdb6ead | |||
| db5f101bfc | |||
| 3c06e8b6fd | |||
| 28f94cbd0b | |||
| 6f37cbd946 | |||
| 396281263b | |||
| a00e8ac201 | |||
| b1772a89c1 | |||
| 58f07ff045 | |||
| 12f99d4fc7 | |||
| 05da0a6877 | |||
| 46ce871f34 | |||
| 4b22c2f044 | |||
| 4014828eff | |||
| bc87a62d59 | |||
| f6862442d3 | |||
| bff7f57eb8 | |||
| e19024ca0d | |||
| 73997e4799 | |||
| ffa97aa438 | |||
| d08244dfd8 | |||
| 2e0d367045 | |||
| 0f1fb2e6a1 | |||
| 672e362ed8 | |||
| bcae16c441 | |||
| 19b8f5cb59 | |||
| 68b37156d8 | |||
| d9237b64c0 | |||
| da037b38e3 | |||
| 62f864f4ab | |||
| bf89f1d37d | |||
| 3dc986e609 | |||
| 2f5e874201 | |||
| 05291932f8 | |||
| 72aa450ecb | |||
| 926ea21fe0 | |||
| 657a077cdb | |||
| 9a90f56845 | |||
| 7d36e0d63b | |||
| 865d5ed7a1 | |||
| 9dd91ee17e | |||
| 425ea821d7 | |||
| bea5049a2f | |||
| eae1e34696 | |||
| e63b6b00bc | |||
| e5b3ed226b | |||
| d5ce354c87 | |||
| e280838989 | |||
| 2309054b1f | |||
| 9dcc44a76b | |||
| 7a417c6d3b | |||
| 425ab15ae1 | |||
| c75ff4f118 | |||
| 75d3dd19ec | |||
| 4cd556555e | |||
| feebe921af | |||
| 92929308bd | |||
| ca4f14b555 | |||
| a7bcfacbd9 | |||
| e097b4820d | |||
| 566ec7974c | |||
| c735d6c420 | |||
| cf54ca9551 | |||
| 9f1da1b562 | |||
| f5a3dbf82b | |||
| 89f83e796a | |||
| 977a9e49c5 | |||
| 7ee0a4b39f |
+5
-5
@@ -100,6 +100,11 @@
|
||||
|
||||
|
||||
# DONE
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc. (not useful)
|
||||
* check Structure "final" fields; should never write back to native memory
|
||||
* OSX ObjC access (see rococoa)
|
||||
* do Structure.write for any callback args
|
||||
@@ -259,11 +264,6 @@ int findNativeWindow(Window w);
|
||||
exception if the value is out of bounds).
|
||||
o when used as struct fields, could allow detection of field order by order
|
||||
of initialization (requires all-or-nothing usage, though)
|
||||
* Make a separate jar file for all OS-specific headers
|
||||
Maybe make interfaces per-header file (winbase, winnt, stdlib, etc),
|
||||
aggregated per-library (interface CLibrary extends stdlib, stdio, etc)
|
||||
(how useful would it really be, or is this just sorting legos?)
|
||||
o same for windowutils, fileutils, etc. (not useful)
|
||||
* StringBuffer/StringBuilder as mutable char*/wchar_t* argument
|
||||
NOTE: byte[]/char[] is probably better; it's trivial to convert to String
|
||||
and native code can't change the size anyway
|
||||
|
||||
+63
-33
@@ -22,7 +22,8 @@
|
||||
<property name="dynlink.native" value="false"/>
|
||||
<property name="native" location="native"/>
|
||||
<property name="src" location="src"/>
|
||||
<property name="contrib" location="contrib/src"/>
|
||||
<property name="platform.src" location="contrib/platform/src"/>
|
||||
<property name="contrib" location="contrib"/>
|
||||
<property name="dist" location="dist"/>
|
||||
<property name="test.src" location="test"/>
|
||||
<property name="doc" location="doc"/>
|
||||
@@ -30,21 +31,21 @@
|
||||
<property name="stylesheet" location="${javadoc}/doc/css/javadoc.css"/>
|
||||
<property name="vendor" value="JNA Development Team"/>
|
||||
<property name="copyright"
|
||||
value="Copyright &copy; 2007-2009 Timothy Wall. All Rights Reserved."/>
|
||||
value="Copyright &copy; 2007-2010 Timothy Wall. All Rights Reserved."/>
|
||||
<buildnumber/>
|
||||
<!-- JNA library release version -->
|
||||
<property name="jna.major" value="3"/>
|
||||
<property name="jna.minor" value="2"/>
|
||||
<property name="jna.revision" value="5"/>
|
||||
<property name="jna.minor" value="3"/>
|
||||
<property name="jna.revision" value="0"/>
|
||||
<property name="jna.build" value="${build.number}"/>
|
||||
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}"/>
|
||||
<!-- jnidispatch library release version -->
|
||||
<property name="jni.major" value="3"/>
|
||||
<property name="jni.minor" value="2"/>
|
||||
<property name="jni.revision" value="1"/>
|
||||
<property name="jni.minor" value="3"/>
|
||||
<property name="jni.revision" value="0"/>
|
||||
<property name="jni.build" value="${build.number}"/>
|
||||
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
|
||||
<property name="jni.md5" value="c870290c36c8d3fdf85db7c782febc3f"/>
|
||||
<property name="jni.md5" value="4c69bcf40b30785215211b5a5dad211e"/>
|
||||
<property name="spec.title" value="Java Native Access (JNA)"/>
|
||||
<property name="spec.vendor" value="${vendor}"/>
|
||||
<property name="spec.version" value="${jna.major}"/>
|
||||
@@ -139,7 +140,10 @@
|
||||
<condition property="jdk.home" value="${java.home}/..">
|
||||
<available file="${java.home}/../include"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="JAVA_HOME/java.home must be a JDK, not JRE"/>
|
||||
<condition property="jdk.home" value="/System/Library/Frameworks/JavaVM.framework/Home">
|
||||
<available file="/System/Library/Frameworks/JavaVM.framework/Headers"/>
|
||||
</condition>
|
||||
<fail unless="jdk.home" message="Can't find JNI headers (java.home=${java.home})"/>
|
||||
<condition property="libjsig"
|
||||
value="${java.home}/lib/${jre.arch}/libjsig.so" else="">
|
||||
<available file="${java.home}/lib/${jre.arch}/libjsig.so"/>
|
||||
@@ -187,6 +191,7 @@
|
||||
source="${compatibility}"
|
||||
target="${compatibility}"
|
||||
destdir="${classes}"
|
||||
includeantruntime="false"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${src}"/>
|
||||
</javac>
|
||||
@@ -231,11 +236,19 @@
|
||||
<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="contrib-jars" depends="jar" description="Build contrib jars">
|
||||
<subant target="jar">
|
||||
<property name="file.reference.jna.build" location="${build}"/>
|
||||
<property name="file.reference.jna.jar" location="${build}/${jar}"/>
|
||||
<property name="libs.junit.classpath" location="lib/junit.jar"/>
|
||||
<!-- platform.jar needs to be built first -->
|
||||
<fileset dir="${contrib}" includes="platform/build.xml" />
|
||||
<fileset dir="${contrib}" includes="*/build.xml" excludes="platform/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="javah" depends="compile">
|
||||
<javah classpath="${classes}" destdir="${build.native}" force="yes">
|
||||
<class name="com.sun.jna.Function"/>
|
||||
@@ -320,8 +333,8 @@
|
||||
<target name="native" depends="-setup,javah,-native-api-check,rsrc"
|
||||
description="Build native libraries. Use 'ant -DCC=xxx' to build using a compiler other than gcc">
|
||||
<property name="comment" value="# auto-generated by ant"/>
|
||||
<replaceregexp match="^VERSION=.*"
|
||||
replace="VERSION=${jni.version} ${comment}"
|
||||
<replaceregexp match="^JNA_JNI_VERSION=.*"
|
||||
replace="JNA_JNI_VERSION=${jni.version} ${comment}"
|
||||
file="native/Makefile" byline="true"/>
|
||||
<replaceregexp match="^CHECKSUM=.*"
|
||||
replace="CHECKSUM=${jni.md5} ${comment}"
|
||||
@@ -338,6 +351,10 @@
|
||||
<condition property="make.SDKROOT" value="SDKROOT=${SDKROOT}">
|
||||
<isset property="SDKROOT"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
|
||||
</condition>
|
||||
<condition property="make.SDKROOT"
|
||||
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
|
||||
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
|
||||
@@ -363,6 +380,7 @@
|
||||
<os name="OpenBSD"/>
|
||||
</or>
|
||||
</condition>
|
||||
|
||||
<!-- Default make program -->
|
||||
<property name="make" value="make"/>
|
||||
|
||||
@@ -377,7 +395,7 @@
|
||||
<arg value="${make.SDKROOT}"/>
|
||||
<arg value="${make.ARCH}"/>
|
||||
<arg value="${make.PATH}"/>
|
||||
<arg value="VERSION=${jni.version}"/>
|
||||
<arg value="JNA_JNI_VERSION=${jni.version}"/>
|
||||
<arg value="CHECKSUM=${jni.md5}"/>
|
||||
</exec>
|
||||
<mkdir dir="${classes}/com/sun/jna/${os.prefix}"/>
|
||||
@@ -408,6 +426,7 @@
|
||||
source="${test.compatibility}"
|
||||
target="${test.compatibility}"
|
||||
destdir="${test.classes}"
|
||||
includeantruntime="false"
|
||||
deprecation="on" debug="${debug}">
|
||||
<src path="${test.src}"/>
|
||||
</javac>
|
||||
@@ -431,7 +450,7 @@
|
||||
|
||||
<!-- When running tests from an IDE, be sure to set jna.library.path -->
|
||||
<!-- to where the test library (testlib) is found. -->
|
||||
<target name="test" depends="jar,compile-tests"
|
||||
<target name="test" depends="jar,contrib-jars,compile-tests"
|
||||
description="Run all unit tests">
|
||||
<property name="test.fork" value="yes"/>
|
||||
<property name="reports.junit" location="${reports}/junit"/>
|
||||
@@ -478,9 +497,6 @@
|
||||
</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"/>
|
||||
@@ -488,6 +504,9 @@
|
||||
<report todir="${reports.junit}"/>
|
||||
</junitreport>
|
||||
<echo>View test report in file://${reports.junit}/index.html</echo>
|
||||
<subant target="test">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml"/>
|
||||
</subant>
|
||||
<fail if="testfailure" unless="clover">One or more tests failed</fail>
|
||||
</target>
|
||||
|
||||
@@ -513,6 +532,14 @@
|
||||
</target>
|
||||
|
||||
<target name="javadoc" depends="-setup">
|
||||
<path id="javadoc.src.path">
|
||||
<path refid="src.path"/>
|
||||
<pathelement location="${platform.src}"/>
|
||||
</path>
|
||||
<path id="javadoc.compile.path">
|
||||
<path refid="compile.path"/>
|
||||
<pathelement location="${classes}"/>
|
||||
</path>
|
||||
<property name="header"
|
||||
value="<b>JNA API</><font size="-1"> ${jna.version}</font>"/>
|
||||
<property name="footer"
|
||||
@@ -521,10 +548,10 @@
|
||||
<mkdir dir="${javadoc}"/>
|
||||
<javadoc package="true"
|
||||
windowtitle="JNA API"
|
||||
sourcepathref="src.path"
|
||||
classpathref="compile.path"
|
||||
sourcepathref="javadoc.src.path"
|
||||
classpathref="javadoc.compile.path"
|
||||
maxmemory="256m"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32,com.sun.jna.exmaples.unix"
|
||||
packagenames="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.platform,com.sun.jna.platform.win32"
|
||||
overview="${src}/com/sun/jna/overview.html"
|
||||
destdir="${javadoc}">
|
||||
<!-- stylesheetfile="${stylesheet}" -->
|
||||
@@ -538,18 +565,21 @@
|
||||
<include name="com/sun/jna/**/*"/>
|
||||
</patternset>
|
||||
</packageset>
|
||||
<packageset dir="${platform.src}" defaultexcludes="yes">
|
||||
<patternset>
|
||||
<include name="com/sun/jna/platform/**/*"/>
|
||||
</patternset>
|
||||
</packageset>
|
||||
|
||||
<group title="Java Native Access" packages="com.sun.jna,com.sun.jna.ptr,com.sun.jna.types,com.sun.jna.win32"/>
|
||||
<group title="Platform Specific" packages="com.sun.jna.platform"/>
|
||||
<group title="Platform Utilities" packages="com.sun.jna.platform,com.sun.jna.platform.dnd"/>
|
||||
<group title="Platform Specific" packages="com.sun.jna.platform.*"/>
|
||||
|
||||
<arg value="-notimestamp"/>
|
||||
</javadoc>
|
||||
<subant target="javadoc">
|
||||
<fileset dir="${contrib}" includes="platform/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
<target name="dist" depends="jar,compile-tests,native,javadoc"
|
||||
<target name="dist" depends="jar,contrib-jars,compile-tests,native,javadoc"
|
||||
description="Build distribution files">
|
||||
<jar jarfile="${dist}/jna.jar" duplicate="preserve">
|
||||
<manifest>
|
||||
@@ -619,14 +649,13 @@
|
||||
</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">
|
||||
<zipfileset dir="." includes="build.xml,LICENSE.txt"/>
|
||||
<zipfileset dir="." includes="build.xml,pom.xml,LICENSE.txt"/>
|
||||
<zipfileset dir="${src}" includes="**/*.java" prefix="src"/>
|
||||
<zipfileset dir="${test.src}" includes="**/*.java" prefix="test"/>
|
||||
<zipfileset dir="${native}" excludes="libffi,libffi/**/*" prefix="native"/>
|
||||
<zipfileset dir="${native}" excludes="libffi,libffi/**/*,build,build/**/*" prefix="native"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java" prefix="contrib/platform"/>
|
||||
</zip>
|
||||
<!-- Full sources required to build and test everything -->
|
||||
@@ -640,6 +669,7 @@
|
||||
<!-- Sources package as required by maven -->
|
||||
<zip zipfile="${dist}/src-mvn.zip">
|
||||
<zipfileset dir="${src}" includes="**/*.java,**/*.html,**/*.png"/>
|
||||
<zipfileset dir="${contrib}/platform" includes="**/*.java"/>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
@@ -652,9 +682,9 @@
|
||||
<fileset dir="${javadoc}"/>
|
||||
<fileset dir="." includes="*~,**/*~"/>
|
||||
</delete>
|
||||
<subant target="clean">
|
||||
<fileset dir="${contrib}" includes="*/build.xml"/>
|
||||
</subant>
|
||||
<subant target="clean">
|
||||
<fileset dir="${contrib}" includes="*/build.xml"/>
|
||||
</subant>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
+17
-19
@@ -4,27 +4,24 @@
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../../dist"/>
|
||||
<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" />
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-alphamask.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.AlphaMaskDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
@@ -32,17 +29,18 @@
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
@@ -52,7 +50,7 @@
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
@@ -61,7 +59,7 @@
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
@@ -69,7 +67,7 @@
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
+24
-21
@@ -64,14 +64,16 @@ 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.platform.win32.WinGDI;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
// TODO: put this into a reasonable API; right now this is pretty much
|
||||
@@ -127,7 +129,7 @@ public class AlphaMaskDemo implements Runnable {
|
||||
|
||||
private com.sun.jna.Memory buffer;
|
||||
private int[] pixels;
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
private void updateX11(boolean a, boolean i) {
|
||||
X11 x11 = X11.INSTANCE;
|
||||
X11.Window win = X11.Window.None;
|
||||
Display dpy = x11.XOpenDisplay(null);
|
||||
@@ -230,9 +232,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
if (!alphaWindow.isDisplayable()) {
|
||||
alphaWindow.pack();
|
||||
hWnd = getHwnd(alphaWindow);
|
||||
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
|
||||
flags |= User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
|
||||
flags |= WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
Window parent = alphaWindow.getOwner();
|
||||
Point where = parent.getLocationOnScreen();
|
||||
where.translate(parent.getWidth(), 0);
|
||||
@@ -260,11 +262,11 @@ public class AlphaMaskDemo implements Runnable {
|
||||
bmi.bmiHeader.biHeight = h;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = GDI32.BI_RGB;
|
||||
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = w * h * 4;
|
||||
|
||||
PointerByReference ppbits = new PointerByReference();
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, GDI32.DIB_RGB_COLORS,
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi, WinGDI.DIB_RGB_COLORS,
|
||||
ppbits, null, 0);
|
||||
oldBitmap = gdi.SelectObject(memDC, hBitmap);
|
||||
Pointer pbits = ppbits.getValue();
|
||||
@@ -293,9 +295,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
POINT srcLoc = new POINT();
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, screenDC, loc, size, memDC, srcLoc,
|
||||
0, blend, User32.ULW_ALPHA);
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
finally {
|
||||
user.ReleaseDC(null, screenDC);
|
||||
@@ -309,9 +311,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
else if (a) {
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = (byte)(alpha * 255);
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, null, null, null, null, null,
|
||||
0, blend, User32.ULW_ALPHA);
|
||||
0, blend, WinUser.ULW_ALPHA);
|
||||
}
|
||||
|
||||
if (!alphaWindow.isVisible()) {
|
||||
@@ -386,8 +388,9 @@ public class AlphaMaskDemo implements Runnable {
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
|
||||
List list = Arrays.asList(transferFlavors);
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR)
|
||||
|| list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
@@ -424,8 +427,8 @@ public class AlphaMaskDemo implements Runnable {
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
|
||||
List files = (List)t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = (File)files.get(0);
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://" + f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
setImage(image);
|
||||
+5
-5
@@ -145,9 +145,10 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
JPanel p = new JPanel(new BorderLayout(8, 8));
|
||||
p.setBorder(new EmptyBorder(8, 8, 8, 8));
|
||||
p.setTransferHandler(new TransferHandler() {
|
||||
public boolean canImport(JComponent comp,
|
||||
private static final long serialVersionUID = 1L;
|
||||
public boolean canImport(JComponent comp,
|
||||
DataFlavor[] transferFlavors) {
|
||||
List list = Arrays.asList(transferFlavors);
|
||||
List<DataFlavor> list = Arrays.asList(transferFlavors);
|
||||
if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR)
|
||||
|| list.contains(DataFlavor.imageFlavor)
|
||||
|| list.contains(DataFlavor.javaFileListFlavor)) {
|
||||
@@ -185,9 +186,8 @@ public class AlphaMaskDemo2 implements Runnable {
|
||||
return true;
|
||||
}
|
||||
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
|
||||
List files = (List)t
|
||||
.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = (File)files.get(0);
|
||||
List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
|
||||
File f = files.get(0);
|
||||
URL url = new URL("file://"
|
||||
+ f.toURI().toURL().getPath());
|
||||
Image image = Toolkit.getDefaultToolkit().getImage(url);
|
||||
|
Antes Largura: | Altura: | Tamanho: 18 KiB Depois Largura: | Altura: | Tamanho: 18 KiB |
+16
-17
@@ -4,26 +4,24 @@
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../../dist"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloonmanager.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.BalloonManagerDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
@@ -31,17 +29,18 @@
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
@@ -51,7 +50,7 @@
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
@@ -60,7 +59,7 @@
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
@@ -68,7 +67,7 @@
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
+2
@@ -57,6 +57,7 @@ public class BalloonManager {
|
||||
}
|
||||
|
||||
private static class DropShadow extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final float SHADOW_ALPHA = .25f;
|
||||
private static final float YSCALE = .80f;
|
||||
private static final double ANGLE = 2*Math.PI/24;
|
||||
@@ -149,6 +150,7 @@ public class BalloonManager {
|
||||
}
|
||||
|
||||
private static final class BubbleWindow extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final int Y_OFFSET = 50;
|
||||
private static final int ARC = 25;
|
||||
|
||||
@@ -4,26 +4,24 @@
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../../dist"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-balloontips.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.FilteredTextField" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
@@ -31,17 +29,18 @@
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
@@ -51,7 +50,7 @@
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
@@ -60,7 +59,7 @@
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
@@ -68,7 +67,7 @@
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
+1
-3
@@ -62,6 +62,7 @@ public class BalloonTipManager {
|
||||
* The BalloonTip class defines the look of the BalloonTip object.
|
||||
*/
|
||||
private static final class BalloonTip extends JWindow {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Integer HMARGIN = 10;
|
||||
private static final Integer VMARGIN = 6;
|
||||
private static final Integer VSPACER = 4;
|
||||
@@ -475,7 +476,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned from moving the component.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class ComponentEar extends ComponentAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -490,7 +490,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned when a mouse button is pressed.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class MouseEar extends MouseAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -505,7 +504,6 @@ public class BalloonTipManager {
|
||||
/*
|
||||
* This class handles events spawned when the component loses focus.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
final class FocusEar extends FocusAdapter {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -4,26 +4,24 @@
|
||||
<!-- Locations -->
|
||||
<property name="src" location="."/>
|
||||
<property name="build" location="build"/>
|
||||
<property name="jna-dist" location="../../../dist"/>
|
||||
<property name="jna-dist" location="../../dist"/>
|
||||
|
||||
<property name="buildClasses" location="${build}/classes"/>
|
||||
<property name="buildJar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="classes" location="${build}/classes"/>
|
||||
<property name="jar" location="${build}/demo-dnd.jar"/>
|
||||
<property name="file.reference.jna.build" location="../../build"/>
|
||||
<property name="file.reference.jna.jar" location="../../build/jna.jar"/>
|
||||
<property name="main-class" value="com.sun.jna.contrib.demo.GhostedDragImageDemo" />
|
||||
|
||||
<path id="classpath">
|
||||
<fileset dir="../../../build">
|
||||
<include name="jna.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="../platform/dist">
|
||||
<include name="platform.jar"/>
|
||||
</fileset>
|
||||
<fileset file="${file.reference.jna.jar}"/>
|
||||
<fileset dir="../platform/dist" includes="platform.jar"/>
|
||||
</path>
|
||||
|
||||
<!-- Run Demo. -->
|
||||
<target name="run" depends="compile">
|
||||
<java classname="${main-class}" fork="true">
|
||||
<classpath>
|
||||
<pathelement location="${buildClasses}" />
|
||||
<pathelement location="${classes}" />
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
</java>
|
||||
@@ -31,17 +29,18 @@
|
||||
|
||||
<!-- Delete class and jar files. -->
|
||||
<target name="clean">
|
||||
<delete dir="${buildClasses}"/>
|
||||
<delete file="${buildJar}"/>
|
||||
<delete dir="${classes}"/>
|
||||
<delete file="${jar}"/>
|
||||
<delete dir="${build}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile all classes. -->
|
||||
<target name="compile">
|
||||
<mkdir dir="${buildClasses}"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
|
||||
<!-- Compile the project. -->
|
||||
<javac srcdir="${src}" destdir="${buildClasses}" target="1.5" source="1.5" encoding="UTF-8" debug="on">
|
||||
<javac srcdir="${src}" destdir="${classes}" target="1.5" source="1.5"
|
||||
encoding="UTF-8" debug="on" includeantruntime="false">
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
</classpath>
|
||||
@@ -51,7 +50,7 @@
|
||||
</javac>
|
||||
|
||||
<!-- Copy all non-java files to classes. -->
|
||||
<copy todir="${buildClasses}/com">
|
||||
<copy todir="${classes}/com">
|
||||
<fileset dir="${src}/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
@@ -60,7 +59,7 @@
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
<!-- jna -->
|
||||
<fileset dir="../../../build/classes/com">
|
||||
<fileset dir="${file.reference.jna.build}/classes/com">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
@@ -68,7 +67,7 @@
|
||||
|
||||
<!-- Create jar-file. -->
|
||||
<target name="jar" depends="compile">
|
||||
<jar jarfile="${buildJar}" basedir="${buildClasses}">
|
||||
<jar jarfile="${jar}" basedir="${classes}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
+2
-1
@@ -63,7 +63,8 @@ public class GhostedDragImageDemo {
|
||||
}
|
||||
|
||||
public static class DragLabel extends JLabel {
|
||||
private boolean dragging;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean dragging;
|
||||
public DragLabel(Icon icon) {
|
||||
super(icon);
|
||||
new DragHandler(this, DnDConstants.ACTION_COPY_OR_MOVE) {
|
||||
|
Antes Largura: | Altura: | Tamanho: 28 KiB Depois Largura: | Altura: | Tamanho: 28 KiB |
+2
-2
@@ -16,8 +16,8 @@ debug.test.classpath=\
|
||||
dist.dir=dist
|
||||
dist.jar=${dist.dir}/contrib-ntservice.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
file.reference.jna.jar=../../../build/jna.jar
|
||||
libs.junit.classpath=../../../lib/junit.jar
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
+2
-125
@@ -18,49 +18,8 @@ import com.sun.jna.win32.*;
|
||||
* @author TB
|
||||
*/
|
||||
public interface Advapi32 extends StdCallLibrary {
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class, Options.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
BOOL WINAPI LookupAccountName(
|
||||
LPCTSTR lpSystemName,
|
||||
LPCTSTR lpAccountName,
|
||||
PSID Sid,
|
||||
LPDWORD cbSid,
|
||||
LPTSTR ReferencedDomainName,
|
||||
LPDWORD cchReferencedDomainName,
|
||||
PSID_NAME_USE peUse
|
||||
);*/
|
||||
public boolean LookupAccountName(String lpSystemName, String lpAccountName,
|
||||
byte[] Sid, IntByReference cbSid, char[] ReferencedDomainName,
|
||||
IntByReference cchReferencedDomainName, PointerByReference peUse);
|
||||
|
||||
/*
|
||||
BOOL WINAPI LookupAccountSid(
|
||||
LPCTSTR lpSystemName,
|
||||
PSID lpSid,
|
||||
LPTSTR lpName,
|
||||
LPDWORD cchName,
|
||||
LPTSTR lpReferencedDomainName,
|
||||
LPDWORD cchReferencedDomainName,
|
||||
PSID_NAME_USE peUse
|
||||
);*/
|
||||
public boolean LookupAccountSid(String lpSystemName, byte[] Sid,
|
||||
char[] lpName, IntByReference cchName, char[] ReferencedDomainName,
|
||||
IntByReference cchReferencedDomainName, PointerByReference peUse);
|
||||
|
||||
/*
|
||||
BOOL ConvertSidToStringSid(
|
||||
PSID Sid,
|
||||
LPTSTR* StringSid
|
||||
);*/
|
||||
public boolean ConvertSidToStringSid(byte[] Sid, PointerByReference StringSid);
|
||||
|
||||
/*
|
||||
BOOL WINAPI ConvertStringSidToSid(
|
||||
LPCTSTR StringSid,
|
||||
PSID* Sid
|
||||
);*/
|
||||
public boolean ConvertStringSidToSid(String StringSid, PointerByReference Sid);
|
||||
Advapi32 INSTANCE = (Advapi32) Native.loadLibrary("Advapi32", Advapi32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/*
|
||||
SC_HANDLE WINAPI OpenSCManager(
|
||||
@@ -163,88 +122,6 @@ BOOL WINAPI ChangeServiceConfig2(
|
||||
);*/
|
||||
public boolean ChangeServiceConfig2(Pointer hService, int dwInfoLevel, ChangeServiceConfig2Info lpInfo);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegOpenKeyEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpSubKey,
|
||||
DWORD ulOptions,
|
||||
REGSAM samDesired,
|
||||
PHKEY phkResult
|
||||
);*/
|
||||
public int RegOpenKeyEx(int hKey, String lpSubKey, int ulOptions, int samDesired, IntByReference phkResult);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegQueryValueEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpValueName,
|
||||
LPDWORD lpReserved,
|
||||
LPDWORD lpType,
|
||||
LPBYTE lpData,
|
||||
LPDWORD lpcbData
|
||||
);*/
|
||||
public int RegQueryValueEx(int hKey, String lpValueName, IntByReference lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegCloseKey(
|
||||
HKEY hKey
|
||||
);*/
|
||||
public int RegCloseKey(int hKey);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegDeleteValue(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpValueName
|
||||
);*/
|
||||
public int RegDeleteValue(int hKey, String lpValueName);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegSetValueEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpValueName,
|
||||
DWORD Reserved,
|
||||
DWORD dwType,
|
||||
const BYTE* lpData,
|
||||
DWORD cbData
|
||||
);*/
|
||||
public int RegSetValueEx(int hKey, String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegCreateKeyEx(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpSubKey,
|
||||
DWORD Reserved,
|
||||
LPTSTR lpClass,
|
||||
DWORD dwOptions,
|
||||
REGSAM samDesired,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
PHKEY phkResult,
|
||||
LPDWORD lpdwDisposition
|
||||
);*/
|
||||
public int RegCreateKeyEx(int hKey, String lpSubKey, int Reserved, String lpClass, int dwOptions,
|
||||
int samDesired, WINBASE.SECURITY_ATTRIBUTES lpSecurityAttributes, IntByReference phkResult,
|
||||
IntByReference lpdwDisposition);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegDeleteKey(
|
||||
HKEY hKey,
|
||||
LPCTSTR lpSubKey
|
||||
);*/
|
||||
public int RegDeleteKey(int hKey, String name);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegEnumKeyEx(
|
||||
HKEY hKey,
|
||||
DWORD dwIndex,
|
||||
LPTSTR lpName,
|
||||
LPDWORD lpcName,
|
||||
LPDWORD lpReserved,
|
||||
LPTSTR lpClass,
|
||||
LPDWORD lpcClass,
|
||||
PFILETIME lpftLastWriteTime
|
||||
);*/
|
||||
public int RegEnumKeyEx(int hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved,
|
||||
char[] lpClass, IntByReference lpcClass, WINBASE.FILETIME lpftLastWriteTime);
|
||||
|
||||
/*
|
||||
LONG WINAPI RegEnumValue(
|
||||
HKEY hKey,
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* WINNT.java
|
||||
*
|
||||
* Created on 8. August 2007, 13:41
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TB
|
||||
*/
|
||||
public interface WINNT {
|
||||
public final static int DELETE = 0x00010000;
|
||||
public final static int READ_CONTROL = 0x00020000;
|
||||
public final static int WRITE_DAC = 0x00040000;
|
||||
public final static int WRITE_OWNER = 0x00080000;
|
||||
public final static int SYNCHRONIZE = 0x00100000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
|
||||
|
||||
public final static int STANDARD_RIGHTS_READ = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_WRITE = READ_CONTROL;
|
||||
public final static int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
|
||||
|
||||
public final static int STANDARD_RIGHTS_ALL = 0x001F0000;
|
||||
|
||||
public final static int SPECIFIC_RIGHTS_ALL = 0x0000FFFF;
|
||||
|
||||
public final static int GENERIC_EXECUTE = 0x20000000;
|
||||
|
||||
public final static int SERVICE_WIN32_OWN_PROCESS = 0x00000010;
|
||||
}
|
||||
-5
@@ -9,11 +9,6 @@
|
||||
|
||||
package jnacontrib.jna;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary.StdCallCallback;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
-1
@@ -180,7 +180,6 @@ public abstract class Win32Service {
|
||||
*/
|
||||
public void init() {
|
||||
Advapi32 advapi32;
|
||||
Advapi32.SERVICE_TABLE_ENTRY[] entries = new Advapi32.SERVICE_TABLE_ENTRY[2];
|
||||
Advapi32.SERVICE_TABLE_ENTRY entry;
|
||||
|
||||
serviceMain = new ServiceMain();
|
||||
@@ -63,11 +63,20 @@
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<condition property="tests.platform" value="win32">
|
||||
<condition property="tests.platform" value="test-win32">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
<target name="test" description="Run unit tests." if="tests.platform">
|
||||
<antcall target="test-win32" />
|
||||
<antcall target="${tests.platform}" />
|
||||
</target>
|
||||
<target name="test-report">
|
||||
<junitreport todir="${build.test.results.dir}">
|
||||
<fileset dir="${build.test.results.dir}">
|
||||
<include name="TEST-*.xml"/>
|
||||
</fileset>
|
||||
<report todir="${build.test.results.dir}"/>
|
||||
</junitreport>
|
||||
<echo message="View test report in file://${build.test.results.dir}/index.html" />
|
||||
</target>
|
||||
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
<target name="test-win32" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" />
|
||||
</project>
|
||||
+2
-2
@@ -16,8 +16,8 @@ debug.test.classpath=\
|
||||
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
|
||||
file.reference.jna.jar=../../build/jna.jar
|
||||
libs.junit.classpath=../../lib/junit.jar
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jna.jar};
|
||||
+10
-9
@@ -20,6 +20,7 @@ import com.sun.jna.Platform;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import com.sun.jna.platform.unix.X11.Display;
|
||||
import com.sun.jna.platform.win32.User32;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
|
||||
/** Provide access to the local keyboard state. Note that this is meaningless
|
||||
* on a headless system and some VNC setups.
|
||||
@@ -71,30 +72,30 @@ public class KeyboardUtils {
|
||||
}
|
||||
if (code == KeyEvent.VK_SHIFT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RSHIFT;
|
||||
return WinUser.VK_RSHIFT;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LSHIFT;
|
||||
return WinUser.VK_LSHIFT;
|
||||
}
|
||||
return User32.VK_SHIFT;
|
||||
return WinUser.VK_SHIFT;
|
||||
}
|
||||
if (code == KeyEvent.VK_CONTROL) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RCONTROL;
|
||||
return WinUser.VK_RCONTROL;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LCONTROL;
|
||||
return WinUser.VK_LCONTROL;
|
||||
}
|
||||
return User32.VK_CONTROL;
|
||||
return WinUser.VK_CONTROL;
|
||||
}
|
||||
if (code == KeyEvent.VK_ALT) {
|
||||
if ((loc & KeyEvent.KEY_LOCATION_RIGHT) != 0) {
|
||||
return User32.VK_RMENU;
|
||||
return WinUser.VK_RMENU;
|
||||
}
|
||||
if ((loc & KeyEvent.KEY_LOCATION_LEFT) != 0) {
|
||||
return User32.VK_LMENU;
|
||||
return WinUser.VK_LMENU;
|
||||
}
|
||||
return User32.VK_MENU;
|
||||
return WinUser.VK_MENU;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+17
-17
@@ -44,7 +44,7 @@ public class RasterRangesUtils {
|
||||
0x0008, 0x0004, 0x0002, 0x0001
|
||||
};
|
||||
|
||||
private static final Comparator COMPARATOR = new Comparator() {
|
||||
private static final Comparator<Object> COMPARATOR = new Comparator<Object>() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((Rectangle)o1).x - ((Rectangle)o2).x;
|
||||
}
|
||||
@@ -116,11 +116,11 @@ public class RasterRangesUtils {
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRangesOfBinaryPixels(byte[] binaryBits, int w, int h, RangesOutput out) {
|
||||
Set rects = new HashSet();
|
||||
Set prevLine = Collections.EMPTY_SET;
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
int scanlineBytes = binaryBits.length / h;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set curLine = new TreeSet(COMPARATOR);
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int rowOffsetBytes = row * scanlineBytes;
|
||||
int startCol = -1;
|
||||
// Look at each batch of 8 columns in this row
|
||||
@@ -163,14 +163,14 @@ public class RasterRangesUtils {
|
||||
// end of last region
|
||||
curLine.add(new Rectangle(startCol, row, w - startCol, 1));
|
||||
}
|
||||
Set unmerged = mergeRects(prevLine, curLine);
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = (Rectangle)i.next();
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
@@ -189,10 +189,10 @@ public class RasterRangesUtils {
|
||||
* @return true if the output succeeded, false otherwise
|
||||
*/
|
||||
public static boolean outputOccupiedRanges(int[] pixels, int w, int h, int occupationMask, RangesOutput out) {
|
||||
Set rects = new HashSet();
|
||||
Set prevLine = Collections.EMPTY_SET;
|
||||
Set<Rectangle> rects = new HashSet<Rectangle>();
|
||||
Set<Rectangle> prevLine = Collections.EMPTY_SET;
|
||||
for (int row = 0; row < h; row++) {
|
||||
Set curLine = new TreeSet(COMPARATOR);
|
||||
Set<Rectangle> curLine = new TreeSet<Rectangle>(COMPARATOR);
|
||||
int idxOffset = row * w;
|
||||
int startCol = -1;
|
||||
|
||||
@@ -213,14 +213,14 @@ public class RasterRangesUtils {
|
||||
// end of last region of current row
|
||||
curLine.add(new Rectangle(startCol, row, w-startCol, 1));
|
||||
}
|
||||
Set unmerged = mergeRects(prevLine, curLine);
|
||||
Set<Rectangle> unmerged = mergeRects(prevLine, curLine);
|
||||
rects.addAll(unmerged);
|
||||
prevLine = curLine;
|
||||
}
|
||||
// Add anything left over
|
||||
rects.addAll(prevLine);
|
||||
for (Iterator i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = (Rectangle)i.next();
|
||||
for (Iterator<Rectangle> i=rects.iterator();i.hasNext();) {
|
||||
Rectangle r = i.next();
|
||||
if (!out.outputRange(r.x, r.y, r.width, r.height)) {
|
||||
return false;
|
||||
}
|
||||
@@ -228,11 +228,11 @@ public class RasterRangesUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Set mergeRects(Set prev, Set current) {
|
||||
Set unmerged = new HashSet(prev);
|
||||
private static Set<Rectangle> mergeRects(Set<Rectangle> prev, Set<Rectangle> current) {
|
||||
Set<Rectangle> unmerged = new HashSet<Rectangle>(prev);
|
||||
if (!prev.isEmpty() && !current.isEmpty()) {
|
||||
Rectangle[] pr = (Rectangle[])prev.toArray(new Rectangle[prev.size()]);
|
||||
Rectangle[] cr = (Rectangle[])current.toArray(new Rectangle[current.size()]);
|
||||
Rectangle[] pr = prev.toArray(new Rectangle[prev.size()]);
|
||||
Rectangle[] cr = current.toArray(new Rectangle[current.size()]);
|
||||
int ipr = 0;
|
||||
int icr = 0;
|
||||
while (ipr < pr.length && icr < cr.length) {
|
||||
+48
-41
@@ -71,15 +71,17 @@ 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.platform.win32.WinGDI;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
@@ -149,6 +151,7 @@ public class WindowUtils {
|
||||
* </pre></code>
|
||||
*/
|
||||
private static class HeavyweightForcer extends Window {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final boolean packed;
|
||||
|
||||
public HeavyweightForcer(Window parent) {
|
||||
@@ -174,6 +177,7 @@ public class WindowUtils {
|
||||
* invoked whenever any part of the ancestor window is repainted.
|
||||
*/
|
||||
protected static class RepaintTrigger extends JComponent {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected class Listener
|
||||
extends WindowAdapter
|
||||
@@ -264,6 +268,7 @@ public class WindowUtils {
|
||||
public static abstract class NativeWindowUtils {
|
||||
protected abstract class TransparentContentPane
|
||||
extends JPanel implements AWTEventListener {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean transparent;
|
||||
public TransparentContentPane(Container oldContent) {
|
||||
super(new BorderLayout());
|
||||
@@ -639,27 +644,27 @@ public class WindowUtils {
|
||||
public void run() {
|
||||
HWND hWnd = getHWnd(w);
|
||||
User32 user = User32.INSTANCE;
|
||||
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
|
||||
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
|
||||
byte level = (byte)((int)(255 * alpha) & 0xFF);
|
||||
if (usingUpdateLayeredWindow(w)) {
|
||||
// If already using UpdateLayeredWindow, continue to
|
||||
// do so
|
||||
User32.BLENDFUNCTION blend = new User32.BLENDFUNCTION();
|
||||
BLENDFUNCTION blend = new BLENDFUNCTION();
|
||||
blend.SourceConstantAlpha = level;
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, null, null, null, null,
|
||||
null, 0, blend,
|
||||
User32.ULW_ALPHA);
|
||||
WinUser.ULW_ALPHA);
|
||||
}
|
||||
else if (alpha == 1f) {
|
||||
flags &= ~User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
flags &= ~WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
}
|
||||
else {
|
||||
flags |= User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
flags |= WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
user.SetLayeredWindowAttributes(hWnd, 0, level,
|
||||
User32.LWA_ALPHA);
|
||||
WinUser.LWA_ALPHA);
|
||||
}
|
||||
setForceHeavyweightPopups(w, alpha != 1f);
|
||||
storeAlpha(w, level);
|
||||
@@ -672,6 +677,7 @@ public class WindowUtils {
|
||||
* when the window is transparent.
|
||||
*/
|
||||
private class W32TransparentContentPane extends TransparentContentPane {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private HDC memDC;
|
||||
private HBITMAP hBitmap;
|
||||
private Pointer pbits;
|
||||
@@ -728,12 +734,12 @@ public class WindowUtils {
|
||||
bmi.bmiHeader.biHeight = wh;
|
||||
bmi.bmiHeader.biPlanes = 1;
|
||||
bmi.bmiHeader.biBitCount = 32;
|
||||
bmi.bmiHeader.biCompression = GDI32.BI_RGB;
|
||||
bmi.bmiHeader.biCompression = WinGDI.BI_RGB;
|
||||
bmi.bmiHeader.biSizeImage = ww * wh * 4;
|
||||
PointerByReference ppbits = new PointerByReference();
|
||||
hBitmap = gdi.CreateDIBSection(memDC, bmi,
|
||||
GDI32.DIB_RGB_COLORS,
|
||||
ppbits, null, 0);
|
||||
WinGDI.DIB_RGB_COLORS,
|
||||
ppbits, null, 0);
|
||||
pbits = ppbits.getValue();
|
||||
bitmapSize = new Dimension(ww, wh);
|
||||
}
|
||||
@@ -769,18 +775,17 @@ public class WindowUtils {
|
||||
try {
|
||||
// GetLayeredwindowAttributes supported WinXP and later
|
||||
if (user.GetLayeredWindowAttributes(hWnd, null, bref, iref)
|
||||
&& (iref.getValue() & User32.LWA_ALPHA) != 0) {
|
||||
&& (iref.getValue() & WinUser.LWA_ALPHA) != 0) {
|
||||
level = bref.getValue();
|
||||
}
|
||||
}
|
||||
catch(UnsatisfiedLinkError e) {
|
||||
}
|
||||
blend.SourceConstantAlpha = level;
|
||||
blend.AlphaFormat = User32.AC_SRC_ALPHA;
|
||||
blend.AlphaFormat = WinUser.AC_SRC_ALPHA;
|
||||
user.UpdateLayeredWindow(hWnd, screenDC, winLoc, winSize, memDC,
|
||||
srcLoc, 0, blend, User32.ULW_ALPHA);
|
||||
}
|
||||
finally {
|
||||
srcLoc, 0, blend, WinUser.ULW_ALPHA);
|
||||
} finally {
|
||||
user.ReleaseDC(null, screenDC);
|
||||
if (memDC != null && oldBitmap != null) {
|
||||
gdi.SelectObject(memDC, oldBitmap);
|
||||
@@ -808,7 +813,7 @@ public class WindowUtils {
|
||||
public void run() {
|
||||
User32 user = User32.INSTANCE;
|
||||
HWND hWnd = getHWnd(w);
|
||||
int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
|
||||
int flags = user.GetWindowLong(hWnd, WinUser.GWL_EXSTYLE);
|
||||
JRootPane root = ((RootPaneContainer)w).getRootPane();
|
||||
JLayeredPane lp = root.getLayeredPane();
|
||||
Container content = root.getContentPane();
|
||||
@@ -823,12 +828,12 @@ public class WindowUtils {
|
||||
JLayeredPane.DRAG_LAYER);
|
||||
}
|
||||
if (transparent && !usingUpdateLayeredWindow(w)) {
|
||||
flags |= User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
flags |= WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
}
|
||||
else if (!transparent && usingUpdateLayeredWindow(w)) {
|
||||
flags &= ~User32.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, User32.GWL_EXSTYLE, flags);
|
||||
flags &= ~WinUser.WS_EX_LAYERED;
|
||||
user.SetWindowLong(hWnd, WinUser.GWL_EXSTYLE, flags);
|
||||
}
|
||||
setLayersTransparent(w, transparent);
|
||||
setForceHeavyweightPopups(w, transparent);
|
||||
@@ -869,11 +874,11 @@ public class WindowUtils {
|
||||
GDI32 gdi = GDI32.INSTANCE;
|
||||
PathIterator pi = area.getPathIterator(null);
|
||||
int mode = pi.getWindingRule() == PathIterator.WIND_NON_ZERO
|
||||
? GDI32.WINDING: GDI32.ALTERNATE;
|
||||
? WinGDI.WINDING: WinGDI.ALTERNATE;
|
||||
float[] coords = new float[6];
|
||||
List points = new ArrayList();
|
||||
List<POINT> points = new ArrayList<POINT>();
|
||||
int size = 0;
|
||||
List sizes = new ArrayList();
|
||||
List<Integer> sizes = new ArrayList<Integer>();
|
||||
while (!pi.isDone()) {
|
||||
int type = pi.currentSegment(coords);
|
||||
if (type == PathIterator.SEG_MOVETO) {
|
||||
@@ -917,7 +922,7 @@ public class WindowUtils {
|
||||
public boolean outputRange(int x, int y, int w, int h) {
|
||||
GDI32 gdi = GDI32.INSTANCE;
|
||||
gdi.SetRectRgn(tempRgn, x, y, x + w, y + h);
|
||||
return gdi.CombineRgn(region, region, tempRgn, GDI32.RGN_OR) != GDI32.ERROR;
|
||||
return gdi.CombineRgn(region, region, tempRgn, WinGDI.RGN_OR) != WinGDI.ERROR;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1008,7 +1013,7 @@ public class WindowUtils {
|
||||
fixWindowDragging(w, "setWindowAlpha");
|
||||
}
|
||||
whenDisplayable(w, new Runnable() {
|
||||
public void run() {
|
||||
public void run() {
|
||||
Object peer = w.getPeer();
|
||||
try {
|
||||
peer.getClass().getMethod("setAlpha", new Class[]{
|
||||
@@ -1049,6 +1054,7 @@ public class WindowUtils {
|
||||
* @author Olivier Chafik
|
||||
*/
|
||||
private static class OSXMaskingContentPane extends JPanel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Shape shape;
|
||||
|
||||
public OSXMaskingContentPane(Component oldContent) {
|
||||
@@ -1123,7 +1129,7 @@ public class WindowUtils {
|
||||
}
|
||||
x11.XSetForeground(dpy, gc, new NativeLong(0));
|
||||
x11.XFillRectangle(dpy, pm, gc, 0, 0, width, height);
|
||||
final List rlist = new ArrayList();
|
||||
final List<Rectangle> rlist = new ArrayList<Rectangle>();
|
||||
try {
|
||||
RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() {
|
||||
public boolean outputRange(int x, int y, int w, int h) {
|
||||
@@ -1229,7 +1235,7 @@ public class WindowUtils {
|
||||
IntByReference pcount = new IntByReference();
|
||||
info = x11.XGetVisualInfo(dpy, mask, template, pcount);
|
||||
if (info != null) {
|
||||
List list = new ArrayList();
|
||||
List<X11.VisualID> list = new ArrayList<X11.VisualID>();
|
||||
XVisualInfo[] infos =
|
||||
(XVisualInfo[])info.toArray(pcount.getValue());
|
||||
for (int i = 0; i < infos.length; i++) {
|
||||
@@ -1269,9 +1275,9 @@ public class WindowUtils {
|
||||
x11.XQueryTree(dpy, win, rootp, parentp, childrenp, countp);
|
||||
Pointer p = childrenp.getValue();
|
||||
int[] ids = p.getIntArray(0, countp.getValue());
|
||||
for (int i=0;i < ids.length;i++) {
|
||||
for (int id : ids) {
|
||||
// TODO: more verification of correct window?
|
||||
X11.Window child = new X11.Window(ids[i]);
|
||||
X11.Window child = new X11.Window(id);
|
||||
X11.XWindowAttributes xwa = new X11.XWindowAttributes();
|
||||
x11.XGetWindowAttributes(dpy, child, xwa);
|
||||
offset.x = -xwa.x;
|
||||
@@ -1333,6 +1339,7 @@ public class WindowUtils {
|
||||
}
|
||||
|
||||
private class X11TransparentContentPane extends TransparentContentPane {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public X11TransparentContentPane(Container oldContent) {
|
||||
super(oldContent);
|
||||
@@ -1344,7 +1351,7 @@ public class WindowUtils {
|
||||
// Painting directly to the original Graphics
|
||||
// fails to properly composite unless the destination
|
||||
// is pure black. Too bad.
|
||||
protected void paintDirect(BufferedImage buf, Rectangle bounds) {
|
||||
protected void paintDirect(BufferedImage buf, Rectangle bounds) {
|
||||
Window window = SwingUtilities.getWindowAncestor(this);
|
||||
X11 x11 = X11.INSTANCE;
|
||||
X11.Display dpy = x11.XOpenDisplay(null);
|
||||
+2
-2
@@ -180,7 +180,7 @@ public abstract class DragHandler
|
||||
private Component dragSource;
|
||||
private GhostedDragImage ghost;
|
||||
private Point imageOffset;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private Dimension maxGhostSize = MAX_GHOST_SIZE;
|
||||
private float ghostAlpha = DEFAULT_GHOST_ALPHA;
|
||||
|
||||
/** Enable drags from the given component, supporting the actions in
|
||||
@@ -530,4 +530,4 @@ public abstract class DragHandler
|
||||
}
|
||||
updateCursor(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -88,7 +88,7 @@ import java.util.Set;
|
||||
public abstract class DropHandler implements DropTargetListener {
|
||||
|
||||
private int acceptedActions;
|
||||
private List acceptedFlavors;
|
||||
private List<DataFlavor> acceptedFlavors;
|
||||
private DropTarget dropTarget;
|
||||
private boolean active = true;
|
||||
private DropTargetPainter painter;
|
||||
@@ -347,7 +347,7 @@ public abstract class DropHandler implements DropTargetListener {
|
||||
* constructor.
|
||||
*/
|
||||
protected boolean isSupported(DataFlavor[] flavors) {
|
||||
Set set = new HashSet(Arrays.asList(flavors));
|
||||
Set<DataFlavor> set = new HashSet<DataFlavor>(Arrays.asList(flavors));
|
||||
set.retainAll(acceptedFlavors);
|
||||
return !set.isEmpty();
|
||||
}
|
||||
+1
@@ -56,6 +56,7 @@ public class GhostedDragImage {
|
||||
// FIXME ensure gc is compatible (X11)
|
||||
GraphicsConfiguration gc = parent.getGraphicsConfiguration();
|
||||
dragImage = new Window(JOptionPane.getRootFrame(), gc) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public void paint(Graphics g) {
|
||||
icon.paintIcon(this, g, 0, 0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides integrated, extended drag and drop functionality,
|
||||
allowing ghosted drag images to be used on all platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class MacFileUtils extends FileUtils {
|
||||
if (!trash.exists()) {
|
||||
throw new IOException("The Trash was not found in its expected location (" + 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());
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for the OS X platform.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides cross-platform utilities based on platform-specific libraries.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+15
-4
@@ -29,12 +29,14 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
public interface X11 extends Library {
|
||||
|
||||
class VisualID extends NativeLong {
|
||||
public VisualID() { }
|
||||
private static final long serialVersionUID = 1L;
|
||||
public VisualID() { }
|
||||
public VisualID(long value) { super(value); }
|
||||
}
|
||||
|
||||
class XID extends NativeLong {
|
||||
public static final XID None = null;
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final XID None = null;
|
||||
public XID() { this(0); }
|
||||
public XID(long id) { super(id); }
|
||||
protected boolean isNone(Object o) {
|
||||
@@ -52,6 +54,7 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Atom extends XID {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Atom None = null;
|
||||
public Atom() { }
|
||||
public Atom(long id) { super(id); }
|
||||
@@ -143,6 +146,7 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Colormap extends XID {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Colormap None = null;
|
||||
public Colormap() { }
|
||||
public Colormap(long id) { super(id); }
|
||||
@@ -153,6 +157,7 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Font extends XID {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Font None = null;
|
||||
public Font() { }
|
||||
public Font(long id) { super(id); }
|
||||
@@ -163,6 +168,7 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Cursor extends XID {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Cursor None = null;
|
||||
public Cursor() { }
|
||||
public Cursor(long id) { super(id); }
|
||||
@@ -173,6 +179,7 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class KeySym extends XID {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final KeySym None = null;
|
||||
public KeySym() { }
|
||||
public KeySym(long id) { super(id); }
|
||||
@@ -183,6 +190,7 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Drawable extends XID {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Drawable None = null;
|
||||
public Drawable() { }
|
||||
public Drawable(long id) { super(id); }
|
||||
@@ -193,7 +201,8 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Window extends Drawable {
|
||||
public static final Window None = null;
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Window None = null;
|
||||
public Window() { }
|
||||
public Window(long id) { super(id); }
|
||||
public Object fromNative(Object nativeValue, FromNativeContext context) {
|
||||
@@ -211,7 +220,8 @@ public interface X11 extends Library {
|
||||
}
|
||||
}
|
||||
class Pixmap extends Drawable {
|
||||
public static final Pixmap None = null;
|
||||
private static final long serialVersionUID = 1L;
|
||||
public static final Pixmap None = null;
|
||||
public Pixmap() { }
|
||||
public Pixmap(long id) { super(id); }
|
||||
public Object fromNative(Object nativeValue, FromNativeContext context) {
|
||||
@@ -268,6 +278,7 @@ public interface X11 extends Library {
|
||||
public short alpha, alphaMask;
|
||||
}
|
||||
class PictFormat extends NativeLong {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public PictFormat(long value) { super(value); }
|
||||
public PictFormat() { }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2010 Timothy Wall
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<!-- One sentence summary -->
|
||||
Provides common library mappings for Unix and X11-based platforms.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Diferenças do arquivo suprimidas por serem muito extensas
Carregar Diff
+673
-72
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,21 +8,26 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
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.Pointer;
|
||||
import com.sun.jna.platform.win32.WinNT.EVENTLOGRECORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.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.WinNT.SID_NAME_USE;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEY;
|
||||
import com.sun.jna.platform.win32.WinReg.HKEYByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
@@ -33,25 +38,7 @@ import com.sun.jna.ptr.PointerByReference;
|
||||
* @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.
|
||||
*/
|
||||
@@ -252,16 +239,48 @@ public abstract class Advapi32Util {
|
||||
/**
|
||||
* Convert a string representation of a security identifier (SID) to
|
||||
* a binary format.
|
||||
* @param sid String SID.
|
||||
* @param sidString
|
||||
* String SID.
|
||||
* @return SID bytes.
|
||||
*/
|
||||
public static byte[] convertStringSidToSid(String sid) {
|
||||
public static byte[] convertStringSidToSid(String sidString) {
|
||||
PSIDByReference pSID = new PSIDByReference();
|
||||
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sid, pSID)) {
|
||||
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sidString, pSID)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return pSID.getValue().getBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares a SID to a well known SID and returns TRUE if they match.
|
||||
* @param sidString
|
||||
* String representation of a SID.
|
||||
* @param wellKnownSidType
|
||||
* Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid.
|
||||
* @return
|
||||
* True if the SID is of the well-known type, false otherwise.
|
||||
*/
|
||||
public static boolean isWellKnownSid(String sidString, int wellKnownSidType) {
|
||||
PSIDByReference pSID = new PSIDByReference();
|
||||
if (! Advapi32.INSTANCE.ConvertStringSidToSid(sidString, pSID)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return Advapi32.INSTANCE.IsWellKnownSid(pSID.getValue(), wellKnownSidType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares a SID to a well known SID and returns TRUE if they match.
|
||||
* @param sidBytes
|
||||
* Byte representation of a SID.
|
||||
* @param wellKnownSidType
|
||||
* Member of the WELL_KNOWN_SID_TYPE enumeration to compare with the SID at pSid.
|
||||
* @return
|
||||
* True if the SID is of the well-known type, false otherwise.
|
||||
*/
|
||||
public static boolean isWellKnownSid(byte[] sidBytes, int wellKnownSidType) {
|
||||
PSID pSID = new PSID(sidBytes);
|
||||
return Advapi32.INSTANCE.IsWellKnownSid(pSID, wellKnownSidType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an account name from a string SID on the local machine.
|
||||
@@ -291,36 +310,41 @@ public abstract class Advapi32Util {
|
||||
* @param hToken Token.
|
||||
* @return Token groups.
|
||||
*/
|
||||
public static Group[] getTokenGroups(HANDLE hToken) {
|
||||
public static Account[] 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) {
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength)) {
|
||||
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
|
||||
}
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
if (rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
// get token group information
|
||||
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
|
||||
WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationBuffer);
|
||||
WinNT.TOKEN_GROUPS groups = new WinNT.TOKEN_GROUPS(tokenInformationLength.getValue());
|
||||
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>();
|
||||
ArrayList<Account> userGroups = new ArrayList<Account>();
|
||||
// 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);
|
||||
Account group = null;
|
||||
try {
|
||||
group.name = Advapi32Util.getAccountBySid(sidAndAttribute.Sid).name;
|
||||
group = Advapi32Util.getAccountBySid(sidAndAttribute.Sid);
|
||||
} catch(Exception e) {
|
||||
group = new Account();
|
||||
group.sid = sidAndAttribute.Sid.getBytes();
|
||||
group.sidString = Advapi32Util.convertSidToStringSid(sidAndAttribute.Sid);
|
||||
group.name = group.sidString;
|
||||
group.fqn = group.sidString;
|
||||
group.accountType = SID_NAME_USE.SidTypeGroup;
|
||||
}
|
||||
userGroups.add(group);
|
||||
}
|
||||
return userGroups.toArray(new Group[0]);
|
||||
return userGroups.toArray(new Account[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -333,13 +357,15 @@ public abstract class Advapi32Util {
|
||||
// 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) {
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, null, 0, tokenInformationLength)) {
|
||||
throw new RuntimeException("Expected GetTokenInformation to fail with ERROR_INSUFFICIENT_BUFFER");
|
||||
}
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
if (rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
// get token user information
|
||||
Memory tokenInformationBuffer = new Memory(tokenInformationLength.getValue());
|
||||
WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationBuffer);
|
||||
WinNT.TOKEN_USER user = new WinNT.TOKEN_USER(tokenInformationLength.getValue());
|
||||
if (! Advapi32.INSTANCE.GetTokenInformation(hToken,
|
||||
WinNT.TOKEN_INFORMATION_CLASS.TokenUser, user,
|
||||
tokenInformationLength.getValue(), tokenInformationLength)) {
|
||||
@@ -352,7 +378,7 @@ public abstract class Advapi32Util {
|
||||
* Return the group memberships of the currently logged on user.
|
||||
* @return An array of groups.
|
||||
*/
|
||||
public static Group[] getCurrentUserGroups() {
|
||||
public static Account[] getCurrentUserGroups() {
|
||||
HANDLEByReference phToken = new HANDLEByReference();
|
||||
try {
|
||||
// open thread or process token
|
||||
@@ -370,7 +396,7 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
return getTokenGroups(phToken.getValue());
|
||||
} finally {
|
||||
if (phToken.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
|
||||
if (phToken.getValue() != WinBase.INVALID_HANDLE_VALUE) {
|
||||
if (! Kernel32.INSTANCE.CloseHandle(phToken.getValue())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
@@ -438,7 +464,7 @@ public abstract class Advapi32Util {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
} finally {
|
||||
if (phkKey.getValue() != Kernel32.INVALID_HANDLE_VALUE) {
|
||||
if (phkKey.getValue() != WinBase.INVALID_HANDLE_VALUE) {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
@@ -490,6 +516,143 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_EXPAND_SZ value.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param key
|
||||
* Registry path.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return
|
||||
* String value.
|
||||
*/
|
||||
public static String registryGetExpandableStringValue(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_EXPAND_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 REG_MULTI_SZ value.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param key
|
||||
* Registry path.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return
|
||||
* String value.
|
||||
*/
|
||||
public static String[] registryGetStringArray(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_MULTI_SZ) {
|
||||
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
|
||||
}
|
||||
Memory data = new Memory(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);
|
||||
}
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
int offset = 0;
|
||||
while(offset < data.size()) {
|
||||
String s = data.getString(offset, true);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
result.add(s);
|
||||
}
|
||||
return result.toArray(new String[0]);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry REG_BINARY value.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param key
|
||||
* Registry path.
|
||||
* @param value
|
||||
* Name of the value to retrieve.
|
||||
* @return
|
||||
* String value.
|
||||
*/
|
||||
public static byte[] registryGetBinaryValue(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_BINARY) {
|
||||
throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_BINARY");
|
||||
}
|
||||
byte[] data = new byte[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 data;
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a registry DWORD value.
|
||||
* @param root
|
||||
@@ -539,18 +702,22 @@ public abstract class Advapi32Util {
|
||||
* Parent key.
|
||||
* @param keyName
|
||||
* Key name.
|
||||
* @return
|
||||
* True if the key was created, false otherwise.
|
||||
*/
|
||||
public static void registryCreateKey(HKEY hKey, String keyName) {
|
||||
public static boolean 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);
|
||||
IntByReference lpdwDisposition = new IntByReference();
|
||||
int rc = Advapi32.INSTANCE.RegCreateKeyEx(hKey, keyName, 0, null, WinNT.REG_OPTION_NON_VOLATILE,
|
||||
WinNT.KEY_READ, null, phkResult, lpdwDisposition);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkResult.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
return WinNT.REG_CREATED_NEW_KEY == lpdwDisposition.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,15 +728,17 @@ public abstract class Advapi32Util {
|
||||
* Path to an existing registry key.
|
||||
* @param keyName
|
||||
* Key name.
|
||||
* @return
|
||||
* True if the key was created, false otherwise.
|
||||
*/
|
||||
public static void registryCreateKey(HKEY root, String parentPath, String keyName) {
|
||||
public static boolean 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);
|
||||
return registryCreateKey(phkKey.getValue(), keyName);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
@@ -583,9 +752,9 @@ public abstract class Advapi32Util {
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Name.
|
||||
* Value name.
|
||||
* @param value
|
||||
* Value.
|
||||
* Value to write to registry.
|
||||
*/
|
||||
public static void registrySetIntValue(HKEY hKey, String name, int value) {
|
||||
byte[] data = new byte[4];
|
||||
@@ -606,9 +775,9 @@ public abstract class Advapi32Util {
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param name
|
||||
* Name.
|
||||
* Value name.
|
||||
* @param value
|
||||
* Value.
|
||||
* Value to write to registry.
|
||||
*/
|
||||
public static void registrySetIntValue(HKEY root, String keyPath, String name, int value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
@@ -631,13 +800,14 @@ public abstract class Advapi32Util {
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Name.
|
||||
* Value name.
|
||||
* @param value
|
||||
* Value.
|
||||
* Value to write to registry.
|
||||
*/
|
||||
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);
|
||||
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_SZ,
|
||||
data, data.length * Native.WCHAR_SIZE);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
@@ -650,9 +820,9 @@ public abstract class Advapi32Util {
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param name
|
||||
* Name.
|
||||
* Value name.
|
||||
* @param value
|
||||
* Value.
|
||||
* Value to write to registry.
|
||||
*/
|
||||
public static void registrySetStringValue(HKEY root, String keyPath, String name, String value) {
|
||||
HKEYByReference phkKey = new HKEYByReference();
|
||||
@@ -670,6 +840,153 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an expandable string value in registry.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Value name.
|
||||
* @param value
|
||||
* Value to write to registry.
|
||||
*/
|
||||
public static void registrySetExpandableStringValue(HKEY hKey, String name, String value) {
|
||||
char[] data = Native.toCharArray(value);
|
||||
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_EXPAND_SZ,
|
||||
data, data.length * Native.WCHAR_SIZE);
|
||||
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
|
||||
* Value name.
|
||||
* @param value
|
||||
* Value to write to registry.
|
||||
*/
|
||||
public static void registrySetExpandableStringValue(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 {
|
||||
registrySetExpandableStringValue(phkKey.getValue(), name, value);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a string array value in registry.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Name.
|
||||
* @param arr
|
||||
* Array of strings to write to registry.
|
||||
*/
|
||||
public static void registrySetStringArray(HKEY hKey, String name, String[] arr) {
|
||||
int size = 0;
|
||||
for(String s : arr) {
|
||||
size += s.length() * Native.WCHAR_SIZE;
|
||||
size += Native.WCHAR_SIZE;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
Memory data = new Memory(size);
|
||||
for(String s : arr) {
|
||||
data.setString(offset, s, true);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
}
|
||||
|
||||
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_MULTI_SZ,
|
||||
data.getByteArray(0, size), size);
|
||||
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a string array value in registry.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param name
|
||||
* Value name.
|
||||
* @param arr
|
||||
* Array of strings to write to registry.
|
||||
*/
|
||||
public static void registrySetStringArray(HKEY root, String keyPath, String name, String[] arr) {
|
||||
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 {
|
||||
registrySetStringArray(phkKey.getValue(), name, arr);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a binary value in registry.
|
||||
* @param hKey
|
||||
* Parent key.
|
||||
* @param name
|
||||
* Value name.
|
||||
* @param data
|
||||
* Data to write to registry.
|
||||
*/
|
||||
public static void registrySetBinaryValue(HKEY hKey, String name, byte[] data) {
|
||||
int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0, WinNT.REG_BINARY, data, data.length);
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a binary value in registry.
|
||||
* @param root
|
||||
* Root key.
|
||||
* @param keyPath
|
||||
* Path to an existing registry key.
|
||||
* @param name
|
||||
* Value name.
|
||||
* @param data
|
||||
* Data to write to registry.
|
||||
*/
|
||||
public static void registrySetBinaryValue(HKEY root, String keyPath, String name, byte[] data) {
|
||||
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 {
|
||||
registrySetBinaryValue(phkKey.getValue(), name, data);
|
||||
} finally {
|
||||
rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a registry key.
|
||||
* @param hKey
|
||||
@@ -818,7 +1135,7 @@ public abstract class Advapi32Util {
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
TreeMap<String, Object> keyValues = new TreeMap<String, Object>();
|
||||
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++) {
|
||||
@@ -830,22 +1147,44 @@ public abstract class Advapi32Util {
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
|
||||
String nameString = Native.toString(name);
|
||||
|
||||
Memory byteData = new Memory(lpcbData.getValue());
|
||||
byteData.write(0, data, 0, lpcbData.getValue());
|
||||
|
||||
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));
|
||||
{
|
||||
keyValues.put(nameString, byteData.getInt(0));
|
||||
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());
|
||||
}
|
||||
case WinNT.REG_EXPAND_SZ:
|
||||
{
|
||||
keyValues.put(nameString, byteData.getString(0, true));
|
||||
break;
|
||||
}
|
||||
case WinNT.REG_BINARY:
|
||||
{
|
||||
keyValues.put(nameString, byteData.getByteArray(0, lpcbData.getValue()));
|
||||
break;
|
||||
}
|
||||
case WinNT.REG_MULTI_SZ:
|
||||
{
|
||||
Memory stringData = new Memory(lpcbData.getValue());
|
||||
stringData.write(0, data, 0, lpcbData.getValue());
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
int offset = 0;
|
||||
while(offset < stringData.size()) {
|
||||
String s = stringData.getString(offset, true);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
result.add(s);
|
||||
}
|
||||
keyValues.put(nameString, result.toArray(new String[0]));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new RuntimeException("Unsupported type: " + lpType.getValue());
|
||||
}
|
||||
@@ -876,5 +1215,267 @@ public abstract class Advapi32Util {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a map of environment variables to an environment block suitable
|
||||
* for {@link Advapi32#CreateProcessAsUser}. This environment block consists
|
||||
* of null-terminated blocks of null-terminated strings. Each string is in the
|
||||
* following form: name=value\0
|
||||
* @param environment Environment variables
|
||||
* @return A environment block
|
||||
*/
|
||||
public static String getEnvironmentBlock(Map<String, String> environment) {
|
||||
StringBuffer out = new StringBuffer();
|
||||
for (Entry<String, String> entry: environment.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
out.append(entry.getKey() + "=" + entry.getValue() + "\0");
|
||||
}
|
||||
}
|
||||
return out.toString() + "\0";
|
||||
}
|
||||
|
||||
/**
|
||||
* Event log types.
|
||||
*/
|
||||
public static enum EventLogType {
|
||||
Error,
|
||||
Warning,
|
||||
Informational,
|
||||
AuditSuccess,
|
||||
AuditFailure
|
||||
}
|
||||
|
||||
/**
|
||||
* An event log record.
|
||||
*/
|
||||
public static class EventLogRecord {
|
||||
private EVENTLOGRECORD _record = null;
|
||||
private String _source;
|
||||
private byte[] _data;
|
||||
private String[] _strings;
|
||||
|
||||
/**
|
||||
* Raw record data.
|
||||
* @return
|
||||
* EVENTLOGRECORD.
|
||||
*/
|
||||
public EVENTLOGRECORD getRecord() {
|
||||
return _record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event Id.
|
||||
* @return
|
||||
* Integer.
|
||||
*/
|
||||
public int getEventId() {
|
||||
return _record.EventID.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Event source.
|
||||
* @return
|
||||
* String.
|
||||
*/
|
||||
public String getSource() {
|
||||
return _source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status code for the facility, part of the Event ID.
|
||||
* @return
|
||||
* Status code.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return _record.EventID.intValue() & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Record number of the record. This value can be used with the EVENTLOG_SEEK_READ flag in
|
||||
* the ReadEventLog function to begin reading at a specified record.
|
||||
* @return
|
||||
* Integer.
|
||||
*/
|
||||
public int getRecordNumber() {
|
||||
return _record.RecordNumber.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Record length, with data.
|
||||
* @return
|
||||
* Number of bytes in the record including data.
|
||||
*/
|
||||
public int getLength() {
|
||||
return _record.Length.intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Strings associated with this event.
|
||||
* @return
|
||||
* Array of strings or null.
|
||||
*/
|
||||
public String[] getStrings() {
|
||||
return _strings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event log type.
|
||||
* @return
|
||||
* Event log type.
|
||||
*/
|
||||
public EventLogType getType() {
|
||||
switch(_record.EventType.intValue()) {
|
||||
case WinNT.EVENTLOG_SUCCESS:
|
||||
case WinNT.EVENTLOG_INFORMATION_TYPE:
|
||||
return EventLogType.Informational;
|
||||
case WinNT.EVENTLOG_AUDIT_FAILURE:
|
||||
return EventLogType.AuditFailure;
|
||||
case WinNT.EVENTLOG_AUDIT_SUCCESS:
|
||||
return EventLogType.AuditSuccess;
|
||||
case WinNT.EVENTLOG_ERROR_TYPE:
|
||||
return EventLogType.Error;
|
||||
case WinNT.EVENTLOG_WARNING_TYPE:
|
||||
return EventLogType.Warning;
|
||||
default:
|
||||
throw new RuntimeException("Invalid type: " + _record.EventType.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw data associated with the record.
|
||||
* @return
|
||||
* Array of bytes or null.
|
||||
*/
|
||||
public byte[] getData() {
|
||||
return _data;
|
||||
}
|
||||
|
||||
public EventLogRecord(Pointer pevlr) {
|
||||
_record = new EVENTLOGRECORD(pevlr);
|
||||
_source = pevlr.getString(_record.size(), true);
|
||||
// data
|
||||
if (_record.DataLength.intValue() > 0) {
|
||||
_data = pevlr.getByteArray(_record.DataOffset.intValue(),
|
||||
_record.DataLength.intValue());
|
||||
}
|
||||
// strings
|
||||
if (_record.NumStrings.intValue() > 0) {
|
||||
ArrayList<String> strings = new ArrayList<String>();
|
||||
int count = _record.NumStrings.intValue();
|
||||
long offset = _record.StringOffset.intValue();
|
||||
while(count > 0) {
|
||||
String s = pevlr.getString(offset, true);
|
||||
strings.add(s);
|
||||
offset += s.length() * Native.WCHAR_SIZE;
|
||||
offset += Native.WCHAR_SIZE;
|
||||
count--;
|
||||
}
|
||||
_strings = strings.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An iterator for Event Log entries.
|
||||
*/
|
||||
public static class EventLogIterator
|
||||
implements Iterable<EventLogRecord>, Iterator<EventLogRecord> {
|
||||
|
||||
private HANDLE _h = null;
|
||||
private Memory _buffer = new Memory(1024 * 64); // memory buffer to store events
|
||||
private boolean _done = false; // no more events
|
||||
private int _dwRead = 0; // number of bytes remaining in the current buffer
|
||||
private Pointer _pevlr = null; // pointer to the current record
|
||||
private int _flags = WinNT.EVENTLOG_FORWARDS_READ;
|
||||
|
||||
public EventLogIterator(String sourceName) {
|
||||
this(null, sourceName, WinNT.EVENTLOG_FORWARDS_READ);
|
||||
}
|
||||
|
||||
public EventLogIterator(String serverName, String sourceName, int flags) {
|
||||
_flags = flags;
|
||||
_h = Advapi32.INSTANCE.OpenEventLog(serverName, sourceName);
|
||||
if (_h == null) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean read() {
|
||||
// finished or bytes remain, don't read any new data
|
||||
if (_done || _dwRead > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IntByReference pnBytesRead = new IntByReference();
|
||||
IntByReference pnMinNumberOfBytesNeeded = new IntByReference();
|
||||
|
||||
if (! Advapi32.INSTANCE.ReadEventLog(_h,
|
||||
WinNT.EVENTLOG_SEQUENTIAL_READ | _flags,
|
||||
0, _buffer, (int) _buffer.size(), pnBytesRead, pnMinNumberOfBytesNeeded)) {
|
||||
|
||||
int rc = Kernel32.INSTANCE.GetLastError();
|
||||
|
||||
// not enough bytes in the buffer, resize
|
||||
if (rc == W32Errors.ERROR_INSUFFICIENT_BUFFER) {
|
||||
_buffer = new Memory(pnMinNumberOfBytesNeeded.getValue());
|
||||
|
||||
if (! Advapi32.INSTANCE.ReadEventLog(_h,
|
||||
WinNT.EVENTLOG_SEQUENTIAL_READ | _flags,
|
||||
0, _buffer, (int) _buffer.size(), pnBytesRead, pnMinNumberOfBytesNeeded)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
} else {
|
||||
// read failed, no more entries or error
|
||||
close();
|
||||
if (rc != W32Errors.ERROR_HANDLE_EOF) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_dwRead = pnBytesRead.getValue();
|
||||
_pevlr = _buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call close() in the case when the caller needs to abandon the iterator before
|
||||
* the iteration completes.
|
||||
*/
|
||||
public void close() {
|
||||
_done = true;
|
||||
if (_h != null) {
|
||||
if (! Advapi32.INSTANCE.CloseEventLog(_h)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
_h = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<EventLogRecord> iterator() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
read();
|
||||
return ! _done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventLogRecord next() {
|
||||
read();
|
||||
EventLogRecord record = new EventLogRecord(_pevlr);
|
||||
_dwRead -= record.getLength();
|
||||
_pevlr = _pevlr.share(record.getLength());
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.IntegerType;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* @author dblock[at]dblock[dot]org
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public interface BaseTSD extends StdCallLibrary {
|
||||
/**
|
||||
* Signed long type for pointer precision.
|
||||
* Use when casting a pointer to a long to perform pointer arithmetic.
|
||||
*/
|
||||
public static class LONG_PTR extends IntegerType {
|
||||
public LONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public LONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signed SIZE_T.
|
||||
*/
|
||||
public static class SSIZE_T extends LONG_PTR {
|
||||
public SSIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SSIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned LONG_PTR.
|
||||
*/
|
||||
public static class ULONG_PTR extends IntegerType {
|
||||
public ULONG_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public ULONG_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsigned DWORD_PTR.
|
||||
*/
|
||||
public static class DWORD_PTR extends IntegerType {
|
||||
public DWORD_PTR() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public DWORD_PTR(long value) {
|
||||
super(Pointer.SIZE, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of bytes to which a pointer can point.
|
||||
* Use for a count that must span the full range of a pointer.
|
||||
*/
|
||||
public static class SIZE_T extends ULONG_PTR {
|
||||
public SIZE_T() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public SIZE_T(long value) {
|
||||
super(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -17,13 +17,15 @@ import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinCrypt.CRYPTPROTECT_PROMPTSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinCrypt.DATA_BLOB;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Crypt32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Crypt32 extends W32API {
|
||||
public interface Crypt32 extends StdCallLibrary {
|
||||
|
||||
Crypt32 INSTANCE = (Crypt32) Native.loadLibrary("Crypt32",
|
||||
Crypt32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
+15
-1
@@ -1,3 +1,15 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.NativeLong;
|
||||
@@ -6,6 +18,7 @@ import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
|
||||
/**
|
||||
@@ -13,7 +26,7 @@ import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
* Windows SDK 6.0a
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class DsGetDC {
|
||||
public interface DsGetDC extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* The DOMAIN_CONTROLLER_INFO structure is used with the DsGetDcName
|
||||
@@ -203,6 +216,7 @@ public abstract class DsGetDC {
|
||||
* @param count
|
||||
* Number of domain trusts.
|
||||
* @return
|
||||
* An array of domain trusts.
|
||||
*/
|
||||
public DS_DOMAIN_TRUSTS[] getTrusts(int count) {
|
||||
return (DS_DOMAIN_TRUSTS[]) t.toArray(count);
|
||||
@@ -0,0 +1,316 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinDef.HBITMAP;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFO;
|
||||
import com.sun.jna.platform.win32.WinGDI.BITMAPINFOHEADER;
|
||||
import com.sun.jna.platform.win32.WinGDI.RGNDATA;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>gdi32.dll</code>. */
|
||||
public interface GDI32 extends StdCallLibrary {
|
||||
|
||||
GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
/**
|
||||
* The ExtCreateRegion function creates a region from the specified region and transformation data.
|
||||
* @param lpXform
|
||||
* Pointer to an XFORM structure that defines the transformation to be performed on the region. If this pointer is NULL,
|
||||
* the identity transformation is used.
|
||||
* @param nCount
|
||||
* Specifies the number of bytes pointed to by lpRgnData.
|
||||
* @param lpRgnData
|
||||
* Pointer to a RGNDATA structure that contains the region data in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the value of the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
public HRGN ExtCreateRegion(Pointer lpXform, int nCount, RGNDATA lpRgnData);
|
||||
|
||||
/**
|
||||
* The CombineRgn function combines two regions and stores the result in a third region.
|
||||
* The two regions are combined according to the specified mode.
|
||||
* @param hrgnDest
|
||||
* Handle to a new region with dimensions defined by combining two other regions.
|
||||
* @param hrgnSrc1
|
||||
* Handle to the first of two regions to be combined.
|
||||
* @param hrgnSrc2
|
||||
* Handle to the second of two regions to be combined.
|
||||
* @param fnCombineMode
|
||||
* Specifies a mode indicating how the two regions will be combined.
|
||||
* @return
|
||||
* The return value specifies the type of the resulting region.
|
||||
*/
|
||||
int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
|
||||
int fnCombineMode);
|
||||
|
||||
/**
|
||||
* The CreateRectRgn function creates a rectangular region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The CreateRoundRectRgn function creates a rectangular region with rounded corners.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the region in logical units.
|
||||
* @param nWidthEllipse
|
||||
* Specifies the width of the ellipse used to create the rounded corners in logical units.
|
||||
* @param nHeightEllipse
|
||||
* Specifies the height of the ellipse used to create the rounded corners in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect, int nWidthEllipse, int nHeightEllipse);
|
||||
|
||||
/**
|
||||
* The CreatePolyPolygonRgn function creates a region consisting of a series
|
||||
* of polygons. The polygons can overlap.
|
||||
* @param lppt
|
||||
* Pointer to an array of POINT structures that define the vertices of the polygons in logical units.
|
||||
* The polygons are specified consecutively. Each polygon is presumed closed and each vertex is
|
||||
* specified only once.
|
||||
* @param lpPolyCounts
|
||||
* Pointer to an array of integers, each of which specifies the number of points in one of the polygons
|
||||
* in the array pointed to by lppt.
|
||||
* @param nCount
|
||||
* Specifies the total number of integers in the array pointed to by lpPolyCounts.
|
||||
* @param fnPolyFillMode
|
||||
* Specifies the fill mode used to determine which pixels are in the region.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the region.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HRGN CreatePolyPolygonRgn(WinUser.POINT[] lppt, int[] lpPolyCounts,
|
||||
int nCount, int fnPolyFillMode);
|
||||
|
||||
/**
|
||||
* The SetRectRgn function converts a region into a rectangular region with the specified coordinates.
|
||||
* @param hrgn
|
||||
* Handle to the region.
|
||||
* @param nLeftRect
|
||||
* Specifies the x-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nTopRect
|
||||
* Specifies the y-coordinate of the upper-left corner of the rectangular region in logical units.
|
||||
* @param nRightRect
|
||||
* Specifies the x-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @param nBottomRect
|
||||
* Specifies the y-coordinate of the lower-right corner of the rectangular region in logical units.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect, int nRightRect,
|
||||
int nBottomRect);
|
||||
|
||||
/**
|
||||
* The SetPixel function sets the pixel at the specified coordinates to the specified color.
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @param x
|
||||
* Specifies the x-coordinate, in logical units, of the point to be set.
|
||||
* @param y
|
||||
* Specifies the y-coordinate, in logical units, of the point to be set.
|
||||
* @param crColor
|
||||
* Specifies the color to be used to paint the point. To create a COLORREF color value, use the RGB macro.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the RGB value that the function sets the pixel to.
|
||||
* This value may differ from the color specified by crColor; that occurs when an exact match for the
|
||||
* specified color cannot be found. If the function fails, the return value is 1. To get extended error
|
||||
* information, call GetLastError. This can be the following value.
|
||||
*/
|
||||
int SetPixel(HDC hDC, int x, int y, int crColor);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
|
||||
* @param hDC
|
||||
* Handle to an existing DC. If this handle is NULL, the function creates a memory DC compatible with the
|
||||
* application's current screen.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to a memory DC.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HDC CreateCompatibleDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The DeleteDC function deletes the specified device context (DC).
|
||||
* @param hDC
|
||||
* Handle to the device context.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteDC(HDC hDC);
|
||||
|
||||
/**
|
||||
* The CreateDIBitmap function creates a compatible bitmap (DDB) from a DIB and, optionally,
|
||||
* sets the bitmap bits.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param lpbmih
|
||||
* Pointer to a bitmap information header structure, which may be one of those shown in the following table.
|
||||
* @param fdwInit
|
||||
* Specifies how the system initializes the bitmap bits.
|
||||
* @param lpbInit
|
||||
* Pointer to an array of bytes containing the initial bitmap data.
|
||||
* @param lpbmi
|
||||
* Pointer to a BITMAPINFO structure that describes the dimensions and color format of
|
||||
* the array pointed to by the lpbInit parameter.
|
||||
* @param fuUsage
|
||||
* Specifies whether the bmiColors member of the BITMAPINFO structure was initialized and, if so,
|
||||
* whether bmiColors contains explicit red, green, blue (RGB) values or palette indexes. The
|
||||
* fuUsage parameter must be one of the following values.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap.
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih, int fdwInit,
|
||||
Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
|
||||
|
||||
/**
|
||||
* The CreateDIBSection function creates a DIB that applications can write to directly.
|
||||
* The function gives you a pointer to the location of the bitmap bit values. You can supply
|
||||
* a handle to a file-mapping object that the function will use to create the bitmap, or you
|
||||
* can let the system allocate the memory for the bitmap.
|
||||
* @param hDC
|
||||
* Handle to a device context. If the value of iUsage is DIB_PAL_COLORS, the function uses this
|
||||
* device context's logical palette to initialize the DIB colors.
|
||||
* @param pbmi
|
||||
* Pointer to a BITMAPINFO structure that specifies various attributes of the DIB, including
|
||||
* the bitmap dimensions and colors.
|
||||
* @param iUsage
|
||||
* Specifies the type of data contained in the bmiColors array member of the BITMAPINFO structure
|
||||
* pointed to by pbmi (either logical palette indexes or literal RGB values).
|
||||
* @param ppvBits
|
||||
* Pointer to a variable that receives a pointer to the location of the DIB bit values.
|
||||
* @param hSection
|
||||
* Handle to a file-mapping object that the function will use to create the DIB. This parameter can be NULL.
|
||||
* @param dwOffset
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
* @return
|
||||
* Specifies the offset from the beginning of the file-mapping object referenced by hSection where storage
|
||||
* for the bitmap bit values is to begin.
|
||||
*/
|
||||
HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
|
||||
PointerByReference ppvBits, Pointer hSection, int dwOffset);
|
||||
|
||||
/**
|
||||
* The CreateCompatibleBitmap function creates a bitmap compatible with the device that is
|
||||
* associated with the specified device context.
|
||||
* @param hDC
|
||||
* Handle to a device context.
|
||||
* @param width
|
||||
* Specifies the bitmap width, in pixels.
|
||||
* @param height
|
||||
* Specifies the bitmap height, in pixels.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the compatible bitmap (DDB).
|
||||
* If the function fails, the return value is NULL.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
|
||||
|
||||
/**
|
||||
* The SelectObject function selects an object into the specified device context (DC).
|
||||
* The new object replaces the previous object of the same type.
|
||||
* @param hDC
|
||||
* Handle to the DC.
|
||||
* @param hGDIObj
|
||||
* Handle to the object to be selected.
|
||||
* @return
|
||||
* If the selected object is not a region and the function succeeds, the return value
|
||||
* is a handle to the object being replaced. If the selected object is a region and the
|
||||
* function succeeds, the return value is one of the REGION values.
|
||||
*/
|
||||
HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
|
||||
|
||||
/**
|
||||
* The DeleteObject function deletes a logical pen, brush, font, bitmap, region, or palette,
|
||||
* freeing all system resources associated with the object. After the object is deleted, the
|
||||
* specified handle is no longer valid.
|
||||
* @param hObject
|
||||
* Handle to a logical pen, brush, font, bitmap, region, or palette.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the specified handle is not valid or is currently selected into a DC, the return value is zero.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DeleteObject(HANDLE hObject);
|
||||
|
||||
/** The GetDeviceCaps function retrieves device-specific information for
|
||||
* the specified device.
|
||||
* @param hdc A handle to the DC.
|
||||
* @param nIndex The item to be returned.
|
||||
* @return
|
||||
* The return value specifies the value of the desired item. When
|
||||
* <i>nIndex</i> is <code>BITSPIXEL</code> and the device has 15bpp or
|
||||
* 16bpp, the return value is 16.
|
||||
*/
|
||||
int GetDeviceCaps(HDC hdc, int nIndex);
|
||||
|
||||
/** The GetDIBits function retrieves the bits fo the specified compatible
|
||||
* bitmap and copies them into a buffer as a DIB using the specified
|
||||
* format.
|
||||
* @param hdc A handle to the device context.
|
||||
* @param hbmp A handle to the bitmap. This must be a compatible bitmap
|
||||
* (DDB).
|
||||
* @param uStartScan The first scan line to retrieve
|
||||
* @param cScanLines The number of scan lines to retrieve.
|
||||
* @param lpvBits A pointer to a buffer to receive the bitmap data. If
|
||||
* this parameter is <code>null</code>, the function passes the dimensions
|
||||
* and format of the bitmap to the {@link BITMAPINFO} structure pointed to
|
||||
* by the <i>lpbi</i> parameter.
|
||||
* @param lpbi A pointer to a {@link BITMAPINFO} structure that specifies
|
||||
* the desired format for the DIB data.
|
||||
* @param uUsage The format of the bmiColors member of the {@link
|
||||
* BITMAPINFO} structure.
|
||||
*/
|
||||
int GetDIBits(HDC hdc, HBITMAP hbmp, int uStartScan, int cScanLines, Pointer lpvBits, BITMAPINFO lpbi, int uUsage);
|
||||
}
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -14,13 +14,14 @@ package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from Guid.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Guid {
|
||||
public interface Guid extends StdCallLibrary {
|
||||
|
||||
public static class GUID extends Structure {
|
||||
|
||||
@@ -0,0 +1,957 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.WinBase.MEMORYSTATUSEX;
|
||||
import com.sun.jna.platform.win32.WinBase.SYSTEM_INFO;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HMODULE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFO;
|
||||
import com.sun.jna.platform.win32.WinNT.OSVERSIONINFOEX;
|
||||
import com.sun.jna.ptr.ByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/** Definition (incomplete) of <code>kernel32.dll</code>. */
|
||||
public interface Kernel32 extends StdCallLibrary {
|
||||
|
||||
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Frees the specified local memory object and invalidates its handle.
|
||||
* @param hLocal
|
||||
* A handle to the local memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL.
|
||||
* If the function fails, the return value is equal to a handle to the local memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalFree(Pointer hLocal);
|
||||
|
||||
/**
|
||||
* Frees the specified global memory object and invalidates its handle.
|
||||
* @param hGlobal
|
||||
* A handle to the global memory object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is NULL
|
||||
* If the function fails, the return value is equal to a handle to the global memory object.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer GlobalFree(Pointer hGlobal);
|
||||
|
||||
/**
|
||||
* The GetModuleHandle function retrieves a module handle for the specified module
|
||||
* if the file has been mapped into the address space of the calling process.
|
||||
* @param name
|
||||
* Pointer to a null-terminated string that contains the name of the module
|
||||
* (either a .dll or .exe file).
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the specified module.
|
||||
* If the function fails, the return value is NULL. To get extended error
|
||||
* information, call GetLastError.
|
||||
*/
|
||||
HMODULE GetModuleHandle(String name);
|
||||
|
||||
/**
|
||||
* The GetSystemTime function retrieves the current system date and time.
|
||||
* The system time is expressed in Coordinated Universal Time (UTC).
|
||||
* @param lpSystemTime
|
||||
* Pointer to a SYSTEMTIME structure to receive the current system date and time.
|
||||
*/
|
||||
void GetSystemTime(WinBase.SYSTEMTIME lpSystemTime);
|
||||
|
||||
/**
|
||||
* The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
|
||||
* @return
|
||||
* Number of milliseconds that have elapsed since the system was started.
|
||||
*/
|
||||
int GetTickCount();
|
||||
|
||||
/**
|
||||
* The GetCurrentThreadId function retrieves the thread identifier of the calling thread.
|
||||
* @return
|
||||
* The return value is the thread identifier of the calling thread.
|
||||
*/
|
||||
int GetCurrentThreadId();
|
||||
|
||||
/**
|
||||
* The GetCurrentThread function retrieves a pseudo handle for the current thread.
|
||||
* @return
|
||||
* The return value is a pseudo handle for the current thread.
|
||||
*/
|
||||
HANDLE GetCurrentThread();
|
||||
|
||||
/**
|
||||
* This function returns the process identifier of the calling process.
|
||||
* @return
|
||||
* The return value is the process identifier of the calling process.
|
||||
*/
|
||||
int GetCurrentProcessId();
|
||||
|
||||
/**
|
||||
* This function returns a pseudohandle for the current process.
|
||||
* @return
|
||||
* The return value is a pseudohandle to the current process.
|
||||
*/
|
||||
HANDLE GetCurrentProcess();
|
||||
|
||||
/**
|
||||
* The GetProcessId function retrieves the process identifier of the
|
||||
* specified process.
|
||||
* @param process
|
||||
* Handle to the process. The handle must have the PROCESS_QUERY_INFORMATION access right.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the process identifier of the
|
||||
* specified process. If the function fails, the return value is zero. To get
|
||||
* extended error information, call GetLastError.
|
||||
*/
|
||||
int GetProcessId(HANDLE process);
|
||||
|
||||
/**
|
||||
* The GetProcessVersion function retrieves the major and minor version numbers of the system
|
||||
* on which the specified process expects to run.
|
||||
* @param processId
|
||||
* Process identifier of the process of interest. A value of zero specifies the
|
||||
* calling process.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the version of the system on
|
||||
* which the process expects to run. The high word of the return value contains
|
||||
* the major version number. The low word of the return value contains the minor
|
||||
* version number. If the function fails, the return value is zero. To get extended
|
||||
* error information, call GetLastError. The function fails if ProcessId is an
|
||||
* invalid value.
|
||||
*/
|
||||
int GetProcessVersion(int processId);
|
||||
|
||||
/**
|
||||
* Retrieves the termination status of the specified process.
|
||||
* @param hProcess A handle to the process.
|
||||
* @param lpExitCode A pointer to a variable to receive the process termination status.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetExitCodeProcess(HANDLE hProcess, IntByReference lpExitCode);
|
||||
|
||||
/**
|
||||
* Terminates the specified process and all of its threads.
|
||||
* @param hProcess A handle to the process to be terminated.
|
||||
* @param uExitCode The exit code to be used by the process and threads
|
||||
* terminated as a result of this call.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean TerminateProcess(HANDLE hProcess, int uExitCode);
|
||||
|
||||
/**
|
||||
* The GetLastError function retrieves the calling thread's last-error code value.
|
||||
* The last-error code is maintained on a per-thread basis. Multiple threads do not
|
||||
* overwrite each other's last-error code.
|
||||
* @return
|
||||
* The return value is the calling thread's last-error code value.
|
||||
*/
|
||||
int GetLastError();
|
||||
|
||||
/**
|
||||
* The SetLastError function sets the last-error code for the calling thread.
|
||||
* @param dwErrCode
|
||||
* Last-error code for the thread.
|
||||
*/
|
||||
void SetLastError(int dwErrCode);
|
||||
|
||||
/**
|
||||
* The GetDriveType function determines whether a disk drive is a removable,
|
||||
* fixed, CD-ROM, RAM disk, or network drive.
|
||||
* @param lpRootPathName
|
||||
* Pointer to a null-terminated string that specifies the root directory of
|
||||
* the disk to return information about. A trailing backslash is required.
|
||||
* If this parameter is NULL, the function uses the root of the current directory.
|
||||
* @return
|
||||
* The return value specifies the type of drive.
|
||||
*/
|
||||
int GetDriveType(String lpRootPathName);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, PointerByReference lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The FormatMessage function formats a message string. The function requires a
|
||||
* message definition as input. The message definition can come from a buffer
|
||||
* passed into the function. It can come from a message table resource in an
|
||||
* already-loaded module. Or the caller can ask the function to search the
|
||||
* system's message table resource(s) for the message definition. The function
|
||||
* finds the message definition in a message table resource based on a message
|
||||
* identifier and a language identifier. The function copies the formatted message
|
||||
* text to an output buffer, processing any embedded insert sequences if requested.
|
||||
* @param dwFlags
|
||||
* Formatting options, and how to interpret the lpSource parameter. The low-order
|
||||
* byte of dwFlags specifies how the function handles line breaks in the output
|
||||
* buffer. The low-order byte can also specify the maximum width of a formatted
|
||||
* output line.
|
||||
* @param lpSource
|
||||
* Location of the message definition.
|
||||
* @param dwMessageId
|
||||
* Message identifier for the requested message.
|
||||
* @param dwLanguageId
|
||||
* Language identifier for the requested message.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives the null-terminated string that specifies the
|
||||
* formatted message.
|
||||
* @param nSize
|
||||
* If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies
|
||||
* the size of the output buffer, in TCHARs. If FORMAT_MESSAGE_ALLOCATE_BUFFER is
|
||||
* set, this parameter specifies the minimum number of TCHARs to allocate for an
|
||||
* output buffer.
|
||||
* @param va_list
|
||||
* Pointer to an array of values that are used as insert values in the formatted message.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of TCHARs stored in
|
||||
* the output buffer, excluding the terminating null character. If the function
|
||||
* fails, the return value is zero. To get extended error information, call
|
||||
* GetLastError.
|
||||
*/
|
||||
int FormatMessage(int dwFlags, Pointer lpSource, int dwMessageId,
|
||||
int dwLanguageId, Buffer lpBuffer,
|
||||
int nSize, Pointer va_list);
|
||||
|
||||
/**
|
||||
* The CreateFile function creates or opens a file, file stream, directory, physical
|
||||
* disk, volume, console buffer, tape drive, communications resource, mailslot, or
|
||||
* named pipe. The function returns a handle that can be used to access an object.
|
||||
* @param lpFileName
|
||||
* A pointer to a null-terminated string that specifies the name of an object to create or open.
|
||||
* @param dwDesiredAccess
|
||||
* The access to the object, which can be read, write, or both.
|
||||
* @param dwShareMode
|
||||
* The sharing mode of an object, which can be read, write, both, or none.
|
||||
* @param lpSecurityAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether or not
|
||||
* the returned handle can be inherited by child processes. If lpSecurityAttributes
|
||||
* is NULL, the handle cannot be inherited.
|
||||
* @param dwCreationDisposition
|
||||
* An action to take on files that exist and do not exist.
|
||||
* @param dwFlagsAndAttributes
|
||||
* The file attributes and flags.
|
||||
* @param hTemplateFile
|
||||
* Handle to a template file with the GENERIC_READ access right. The template file
|
||||
* supplies file attributes and extended attributes for the file that is being
|
||||
* created. This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to a specified file.
|
||||
* If a specified file exists before the function call and dwCreationDisposition is
|
||||
* CREATE_ALWAYS or OPEN_ALWAYS, a call to GetLastError returns ERROR_ALREADY_EXISTS,
|
||||
* even when the function succeeds. If a file does not exist before the call,
|
||||
* GetLastError returns 0 (zero). If the function fails, the return value is
|
||||
* INVALID_HANDLE_VALUE. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFile(String lpFileName, int dwDesiredAccess, int dwShareMode,
|
||||
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition,
|
||||
int dwFlagsAndAttributes, HANDLE hTemplateFile);
|
||||
|
||||
|
||||
/**
|
||||
* The CreateDirectory function creates a new directory. If the underlying file
|
||||
* system supports security on files and directories, the function applies a
|
||||
* specified security descriptor to the new directory.
|
||||
* @param lpPathName
|
||||
* Pointer to a null-terminated string that specifies the path of the directory
|
||||
* to be created.
|
||||
* @param lpSecurityAttributes
|
||||
* Pointer to a SECURITY_ATTRIBUTES structure. The lpSecurityDescriptor member
|
||||
* of the structure specifies a security descriptor for the new directory. If
|
||||
* lpSecurityAttributes is NULL, the directory gets a default security descriptor.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. If the function fails,
|
||||
* the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean CreateDirectory(String lpPathName,
|
||||
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||
|
||||
/**
|
||||
* Reads data from the specified file or input/output (I/O) device. Reads
|
||||
* occur at the position specified by the file pointer if supported by the
|
||||
* device.
|
||||
*
|
||||
* This function is designed for both synchronous and asynchronous
|
||||
* operations. For a similar function designed solely for asynchronous
|
||||
* operation, see ReadFileEx
|
||||
*
|
||||
* @param hFile A handle to the device (for example, a file, file stream,
|
||||
* physical disk, volume, console buffer, tape drive, socket, communications
|
||||
* resource, mailslot, or pipe).
|
||||
* @param lpBuffer A pointer to the buffer that receives the data read from a file or device.
|
||||
* @param nNumberOfBytesToRead The maximum number of bytes to be read.
|
||||
* @param lpNumberOfBytesRead A pointer to the variable that receives the number of bytes
|
||||
* read when using a synchronous hFile parameter
|
||||
* @param lpOverlapped A pointer to an OVERLAPPED structure is required if the hFile
|
||||
* parameter was opened with FILE_FLAG_OVERLAPPED, otherwise it can be NULL.
|
||||
* @return If the function succeeds, the return value is nonzero (TRUE).
|
||||
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
|
||||
* To get extended error information, call the GetLastError function.
|
||||
*
|
||||
* Note The GetLastError code ERROR_IO_PENDING is not a failure; it designates the read
|
||||
* operation is pending completion asynchronously. For more information, see Remarks.
|
||||
*/
|
||||
boolean ReadFile(
|
||||
HANDLE hFile,
|
||||
Buffer lpBuffer,
|
||||
int nNumberOfBytesToRead,
|
||||
IntByReference lpNumberOfBytesRead,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
/**
|
||||
* Creates an input/output (I/O) completion port and associates it with a specified
|
||||
* file handle, or creates an I/O completion port that is not yet associated with a
|
||||
* file handle, allowing association at a later time.
|
||||
* @param FileHandle
|
||||
* An open file handle or INVALID_HANDLE_VALUE.
|
||||
* @param ExistingCompletionPort
|
||||
* A handle to an existing I/O completion port or NULL.
|
||||
* @param CompletionKey
|
||||
* The per-handle user-defined completion key that is included in every I/O completion
|
||||
* packet for the specified file handle.
|
||||
* @param NumberOfConcurrentThreads
|
||||
* The maximum number of threads that the operating system can allow to concurrently
|
||||
* process I/O completion packets for the I/O completion port.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to an I/O completion port:
|
||||
* If the ExistingCompletionPort parameter was NULL, the return value is a new handle.
|
||||
* If the ExistingCompletionPort parameter was a valid I/O completion port handle, the return value is that same handle.
|
||||
* If the FileHandle parameter was a valid handle, that file handle is now associated with the returned I/O completion port.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call the GetLastError function.
|
||||
*/
|
||||
HANDLE CreateIoCompletionPort(HANDLE FileHandle, HANDLE ExistingCompletionPort,
|
||||
Pointer CompletionKey, int NumberOfConcurrentThreads);
|
||||
|
||||
/**
|
||||
* Attempts to dequeue an I/O completion packet from the specified I/O completion
|
||||
* port. If there is no completion packet queued, the function waits for a pending
|
||||
* I/O operation associated with the completion port to complete.
|
||||
* @param CompletionPort
|
||||
* A handle to the completion port.
|
||||
* @param lpNumberOfBytes
|
||||
* A pointer to a variable that receives the number of bytes transferred during
|
||||
* an I/O operation that has completed.
|
||||
* @param lpCompletionKey
|
||||
* A pointer to a variable that receives the completion key value associated with
|
||||
* the file handle whose I/O operation has completed.
|
||||
* @param lpOverlapped
|
||||
* A pointer to a variable that receives the address of the OVERLAPPED structure
|
||||
* that was specified when the completed I/O operation was started.
|
||||
* @param dwMilliseconds
|
||||
* The number of milliseconds that the caller is willing to wait for a completion
|
||||
* packet to appear at the completion port.
|
||||
* @return
|
||||
* Returns nonzero (TRUE) if successful or zero (FALSE) otherwise.
|
||||
*/
|
||||
boolean GetQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
IntByReference lpNumberOfBytes, ByReference lpCompletionKey,
|
||||
PointerByReference lpOverlapped, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Posts an I/O completion packet to an I/O completion port.
|
||||
* @param CompletionPort
|
||||
* A handle to an I/O completion port to which the I/O completion packet is to be posted.
|
||||
* @param dwNumberOfBytesTransferred
|
||||
* The value to be returned through the lpNumberOfBytesTransferred parameter of the GetQueuedCompletionStatus function.
|
||||
* @param dwCompletionKey
|
||||
* The value to be returned through the lpCompletionKey parameter of the GetQueuedCompletionStatus function.
|
||||
* @param lpOverlapped
|
||||
* The value to be returned through the lpOverlapped parameter of the GetQueuedCompletionStatus function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError .
|
||||
*/
|
||||
boolean PostQueuedCompletionStatus(HANDLE CompletionPort,
|
||||
int dwNumberOfBytesTransferred, Pointer dwCompletionKey,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Waits until the specified object is in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForSingleObjectEx function.
|
||||
* To wait for multiple objects, use the WaitForMultipleObjects.
|
||||
* @param hHandle
|
||||
* A handle to the object. For a list of the object types whose handles can be specified, see the following Remarks section.
|
||||
* If this handle is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handle must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the object is signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the object is not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the object is signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForSingleObject(HANDLE hHandle, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses.
|
||||
* To enter an alertable wait state, use the WaitForMultipleObjectsEx function.
|
||||
* @param nCount
|
||||
* The number of object handles in the array pointed to by lpHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS.
|
||||
* @param hHandle
|
||||
* An array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles to objects of different types.
|
||||
* It may not contain multiple copies of the same handle.
|
||||
* If one of these handles is closed while the wait is still pending, the function's behavior is undefined.
|
||||
* The handles must have the SYNCHRONIZE access right. For more information, see Standard Access Rights.
|
||||
* @param bWaitAll
|
||||
* If this parameter is TRUE, the function returns when the state of all objects in the lpHandles array is signaled.
|
||||
* If FALSE, the function returns when the state of any one of the objects is set to signaled.
|
||||
* In the latter case, the return value indicates the object whose state caused the function to return.
|
||||
* @param dwMilliseconds
|
||||
* The time-out interval, in milliseconds. If a nonzero value is specified, the function waits until the specified objects are signaled or the interval elapses.
|
||||
* If dwMilliseconds is zero, the function does not enter a wait state if the specified objects are not signaled; it always returns immediately.
|
||||
* If dwMilliseconds is INFINITE, the function will return only when the specified objects are signaled.
|
||||
* @return
|
||||
* If the function succeeds, the return value indicates the event that caused the function to return.
|
||||
*/
|
||||
int WaitForMultipleObjects(int nCount, HANDLE[] hHandle, boolean bWaitAll, int dwMilliseconds);
|
||||
|
||||
/**
|
||||
* The DuplicateHandle function duplicates an object handle.
|
||||
*
|
||||
* @param hSourceProcessHandle
|
||||
* Handle to the process with the handle to duplicate.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param hSourceHandle
|
||||
* Handle to duplicate. This is an open object handle that is valid in the
|
||||
* context of the source process.
|
||||
* @param hTargetProcessHandle
|
||||
* Handle to the process that is to receive the duplicated handle.
|
||||
* The handle must have the PROCESS_DUP_HANDLE access right.
|
||||
* @param lpTargetHandle
|
||||
* Pointer to a variable that receives the duplicate handle. This handle value is valid in
|
||||
* the context of the target process. If hSourceHandle is a pseudo handle returned by
|
||||
* GetCurrentProcess or GetCurrentThread, DuplicateHandle converts it to a real handle to
|
||||
* a process or thread, respectively.
|
||||
* @param dwDesiredAccess
|
||||
* Access requested for the new handle.
|
||||
* @param bInheritHandle
|
||||
* Indicates whether the handle is inheritable.
|
||||
* @param dwOptions
|
||||
* Optional actions.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle,
|
||||
HANDLE hTargetProcessHandle, HANDLEByReference lpTargetHandle,
|
||||
int dwDesiredAccess, boolean bInheritHandle, int dwOptions);
|
||||
|
||||
/**
|
||||
* The CloseHandle function closes an open object handle.
|
||||
*
|
||||
* @param hObject
|
||||
* Handle to an open object. This parameter can be a pseudo handle or INVALID_HANDLE_VALUE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean CloseHandle(HANDLE hObject);
|
||||
|
||||
// TODO: figure out how OVERLAPPED is used and apply an appropriate mapping
|
||||
interface OVERLAPPED_COMPLETION_ROUTINE extends StdCallCallback {
|
||||
void callback(int errorCode, int nBytesTransferred,
|
||||
WinBase.OVERLAPPED overlapped);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves information that describes the changes within the specified directory.
|
||||
* The function does not report changes to the specified directory itself.
|
||||
* Note: there's no ReadDirectoryChangesA.
|
||||
* @param directory
|
||||
* A handle to the directory to be monitored. This directory must be opened with the
|
||||
* FILE_LIST_DIRECTORY access right.
|
||||
* @param info
|
||||
* A pointer to the DWORD-aligned formatted buffer in which the read results are to be returned.
|
||||
* @param length
|
||||
* The size of the buffer that is pointed to by the lpBuffer parameter, in bytes.
|
||||
* @param watchSubtree
|
||||
* If this parameter is TRUE, the function monitors the directory tree rooted at the specified
|
||||
* directory. If this parameter is FALSE, the function monitors only the directory specified by
|
||||
* the hDirectory parameter.
|
||||
* @param notifyFilter
|
||||
* The filter criteria that the function checks to determine if the wait operation has completed.
|
||||
* @param bytesReturned
|
||||
* For synchronous calls, this parameter receives the number of bytes transferred into the
|
||||
* lpBuffer parameter. For asynchronous calls, this parameter is undefined. You must use an asynchronous
|
||||
* notification technique to retrieve the number of bytes transferred.
|
||||
* @param overlapped
|
||||
* A pointer to an OVERLAPPED structure that supplies data to be used during asynchronous operation.
|
||||
* Otherwise, this value is NULL. The Offset and OffsetHigh members of this structure are not used.
|
||||
* @param completionRoutine
|
||||
* A pointer to a completion routine to be called when the operation has been completed or canceled and
|
||||
* the calling thread is in an alertable wait state.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero. For synchronous calls, this means that the
|
||||
* operation succeeded. For asynchronous calls, this indicates that the operation was successfully queued.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the network redirector or the target file system does not support this operation, the function
|
||||
* fails with ERROR_INVALID_FUNCTION.
|
||||
*/
|
||||
public boolean ReadDirectoryChangesW(HANDLE directory,
|
||||
WinNT.FILE_NOTIFY_INFORMATION info, int length, boolean watchSubtree,
|
||||
int notifyFilter, IntByReference bytesReturned, WinBase.OVERLAPPED overlapped,
|
||||
OVERLAPPED_COMPLETION_ROUTINE completionRoutine);
|
||||
|
||||
/**
|
||||
* Retrieves the short path form of the specified path.
|
||||
* @param lpszLongPath
|
||||
* The path string.
|
||||
* @param lpdzShortPath
|
||||
* A pointer to a buffer to receive the null-terminated short form of the path that lpszLongPath specifies.
|
||||
* @param cchBuffer
|
||||
* The size of the buffer that lpszShortPath points to, in TCHARs.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string that is copied to
|
||||
* lpszShortPath, not including the terminating null character.
|
||||
* If the lpszShortPath buffer is too small to contain the path, the return value is the size of the buffer,
|
||||
* in TCHARs, that is required to hold the path and the terminating null character.
|
||||
* If the function fails for any other reason, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
int GetShortPathName(String lpszLongPath, char[] lpdzShortPath, int cchBuffer);
|
||||
|
||||
/**
|
||||
* The LocalAlloc function allocates the specified number of bytes from the heap.
|
||||
* Windows memory management does not provide a separate local heap and global heap.
|
||||
* @param type
|
||||
* Memory allocation attributes. The default is the LMEM_FIXED value.
|
||||
* @param cbInput
|
||||
* Number of bytes to allocate. If this parameter is zero and the uFlags parameter
|
||||
* specifies LMEM_MOVEABLE, the function returns a handle to a memory object that
|
||||
* is marked as discarded.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly allocated memory object.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer LocalAlloc(int type, int cbInput);
|
||||
|
||||
/**
|
||||
* Writes data to the specified file or input/output (I/O) device.
|
||||
* @param hFile
|
||||
* A handle to the file or I/O device (for example, a file, file stream, physical disk, volume,
|
||||
* console buffer, tape drive, socket, communications resource, mailslot, or pipe).
|
||||
* @param lpBuffer
|
||||
* A pointer to the buffer containing the data to be written to the file or device.
|
||||
* @param nNumberOfBytesToWrite
|
||||
* The number of bytes to be written to the file or device.
|
||||
* @param lpNumberOfBytesWritten
|
||||
* A pointer to the variable that receives the number of bytes written when using a synchronous hFile parameter.
|
||||
* @param lpOverlapped
|
||||
* A pointer to an OVERLAPPED structure is required if the hFile parameter was opened with FILE_FLAG_OVERLAPPED,
|
||||
* otherwise this parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero (TRUE).
|
||||
* If the function fails, or is completing asynchronously, the return value is zero (FALSE).
|
||||
* To get extended error information, call the GetLastError function.
|
||||
*/
|
||||
boolean WriteFile(HANDLE hFile, byte[] lpBuffer, int nNumberOfBytesToWrite,
|
||||
IntByReference lpNumberOfBytesWritten,
|
||||
WinBase.OVERLAPPED lpOverlapped);
|
||||
|
||||
/**
|
||||
* Creates or opens a named or unnamed event object.
|
||||
* @param lpEventAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL,
|
||||
* the handle cannot be inherited by child processes.
|
||||
* @param bManualReset
|
||||
* If this parameter is TRUE, the function creates a manual-reset event object,
|
||||
* which requires the use of the ResetEvent function to set the event state to nonsignaled.
|
||||
* If this parameter is FALSE, the function creates an auto-reset event object, and system
|
||||
* automatically resets the event state to nonsignaled after a single waiting thread has
|
||||
* been released.
|
||||
* @param bInitialState
|
||||
* If this parameter is TRUE, the initial state of the event object is signaled; otherwise,
|
||||
* it is nonsignaled.
|
||||
* @param lpName
|
||||
* The name of the event object. The name is limited to MAX_PATH characters. Name comparison
|
||||
* is case sensitive.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the event object. If the named event
|
||||
* object existed before the function call, the function returns a handle to the existing object
|
||||
* and GetLastError returns ERROR_ALREADY_EXISTS.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateEvent(WinBase.SECURITY_ATTRIBUTES lpEventAttributes,
|
||||
boolean bManualReset, boolean bInitialState,
|
||||
String lpName);
|
||||
|
||||
/**
|
||||
* Sets the specified event object to the signaled state.
|
||||
* @param hEvent
|
||||
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetEvent(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Sets the specified event object to the signaled state and then resets it to the nonsignaled
|
||||
* state after releasing the appropriate number of waiting threads.
|
||||
* @param hEvent
|
||||
* A handle to the event object. The CreateEvent or OpenEvent function returns this handle.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean PulseEvent(HANDLE hEvent);
|
||||
|
||||
/**
|
||||
* Creates or opens a named or unnamed file mapping object for a specified file.
|
||||
* @param hFile
|
||||
* A handle to the file from which to create a file mapping object.
|
||||
* @param lpAttributes
|
||||
* A pointer to a SECURITY_ATTRIBUTES structure that determines whether a returned handle can be inherited by child processes. The lpSecurityDescriptor member of the SECURITY_ATTRIBUTES structure specifies a security descriptor for a new file mapping object.
|
||||
* @param flProtect
|
||||
* Specifies the page protection of the file mapping object. All mapped views of the object must be compatible with this protection.
|
||||
* @param dwMaximumSizeHigh
|
||||
* The high-order DWORD of the maximum size of the file mapping object.
|
||||
* @param dwMaximumSizeLow
|
||||
* The low-order DWORD of the maximum size of the file mapping object.
|
||||
* @param lpName
|
||||
* The name of the file mapping object.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a handle to the newly created file mapping object.
|
||||
* If the object exists before the function call, the function returns a handle to the existing object (with its current size, not the specified size), and GetLastError returns ERROR_ALREADY_EXISTS.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE CreateFileMapping(HANDLE hFile, WinBase.SECURITY_ATTRIBUTES lpAttributes,
|
||||
int flProtect, int dwMaximumSizeHigh,
|
||||
int dwMaximumSizeLow, String lpName);
|
||||
|
||||
/**
|
||||
* Maps a view of a file mapping into the address space of a calling process.
|
||||
* @param hFileMappingObject
|
||||
* A handle to a file mapping object. The CreateFileMapping and OpenFileMapping functions return this handle.
|
||||
* @param dwDesiredAccess
|
||||
* The type of access to a file mapping object, which determines the protection of the pages.
|
||||
* @param dwFileOffsetHigh
|
||||
* A high-order DWORD of the file offset where the view begins.
|
||||
* @param dwFileOffsetLow
|
||||
* A low-order DWORD of the file offset where the view is to begin.
|
||||
* @param dwNumberOfBytesToMap
|
||||
* The number of bytes of a file mapping to map to the view.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the starting address of the mapped view.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer MapViewOfFile(HANDLE hFileMappingObject, int dwDesiredAccess,
|
||||
int dwFileOffsetHigh, int dwFileOffsetLow,
|
||||
int dwNumberOfBytesToMap);
|
||||
|
||||
/**
|
||||
* Unmaps a mapped view of a file from the calling process's address space.
|
||||
* @param lpBaseAddress
|
||||
* A pointer to the base address of the mapped view of a file that is to be unmapped.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the starting address of the mapped view.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UnmapViewOfFile(Pointer lpBaseAddress);
|
||||
|
||||
/**
|
||||
* Retrieves only the NetBIOS name of the local computer.
|
||||
*
|
||||
* @param buffer
|
||||
* A pointer to a buffer that receives the computer name or the cluster virtual server
|
||||
* name. The buffer size should be large enough to contain MAX_COMPUTERNAME_LENGTH + 1
|
||||
* characters.
|
||||
* @param lpnSize
|
||||
* On input, specifies the size of the buffer, in TCHARs. On output, the number of TCHARs
|
||||
* copied to the destination buffer, not including the terminating null character. If
|
||||
* the buffer is too small, the function fails and GetLastError returns
|
||||
* ERROR_BUFFER_OVERFLOW. The lpnSize parameter specifies the size of the buffer required,
|
||||
* including the terminating null character.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
public boolean GetComputerName(char[] buffer, IntByReference lpnSize);
|
||||
|
||||
/**
|
||||
* The OpenThread function opens an existing thread object.
|
||||
* @param dwDesiredAccess
|
||||
* Access to the thread object. This access right is checked against any security
|
||||
* descriptor for the thread.
|
||||
* @param bInheritHandle
|
||||
* If this parameter is TRUE, the new process inherits the handle. If the parameter
|
||||
* is FALSE, the handle is not inherited.
|
||||
* @param dwThreadId
|
||||
* Identifier of the thread to be opened.
|
||||
* @return
|
||||
* If the function succeeds, the return value is an open handle to the specified process.
|
||||
* If the function fails, the return value is NULL. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
HANDLE OpenThread(int dwDesiredAccess, boolean bInheritHandle, int dwThreadId);
|
||||
|
||||
/**
|
||||
* This function returns a handle to an existing process object.
|
||||
* @param fdwAccess
|
||||
* Not supported; set to zero.
|
||||
* @param fInherit
|
||||
* Not supported; set to FALSE.
|
||||
* @param IDProcess
|
||||
* Specifies the process identifier of the process to open.
|
||||
* @return
|
||||
* An open handle to the specified process indicates success.
|
||||
* NULL indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE OpenProcess(int fdwAccess, boolean fInherit, int IDProcess);
|
||||
|
||||
/**
|
||||
* The GetTempPath function retrieves the path of the directory designated
|
||||
* for temporary files.
|
||||
* @param nBufferLength
|
||||
* Size of the string buffer identified by lpBuffer, in TCHARs.
|
||||
* @param buffer
|
||||
* Pointer to a string buffer that receives the null-terminated string specifying the
|
||||
* temporary file path. The returned string ends with a backslash, for example,
|
||||
* C:\TEMP\.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in TCHARs, of the string
|
||||
* copied to lpBuffer, not including the terminating null character. If the return value
|
||||
* is greater than nBufferLength, the return value is the length, in TCHARs, of the
|
||||
* buffer required to hold the path.
|
||||
*
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
DWORD GetTempPath(DWORD nBufferLength, char[] buffer);
|
||||
|
||||
/**
|
||||
* The GetVersion function returns the current version number of the operating system.
|
||||
* @return
|
||||
* If the function succeeds, the return value includes the major and minor version numbers
|
||||
* of the operating system in the low order word, and information about the operating system
|
||||
* platform in the high order word.
|
||||
*/
|
||||
DWORD GetVersion();
|
||||
|
||||
/**
|
||||
* The GetVersionEx function obtains extended information about the version of the operating
|
||||
* system that is currently running.
|
||||
* @param lpVersionInfo
|
||||
* Pointer to an OSVERSIONINFO data structure that the function fills with operating system
|
||||
* version information.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError. The function fails if you specify an invalid value for the
|
||||
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
|
||||
*/
|
||||
boolean GetVersionEx(OSVERSIONINFO lpVersionInfo);
|
||||
|
||||
/**
|
||||
* The GetVersionEx function obtains extended information about the version of the operating
|
||||
* system that is currently running.
|
||||
* @param lpVersionInfo
|
||||
* Pointer to an OSVERSIONINFOEX data structure that the function fills with operating system
|
||||
* version information.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError. The function fails if you specify an invalid value for the
|
||||
* dwOSVersionInfoSize member of the OSVERSIONINFO or OSVERSIONINFOEX structure.
|
||||
*/
|
||||
boolean GetVersionEx(OSVERSIONINFOEX lpVersionInfo);
|
||||
|
||||
/**
|
||||
* The GetSystemInfo function returns information about the current system.
|
||||
* @param lpSystemInfo
|
||||
* Pointer to a SYSTEM_INFO structure that receives the information.
|
||||
*/
|
||||
void GetSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||
|
||||
/**
|
||||
* The GetNativeSystemInfo function retrieves information about the current system to an
|
||||
* application running under WOW64. If the function is called from a 64-bit application,
|
||||
* it is equivalent to the GetSystemInfo function.
|
||||
* @param lpSystemInfo
|
||||
* Pointer to a SYSTEM_INFO structure that receives the information.
|
||||
*/
|
||||
void GetNativeSystemInfo(SYSTEM_INFO lpSystemInfo);
|
||||
|
||||
/**
|
||||
* The IsWow64Process function determines whether the specified process is running under WOW64.
|
||||
* @param hProcess
|
||||
* Handle to a process.
|
||||
* @param Wow64Process
|
||||
* Pointer to a value that is set to TRUE if the process is running under WOW64.
|
||||
* Otherwise, the value is set to FALSE.
|
||||
* @return
|
||||
* If the function succeeds, the return value is a nonzero value.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean IsWow64Process(HANDLE hProcess, IntByReference Wow64Process);
|
||||
|
||||
/**
|
||||
* Retrieves information about the system's current usage of both physical and virtual memory.
|
||||
* @param lpBuffer
|
||||
* A pointer to a MEMORYSTATUSEX structure that receives information about current memory availability.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean GlobalMemoryStatusEx(MEMORYSTATUSEX lpBuffer);
|
||||
|
||||
/**
|
||||
* The GetLogicalDriveStrings function fills a buffer with strings that specify
|
||||
* valid drives in the system.
|
||||
* @param nBufferLength
|
||||
* Maximum size of the buffer pointed to by lpBuffer, in TCHARs. This size does not include
|
||||
* the terminating null character. If this parameter is zero, lpBuffer is not used.
|
||||
* @param lpBuffer
|
||||
* Pointer to a buffer that receives a series of null-terminated strings, one for each valid
|
||||
* drive in the system, plus with an additional null character. Each string is a device name.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the length, in characters, of the strings
|
||||
* copied to the buffer, not including the terminating null character. Note that an ANSI-ASCII
|
||||
* null character uses one byte, but a Unicode null character uses two bytes.
|
||||
* If the buffer is not large enough, the return value is greater than nBufferLength. It is
|
||||
* the size of the buffer required to hold the drive strings.
|
||||
* If the function fails, the return value is zero. To get extended error information, use
|
||||
* the GetLastError function.
|
||||
*/
|
||||
DWORD GetLogicalDriveStrings(DWORD nBufferLength, char[] lpBuffer);
|
||||
|
||||
/**
|
||||
* The GetDiskFreeSpaceEx function retrieves information about the amount of space that is
|
||||
* available on a disk volume, which is the total amount of space, the total amount of free
|
||||
* space, and the total amount of free space available to the user that is associated with
|
||||
* the calling thread.
|
||||
* @param lpDirectoryName
|
||||
* A pointer to a null-terminated string that specifies a directory on a disk.
|
||||
* If this parameter is NULL, the function uses the root of the current disk.
|
||||
* If this parameter is a UNC name, it must include a trailing backslash, for example,
|
||||
* \\MyServer\MyShare\.
|
||||
* This parameter does not have to specify the root directory on a disk. The function
|
||||
* accepts any directory on a disk.
|
||||
* @param lpFreeBytesAvailable
|
||||
* A pointer to a variable that receives the total number of free bytes on a disk that
|
||||
* are available to the user who is associated with the calling thread.
|
||||
* This parameter can be NULL.
|
||||
* @param lpTotalNumberOfBytes
|
||||
* A pointer to a variable that receives the total number of bytes on a disk that are
|
||||
* available to the user who is associated with the calling thread.
|
||||
* This parameter can be NULL.
|
||||
* @param lpTotalNumberOfFreeBytes
|
||||
* A pointer to a variable that receives the total number of free bytes on a disk.
|
||||
* This parameter can be NULL.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is 0 (zero). To get extended error information,
|
||||
* call GetLastError.
|
||||
*/
|
||||
boolean GetDiskFreeSpaceEx(String lpDirectoryName, LARGE_INTEGER.ByReference lpFreeBytesAvailable,
|
||||
LARGE_INTEGER.ByReference lpTotalNumberOfBytes, LARGE_INTEGER.ByReference lpTotalNumberOfFreeBytes);
|
||||
|
||||
/**
|
||||
* Deletes an existing file.
|
||||
* @param filename
|
||||
* The name of the file to be deleted.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero (0). To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean DeleteFile(String filename);
|
||||
|
||||
/**
|
||||
* Creates an anonymous pipe, and returns handles to the read and write ends of the pipe.
|
||||
* @param hReadPipe A pointer to a variable that receives the read handle for the pipe.
|
||||
* @param hWritePipe A pointer to a variable that receives the write handle for the pipe.
|
||||
* @param lpPipeAttributes A pointer to a SECURITY_ATTRIBUTES structure that determines whether
|
||||
* the returned handle can be inherited by child processes.
|
||||
* @param nSize The size of the buffer for the pipe, in bytes.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
public boolean CreatePipe(
|
||||
HANDLEByReference hReadPipe,
|
||||
HANDLEByReference hWritePipe,
|
||||
WinBase.SECURITY_ATTRIBUTES lpPipeAttributes,
|
||||
int nSize);
|
||||
|
||||
/**
|
||||
* Sets certain properties of an object handle.
|
||||
* @param hObject A handle to an object whose information is to be set.
|
||||
* @param dwMask A mask that specifies the bit flags to be changed. Use the same constants shown in the description of dwFlags.
|
||||
* @param dwFlags Set of bit flags that specifies properties of the object handle.
|
||||
* @return If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetHandleInformation(
|
||||
HANDLE hObject,
|
||||
int dwMask,
|
||||
int dwFlags);
|
||||
|
||||
/**
|
||||
* Retrieves file system attributes for a specified file or directory.
|
||||
* @param lpFileName The name of the file or directory. Prepend \\?\ to the path for names up to 32,767 wide characters
|
||||
* @return INVALID_FILE_ATTRIBUTES if the function fails, otherwise the file attributes WinNT.FILE_ATTRIBUTE_*
|
||||
*/
|
||||
public int GetFileAttributes(String lpFileName);
|
||||
}
|
||||
+58
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -12,10 +12,13 @@
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jna.LastErrorException;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.W32API.DWORD;
|
||||
import com.sun.jna.platform.win32.W32API.HRESULT;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
@@ -90,4 +93,56 @@ public abstract class Kernel32Util {
|
||||
}
|
||||
return Native.toString(buffer);
|
||||
}
|
||||
|
||||
public static void deleteFile(String filename) {
|
||||
if (! Kernel32.INSTANCE.DeleteFile(filename)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns valid drives in the system.
|
||||
* @return
|
||||
* An array of valid drives.
|
||||
*/
|
||||
public static String[] getLogicalDriveStrings() {
|
||||
DWORD dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(new DWORD(0), null);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
char buf[] = new char[dwSize.intValue()];
|
||||
dwSize = Kernel32.INSTANCE.GetLogicalDriveStrings(dwSize, buf);
|
||||
if (dwSize.intValue() <= 0) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
List<String> drives = new ArrayList<String>();
|
||||
String drive = "";
|
||||
// the buffer is double-null-terminated
|
||||
for(int i = 0; i < buf.length - 1; i++) {
|
||||
if (buf[i] == 0) {
|
||||
drives.add(drive);
|
||||
drive = "";
|
||||
} else {
|
||||
drive += buf[i];
|
||||
}
|
||||
}
|
||||
return drives.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves file system attributes for a specified file or directory.
|
||||
* @param fileName
|
||||
* The name of the file or directory.
|
||||
* @return
|
||||
* The attributes of the specified file or directory.
|
||||
*/
|
||||
public static int getFileAttributes(String fileName) {
|
||||
int fileAttributes = Kernel32.INSTANCE.GetFileAttributes(fileName);
|
||||
if (fileAttributes == WinBase.INVALID_FILE_ATTRIBUTES) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return fileAttributes;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -16,13 +16,14 @@ import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMAccess.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMAccess {
|
||||
public interface LMAccess extends StdCallLibrary {
|
||||
|
||||
public static class LOCALGROUP_INFO_0 extends Structure {
|
||||
public LOCALGROUP_INFO_0() {
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -11,13 +11,15 @@
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMCons.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMCons {
|
||||
public interface LMCons extends StdCallLibrary {
|
||||
public static final int NETBIOS_NAME_LEN = 16; // NetBIOS net name (bytes)
|
||||
|
||||
/**
|
||||
+3
-1
@@ -11,13 +11,15 @@
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMErr.h.
|
||||
* @author dblock[at]dblock.org
|
||||
* Windows SDK 6.0A
|
||||
*/
|
||||
public interface LMErr {
|
||||
public interface LMErr extends StdCallLibrary {
|
||||
public static final int NERR_Success = 0;
|
||||
public static final int NERR_BASE = 2100;
|
||||
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -11,13 +11,15 @@
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from LMJoin.h.
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface LMJoin {
|
||||
public interface LMJoin extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* Status of a workstation.
|
||||
+5
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -19,13 +19,14 @@ import com.sun.jna.Structure;
|
||||
import com.sun.jna.Union;
|
||||
import com.sun.jna.platform.win32.WinNT.LARGE_INTEGER;
|
||||
import com.sun.jna.platform.win32.WinNT.PSID;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from NTSecApi.h
|
||||
* Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class NTSecApi {
|
||||
public interface NTSecApi extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* The LSA_UNICODE_STRING structure is used by various Local Security Authority (LSA)
|
||||
@@ -193,6 +194,7 @@ public abstract class NTSecApi {
|
||||
/**
|
||||
* Get an array of LSA_FOREST_TRUST_RECORD entries.
|
||||
* @return
|
||||
* An array of forest trust records.
|
||||
*/
|
||||
public PLSA_FOREST_TRUST_RECORD[] getEntries() {
|
||||
return (PLSA_FOREST_TRUST_RECORD[]) Entries.toArray(RecordCount.intValue());
|
||||
+3
-1
@@ -11,8 +11,10 @@
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
public abstract class NTStatus {
|
||||
public interface NTStatus extends StdCallLibrary {
|
||||
|
||||
public static final int STATUS_SUCCESS = 0x00000000; // ntsubauth
|
||||
public static final int STATUS_BUFFER_TOO_SMALL = 0xC0000023;
|
||||
+25
-23
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -23,13 +23,15 @@ import com.sun.jna.platform.win32.NTSecApi.PLSA_FOREST_TRUST_INFORMATION;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Netapi32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Netapi32 extends W32API {
|
||||
public interface Netapi32 extends StdCallLibrary {
|
||||
|
||||
Netapi32 INSTANCE = (Netapi32) Native.loadLibrary("Netapi32",
|
||||
Netapi32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
@@ -37,13 +39,13 @@ public interface Netapi32 extends W32API {
|
||||
* 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.
|
||||
* 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.
|
||||
* Receives the NetBIOS name of the domain or workgroup to which
|
||||
* the computer is joined.
|
||||
* @param BufferType
|
||||
* Join status of the specified computer.
|
||||
* 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.
|
||||
*/
|
||||
@@ -64,27 +66,27 @@ public interface Netapi32 extends W32API {
|
||||
* 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.
|
||||
* 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.
|
||||
* Specifies the information level of the data.
|
||||
* @param bufptr
|
||||
* Pointer to the address of the buffer that receives the
|
||||
* information structure.
|
||||
* Pointer to the address of the buffer that receives the
|
||||
* information structure.
|
||||
* @param prefmaxlen
|
||||
* Specifies the preferred maximum length of returned data, in
|
||||
* bytes.
|
||||
* Specifies the preferred maximum length of returned data, in
|
||||
* bytes.
|
||||
* @param entriesread
|
||||
* Pointer to a value that receives the count of elements
|
||||
* actually enumerated.
|
||||
* 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.
|
||||
* 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.
|
||||
* 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,
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -449,7 +449,7 @@ public abstract class Netapi32Util {
|
||||
dc.domainName = pdci.dci.DomainName.toString();
|
||||
dc.flags = pdci.dci.Flags;
|
||||
dc.name = pdci.dci.DomainControllerName.toString();
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.getPointer());
|
||||
rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
|
||||
if (LMErr.NERR_Success != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
+6
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,20 +8,23 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* ntdll.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface NtDll extends W32API {
|
||||
public interface NtDll extends StdCallLibrary {
|
||||
|
||||
NtDll INSTANCE = (NtDll) Native.loadLibrary("NtDll",
|
||||
NtDll.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010 Digital Rapids Corp.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.WTypes;
|
||||
|
||||
/**
|
||||
* Definitions from ObjBase.h
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface ObjBase {
|
||||
|
||||
public static final int CLSCTX_INPROC = (WTypes.CLSCTX_INPROC_SERVER | WTypes.CLSCTX_INPROC_HANDLER);
|
||||
|
||||
// With DCOM, CLSCTX_REMOTE_SERVER should be included
|
||||
public static final int CLSCTX_ALL = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_INPROC_HANDLER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
|
||||
public static final int CLSCTX_SERVER = (WTypes.CLSCTX_INPROC_SERVER
|
||||
| WTypes.CLSCTX_LOCAL_SERVER
|
||||
| WTypes.CLSCTX_REMOTE_SERVER);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Ole32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Ole32 extends StdCallLibrary {
|
||||
|
||||
Ole32 INSTANCE = (Ole32) Native.loadLibrary(
|
||||
"Ole32", Ole32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* Creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.
|
||||
* @param pguid
|
||||
* A pointer to the requested GUID.
|
||||
* @return
|
||||
* S_OK if the GUID was successfully created.
|
||||
*/
|
||||
HRESULT CoCreateGuid(GUID.ByReference pguid);
|
||||
|
||||
/**
|
||||
* Converts a globally unique identifier (GUID) into a string of printable characters.
|
||||
* @param rguid
|
||||
* The GUID to be converted.
|
||||
* @param lpsz
|
||||
* A pointer to a caller-allocated string variable to receive the resulting string.
|
||||
* @param cchMax
|
||||
* The number of characters available in the lpsz buffer.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the number of characters in the
|
||||
* returned string, including the null terminator. If the buffer is too small to contain
|
||||
* the string, the return value is 0.
|
||||
*/
|
||||
int StringFromGUID2(GUID.ByReference rguid, char[] lpsz, int cchMax);
|
||||
|
||||
/**
|
||||
* Converts a string generated by the StringFromIID function back into the
|
||||
* original interface identifier (IID).
|
||||
* @param lpsz
|
||||
* A pointer to the string representation of the IID.
|
||||
* @param lpiid
|
||||
* A pointer to the requested IID on return.
|
||||
* @return
|
||||
* This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY,
|
||||
* and S_OK.
|
||||
*/
|
||||
HRESULT IIDFromString(String lpsz, GUID.ByReference lpiid);
|
||||
|
||||
/**
|
||||
* Initializes the COM library for use by the calling thread, sets the thread's
|
||||
* concurrency model, and creates a new apartment for the thread if one is required.
|
||||
* @param reserved This parameter is reserved and must be NULL.
|
||||
* @param dwCoInit The concurrency model and initialization options for the
|
||||
* thread. Values for this parameter are taken from the COINIT enumeration.
|
||||
* Any combination of values from COINIT can be used, except that the
|
||||
* COINIT_APARTMENTTHREADED and COINIT_MULTITHREADED flags cannot both be
|
||||
* set. The default (and only sane choice) is COINIT_MULTITHREADED.
|
||||
* @return This function can return the standard return values E_INVALIDARG, E_OUTOFMEMORY, and E_UNEXPECTED, as well as the following values. S_OK, S_FALSE, RPC_E_CHANGED_MODE
|
||||
*/
|
||||
HRESULT CoInitializeEx(Pointer reserved, int dwCoInit);
|
||||
|
||||
/**
|
||||
* Closes the COM library on the current thread, unloads all DLLs loaded by
|
||||
* the thread, frees any other resources that the thread maintains, and
|
||||
* forces all RPC connections on the thread to close.
|
||||
*
|
||||
*/
|
||||
void CoUninitialize();
|
||||
|
||||
/**
|
||||
* Creates a single uninitialized object of the class associated with a specified CLSID.
|
||||
* @param rclsid The CLSID associated with the data and code that will be used to create the object.
|
||||
* @param pUnkOuter If NULL, indicates that the object is not being created as part of an aggregate. If non-NULL, pointer to the aggregate object's IUnknown interface (the controlling IUnknown).
|
||||
* @param dwClsContext Context in which the code that manages the newly created object will run. The values are taken from the enumeration CLSCTX defined in WTypes.
|
||||
* @param riid A reference to the identifier of the interface to be used to communicate with the object.
|
||||
* @param ppv Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppv contains the requested interface pointer. Upon failure, *ppv contains NULL.
|
||||
* @return an HRESULT
|
||||
*/
|
||||
HRESULT CoCreateInstance(
|
||||
GUID rclsid,
|
||||
Pointer pUnkOuter,
|
||||
int dwClsContext,
|
||||
GUID riid,
|
||||
PointerByReference ppv);
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,13 +8,13 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Guid.GUID;
|
||||
import com.sun.jna.platform.win32.W32API.HRESULT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Ole32 Utility API.
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Digital Rapids Corp., All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Oleaut32.dll Interface.
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface Oleaut32 extends StdCallLibrary {
|
||||
|
||||
Oleaut32 INSTANCE = (Oleaut32) Native.loadLibrary(
|
||||
"Oleaut32", Oleaut32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function allocates a new string and copies the passed string into it.
|
||||
* @param sz
|
||||
* Null-terminated UNICODE string to copy.
|
||||
* @return
|
||||
* Null if there is insufficient memory or if a null pointer is passed in.
|
||||
*/
|
||||
Pointer SysAllocString(String sz);
|
||||
|
||||
/**
|
||||
* This function frees a string allocated previously by SysAllocString,
|
||||
* SysAllocStringByteLen, SysReAllocString, SysAllocStringLen, or
|
||||
* SysReAllocStringLen.
|
||||
* @param bstr
|
||||
* Unicode string that was allocated previously, or NULL. Setting this parameter
|
||||
* to NULL causes the function to simply return.
|
||||
*/
|
||||
void SysFreeString(Pointer bstr);
|
||||
}
|
||||
+34
-5
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -17,20 +17,21 @@ 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.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinNT.LUID;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.NativeLongByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Secur32.dll Interface.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public interface Secur32 extends W32API {
|
||||
public interface Secur32 extends StdCallLibrary {
|
||||
Secur32 INSTANCE = (Secur32) Native.loadLibrary(
|
||||
"Secur32", Secur32.class, W32APIOptions.UNICODE_OPTIONS);
|
||||
|
||||
@@ -282,6 +283,34 @@ public interface Secur32 extends W32API {
|
||||
* 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,
|
||||
public int QuerySecurityContextToken(CtxtHandle phContext,
|
||||
HANDLEByReference phToken);
|
||||
|
||||
/**
|
||||
* The ImpersonateSecurityContext function allows a server to impersonate a client by using
|
||||
* a token previously obtained by a call to AcceptSecurityContext or QuerySecurityContextToken.
|
||||
* This function allows the application server to act as the client, and thus all necessary
|
||||
* access controls are enforced.
|
||||
* @param phContext
|
||||
* The handle of the context to impersonate. This handle must have been obtained by a call
|
||||
* to the AcceptSecurityContext function.
|
||||
* @return
|
||||
* If the function succeeds, the function returns SEC_E_OK.
|
||||
* If the function fails, it returns a SEC_E_INVALID_HANDLE, SEC_E_NO_IMPERSONATION or
|
||||
* SEC_E_UNSUPPORTED_FUNCTION error code.
|
||||
*/
|
||||
public int ImpersonateSecurityContext(CtxtHandle phContext);
|
||||
|
||||
/**
|
||||
* Allows a security package to discontinue the impersonation of the caller and restore its
|
||||
* own security context.
|
||||
* @param phContext
|
||||
* Handle of the security context being impersonated. This handle must have been obtained in
|
||||
* the call to the AcceptSecurityContext function and used in the call to the
|
||||
* ImpersonateSecurityContext function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is SEC_E_OK.
|
||||
* If the function fails, the return value can be either SEC_E_INVALID_HANDLE or SEC_E_UNSUPPORTED_FUNCTION.
|
||||
*/
|
||||
public int RevertSecurityContext(CtxtHandle phContext);
|
||||
}
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
@@ -85,15 +85,15 @@ public abstract class Secur32Util {
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
SecPkgInfo.ByReference[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
|
||||
SecPkgInfo[] packagesInfo = pPackageInfo.toArray(pcPackages.getValue());
|
||||
ArrayList<SecurityPackage> packages = new ArrayList<SecurityPackage>(pcPackages.getValue());
|
||||
for(SecPkgInfo.ByReference packageInfo : packagesInfo) {
|
||||
for(SecPkgInfo packageInfo : packagesInfo) {
|
||||
SecurityPackage securityPackage = new SecurityPackage();
|
||||
securityPackage.name = packageInfo.Name.toString();
|
||||
securityPackage.comment = packageInfo.Comment.toString();
|
||||
packages.add(securityPackage);
|
||||
}
|
||||
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.getPointer());
|
||||
rc = Secur32.INSTANCE.FreeContextBuffer(pPackageInfo.pPkgInfo.getPointer());
|
||||
if(W32Errors.SEC_E_OK != rc) {
|
||||
throw new Win32Exception(rc);
|
||||
}
|
||||
+18
-2
@@ -14,12 +14,18 @@ package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.ShellAPI.SHFILEOPSTRUCT;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Mapping for Shell32.dll API.
|
||||
* Shell32.dll Interface.
|
||||
*/
|
||||
public interface Shell32 extends W32API {
|
||||
public interface Shell32 extends StdCallLibrary {
|
||||
|
||||
Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class,
|
||||
W32APIOptions.UNICODE_OPTIONS);
|
||||
@@ -57,4 +63,14 @@ public interface Shell32 extends W32API {
|
||||
*/
|
||||
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags,
|
||||
char[] pszPath);
|
||||
|
||||
/**
|
||||
* Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace.
|
||||
* The retrieved COM interface pointer can be used via Com4JNA's ComObject.wrapNativeInterface call
|
||||
* given a suitable interface definition for IShellFolder
|
||||
* @param ppshf A place to put the IShellFolder interface pointer
|
||||
* @return If the function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
|
||||
*/
|
||||
HRESULT SHGetDesktopFolder( PointerByReference ppshf );
|
||||
|
||||
}
|
||||
+5
-6
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,15 +8,14 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import 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;
|
||||
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Shell32 Utility API.
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -15,7 +15,7 @@ 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.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ import com.sun.jna.win32.StdCallLibrary;
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract interface ShellAPI extends StdCallLibrary {
|
||||
public interface ShellAPI extends StdCallLibrary {
|
||||
|
||||
int STRUCTURE_ALIGNMENT = Structure.ALIGN_NONE;
|
||||
|
||||
+6
-5
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -7,19 +7,20 @@
|
||||
*
|
||||
* 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.
|
||||
* 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;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from ShlObj.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class ShlObj {
|
||||
public interface ShlObj extends StdCallLibrary {
|
||||
|
||||
public static final DWORD SHGFP_TYPE_CURRENT = new DWORD(0); // current value for user, verify it exists
|
||||
public static final DWORD SHGFP_TYPE_DEFAULT = new DWORD(1); // default value, may not exist
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -17,13 +17,14 @@ import com.sun.jna.NativeLong;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.Structure;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
|
||||
/**
|
||||
* Ported from Sspi.h.
|
||||
* Microsoft Windows SDK 6.0A.
|
||||
* @author dblock[at]dblock.org
|
||||
*/
|
||||
public abstract class Sspi {
|
||||
public interface Sspi extends StdCallLibrary {
|
||||
|
||||
/**
|
||||
* Maximum size in bytes of a security token.
|
||||
@@ -0,0 +1,735 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* <p/>
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.BaseTSD.LONG_PTR;
|
||||
import com.sun.jna.platform.win32.WinDef.HDC;
|
||||
import com.sun.jna.platform.win32.WinDef.HICON;
|
||||
import com.sun.jna.platform.win32.WinDef.HINSTANCE;
|
||||
import com.sun.jna.platform.win32.WinDef.HRGN;
|
||||
import com.sun.jna.platform.win32.WinDef.HWND;
|
||||
import com.sun.jna.platform.win32.WinDef.LPARAM;
|
||||
import com.sun.jna.platform.win32.WinDef.LRESULT;
|
||||
import com.sun.jna.platform.win32.WinDef.RECT;
|
||||
import com.sun.jna.platform.win32.WinDef.WPARAM;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinUser.BLENDFUNCTION;
|
||||
import com.sun.jna.platform.win32.WinUser.FLASHWINFO;
|
||||
import com.sun.jna.platform.win32.WinUser.GUITHREADINFO;
|
||||
import com.sun.jna.platform.win32.WinUser.HHOOK;
|
||||
import com.sun.jna.platform.win32.WinUser.HOOKPROC;
|
||||
import com.sun.jna.platform.win32.WinUser.MSG;
|
||||
import com.sun.jna.platform.win32.WinUser.POINT;
|
||||
import com.sun.jna.platform.win32.WinUser.SIZE;
|
||||
import com.sun.jna.platform.win32.WinUser.WINDOWINFO;
|
||||
import com.sun.jna.platform.win32.WinUser.WNDENUMPROC;
|
||||
import com.sun.jna.ptr.ByteByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.StdCallLibrary;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
/**
|
||||
* Provides access to the w32 user32 library. Incomplete implementation to
|
||||
* support demos.
|
||||
*
|
||||
* @author Todd Fast, todd.fast@sun.com
|
||||
* @author twalljava@dev.java.net
|
||||
*/
|
||||
public interface User32 extends StdCallLibrary {
|
||||
|
||||
User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class,
|
||||
W32APIOptions.DEFAULT_OPTIONS);
|
||||
|
||||
/**
|
||||
* This function retrieves a handle to a display device context (DC) for the
|
||||
* client area of the specified window. The display device context can be
|
||||
* used in subsequent graphics display interface (GDI) functions to draw in
|
||||
* the client area of the window.
|
||||
* @param hWnd
|
||||
* Handle to the window whose device context is to be retrieved.
|
||||
* If this value is NULL, GetDC retrieves the device context for
|
||||
* the entire screen.
|
||||
* @return
|
||||
* The handle the device context for the specified window's client
|
||||
* area indicates success. NULL indicates failure. To get extended
|
||||
* error information, call GetLastError.
|
||||
*/
|
||||
HDC GetDC(HWND hWnd);
|
||||
|
||||
/**
|
||||
* This function releases a device context (DC), freeing it for use by other
|
||||
* applications. The effect of ReleaseDC depends on the type of device
|
||||
* context.
|
||||
*
|
||||
* @param hWnd
|
||||
* Handle to the window whose device context is to be released.
|
||||
* @param hDC
|
||||
* Handle to the device context to be released.
|
||||
* @return
|
||||
* The return value specifies whether the device context is
|
||||
* released. 1 indicates that the device context is released. Zero
|
||||
* indicates that the device context is not released.
|
||||
*/
|
||||
int ReleaseDC(HWND hWnd, HDC hDC);
|
||||
|
||||
/**
|
||||
* This function retrieves the handle to the top-level window whose class name and
|
||||
* window name match the specified strings. This function does not search child windows.
|
||||
* @param lpClassName
|
||||
* Long pointer to a null-terminated string that specifies the class name or is an atom
|
||||
* that identifies the class-name string. If this parameter is an atom, it must be a
|
||||
* global atom created by a previous call to the GlobalAddAtom function. The atom, a
|
||||
* 16-bit value, must be placed in the low-order word of lpClassName; the high-order
|
||||
* word must be zero.
|
||||
* @param lpWindowName
|
||||
* Long pointer to a null-terminated string that specifies the window name (the window's
|
||||
* title). If this parameter is NULL, all window names match.
|
||||
* @return
|
||||
* A handle to the window that has the specified class name and window name indicates
|
||||
* success. NULL indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HWND FindWindow(String lpClassName, String lpWindowName);
|
||||
|
||||
/**
|
||||
* This function retrieves the name of the class to which the specified window belongs.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param lpClassName
|
||||
* Long pointer to the buffer that is to receive the class name string.
|
||||
* @param nMaxCount
|
||||
* Specifies the length, in characters, of the buffer pointed to by the lpClassName
|
||||
* parameter. The class name string is truncated if it is longer than the buffer.
|
||||
* @return
|
||||
* The number of characters copied to the specified buffer indicates success. Zero
|
||||
* indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
int GetClassName(HWND hWnd, char[] lpClassName, int nMaxCount);
|
||||
|
||||
/**
|
||||
* Retrieves information about the active window or a specified graphical user
|
||||
* interface (GUI) thread.
|
||||
* @param idThread
|
||||
* Identifies the thread for which information is to be retrieved. To retrieve
|
||||
* this value, use the GetWindowThreadProcessId function. If this parameter is NULL,
|
||||
* the function returns information for the foreground thread.
|
||||
* @param lpgui
|
||||
* Pointer to a GUITHREADINFO structure that receives information describing the thread.
|
||||
* Note that you must set GUITHREADINFO.cbSize to sizeof(GUITHREADINFO) before calling this function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetGUIThreadInfo(int idThread, GUITHREADINFO lpgui);
|
||||
|
||||
/**
|
||||
* The GetWindowInfo function retrieves information about the specified window.
|
||||
* @param hWnd
|
||||
* Handle to the window whose information is to be retrieved.
|
||||
* @param pwi
|
||||
* Pointer to a WINDOWINFO structure to receive the information. Note that you must set WINDOWINFO.cbSize
|
||||
* to sizeof(WINDOWINFO) before calling this function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero.
|
||||
*/
|
||||
boolean GetWindowInfo(HWND hWnd, WINDOWINFO pwi);
|
||||
|
||||
/**
|
||||
* This function retrieves the dimensions of the bounding rectangle of the specified window. The
|
||||
* dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
|
||||
* @param hWnd
|
||||
* Handle to the window.
|
||||
* @param rect
|
||||
* Long pointer to a RECT structure that receives the screen coordinates of the upper-left and lower-right
|
||||
* corners of the window.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetWindowRect(HWND hWnd, RECT rect);
|
||||
|
||||
/**
|
||||
* This function copies the text of the specified window's title bar - if it has one - into a buffer. If
|
||||
* the specified window is a control, the text of the control is copied.
|
||||
* @param hWnd
|
||||
* Handle to the window or control containing the text.
|
||||
* @param lpString
|
||||
* Long pointer to the buffer that will receive the text.
|
||||
* @param nMaxCount
|
||||
* Specifies the maximum number of characters to copy to the buffer, including the NULL character.
|
||||
* If the text exceeds this limit, it is truncated.
|
||||
* @return
|
||||
* The length, in characters, of the copied string, not including the terminating null character,
|
||||
* indicates success. Zero indicates that the window has no title bar or text, if the title bar is
|
||||
* empty, or if the window or control handle is invalid. To get extended error information, call
|
||||
* GetLastError. This function cannot retrieve the text of an edit control in another application.
|
||||
*/
|
||||
int GetWindowText(HWND hWnd, char[] lpString, int nMaxCount);
|
||||
|
||||
/**
|
||||
* This function retrieves the length, in characters, of the specified window's title bar text -
|
||||
* if the window has a title bar. If the specified window is a control, the function retrieves the
|
||||
* length of the text within the control.
|
||||
* @param hWnd
|
||||
* Handle to the window or control.
|
||||
* @return
|
||||
* The length, in characters, of the text indicates success. Under certain conditions, this value
|
||||
* may actually be greater than the length of the text. Zero indicates that the window has no text.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
int GetWindowTextLength(HWND hWnd);
|
||||
|
||||
/**
|
||||
* The GetWindowModuleFileName function retrieves the full path and file name of the module associated
|
||||
* with the specified window handle.
|
||||
* @param hWnd
|
||||
* Handle to the window whose module file name will be retrieved.
|
||||
* @param lpszFileName
|
||||
* Pointer to a buffer that receives the path and file name.
|
||||
* @param cchFileNameMax
|
||||
* Specifies the maximum number of TCHARs that can be copied into the lpszFileName buffer.
|
||||
* @return
|
||||
* The return value is the total number of TCHARs copied into the buffer.
|
||||
*/
|
||||
int GetWindowModuleFileName(HWND hWnd, char[] lpszFileName,
|
||||
int cchFileNameMax);
|
||||
|
||||
/**
|
||||
* This function retrieves the identifier of the thread that created the specified window and, optionally,
|
||||
* the identifier of the process that created the window.
|
||||
* @param hWnd
|
||||
* Handle to the window.
|
||||
* @param lpdwProcessId
|
||||
* Pointer to a 32-bit value that receives the process identifier. If this parameter is not NULL,
|
||||
* GetWindowThreadProcessId copies the identifier of the process to the 32-bit value; otherwise,
|
||||
* it does not.
|
||||
* @return
|
||||
* The return value is the identifier of the thread that created the window.
|
||||
*/
|
||||
int GetWindowThreadProcessId(HWND hWnd, IntByReference lpdwProcessId);
|
||||
|
||||
/**
|
||||
* This function enumerates all top-level windows on the screen by passing the handle to each window,
|
||||
* in turn, to an application-defined callback function. EnumWindows continues until the last top-level
|
||||
* window is enumerated or the callback function returns FALSE.
|
||||
* @param lpEnumFunc
|
||||
* Long pointer to an application-defined callback function.
|
||||
* @param data
|
||||
* Specifies an application-defined value to be passed to the callback function.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean EnumWindows(WNDENUMPROC lpEnumFunc, Pointer data);
|
||||
|
||||
/**
|
||||
* The EnumChildWindows function enumerates the child windows that belong to the specified parent window
|
||||
* by passing the handle to each child window, in turn, to an application-defined callback function.
|
||||
* EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.
|
||||
* @param hWnd
|
||||
* Handle to the parent window whose child windows are to be enumerated. If this parameter is NULL, this
|
||||
* function is equivalent to EnumWindows.
|
||||
* @param lpEnumFunc
|
||||
* Pointer to an application-defined callback function.
|
||||
* @param data
|
||||
* Specifies an application-defined value to be passed to the callback function.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If EnumChildProc returns zero, the return value is also zero. In this case, the callback function
|
||||
* should call SetLastError to obtain a meaningful error code to be returned to the caller of
|
||||
* EnumChildWindows.
|
||||
*/
|
||||
boolean EnumChildWindows(HWND hWnd, WNDENUMPROC lpEnumFunc, Pointer data);
|
||||
|
||||
/**
|
||||
* The EnumThreadWindows function enumerates all nonchild windows associated with a thread by passing
|
||||
* the handle to each window, in turn, to an application-defined callback function. EnumThreadWindows
|
||||
* continues until the last window is enumerated or the callback function returns FALSE. To enumerate
|
||||
* child windows of a particular window, use the EnumChildWindows function.
|
||||
* @param dwThreadId
|
||||
* Identifies the thread whose windows are to be enumerated.
|
||||
* @param lpEnumFunc
|
||||
* Pointer to an application-defined callback function.
|
||||
* @param data
|
||||
* Specifies an application-defined value to be passed to the callback function.
|
||||
* @return
|
||||
* If the callback function returns TRUE for all windows in the thread specified by dwThreadId, the
|
||||
* return value is TRUE. If the callback function returns FALSE on any enumerated window, or if there
|
||||
* are no windows found in the thread specified by dwThreadId, the return value is FALSE.
|
||||
*/
|
||||
boolean EnumThreadWindows(int dwThreadId, WNDENUMPROC lpEnumFunc,
|
||||
Pointer data);
|
||||
|
||||
/**
|
||||
* The FlashWindowEx function flashes the specified window. It does not change the active state of the window.
|
||||
* @param pfwi
|
||||
* Pointer to the FLASHWINFO structure.
|
||||
* @return
|
||||
* The return value specifies the window's state before the call to the FlashWindowEx function. If the window
|
||||
* caption was drawn as active before the call, the return value is nonzero. Otherwise, the return value is zero.
|
||||
*/
|
||||
boolean FlashWindowEx(FLASHWINFO pfwi);
|
||||
|
||||
/**
|
||||
* This function loads the specified icon resource from the executable (.exe) file associated with an
|
||||
* application instance.
|
||||
* @param hInstance
|
||||
* Handle to an instance of the module whose executable file contains the icon to be loaded.
|
||||
* This parameter must be NULL when a standard icon is being loaded.
|
||||
* @param iconName
|
||||
* Long pointer to a null-terminated string that contains the name of the icon resource to be loaded.
|
||||
* Alternatively, this parameter can contain the resource identifier in the low-order word and zero
|
||||
* in the high-order word. Use the MAKEINTRESOURCE macro to create this value.
|
||||
* @return
|
||||
* A handle to the newly loaded icon indicates success. NULL indicates failure. To get extended
|
||||
* error information, call GetLastError.
|
||||
*/
|
||||
HICON LoadIcon(HINSTANCE hInstance, String iconName);
|
||||
|
||||
/**
|
||||
* This function loads an icon, cursor, or bitmap.
|
||||
* @param hinst
|
||||
* Handle to an instance of the module that contains the image to be loaded.
|
||||
* @param name
|
||||
* Pointer to a null-terminated string that contains the name of the image resource
|
||||
* in the hinst module that identifies the image to load.
|
||||
* @param type
|
||||
* Specifies the type of image to be loaded.
|
||||
* @param xDesired
|
||||
* Specifies the width, in pixels, of the icon or cursor. If this parameter is zero, the function uses
|
||||
* the SM_CXICON or SM_CXCURSOR system metric value to set the width. If uType is IMAGE_BITMAP, this
|
||||
* parameter must be zero.
|
||||
* @param yDesired
|
||||
* Specifies the height, in pixels, of the icon or cursor. If this parameter is zero, the function uses
|
||||
* the SM_CYICON or SM_CYCURSOR system metric value to set the height. If uType is IMAGE_BITMAP, this
|
||||
* parameter must be zero.
|
||||
* @param load
|
||||
* Set to zero.
|
||||
* @return
|
||||
* The handle of the newly loaded image indicates success. NULL indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HANDLE LoadImage(HINSTANCE hinst, String name, int type, int xDesired,
|
||||
int yDesired, int load);
|
||||
|
||||
/**
|
||||
* This function destroys an icon and frees any memory the icon occupied.
|
||||
* @param hicon
|
||||
* Handle to the icon to be destroyed. The icon must not be in use.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean DestroyIcon(HICON hicon);
|
||||
|
||||
/**
|
||||
* This function retrieves information about the specified window. GetWindowLong also retrieves
|
||||
* the 32-bit (long) value at the specified offset into the extra window memory of a window.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be retrieved.
|
||||
* @return
|
||||
* The requested 32-bit value indicates success. Zero indicates failure. To get extended error
|
||||
* information, call GetLastError.
|
||||
*/
|
||||
int GetWindowLong(HWND hWnd, int nIndex);
|
||||
|
||||
/**
|
||||
* This function changes an attribute of the specified window. SetWindowLong also sets a 32-bit (LONG)
|
||||
* value at the specified offset into the extra window memory of a window.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLong
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* The previous value of the specified 32-bit integer indicates success. Zero indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
int SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
/**
|
||||
* This function changes an attribute of the specified window. SetWindowLong also sets a
|
||||
* 32-bit (LONG) value at the specified offset into the extra window memory of a window.
|
||||
* Do not use this version on Windows-64.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLong
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* The previous value of the specified 32-bit integer indicates success. Zero indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
Pointer SetWindowLong(HWND hWnd, int nIndex, Pointer dwNewLong);
|
||||
|
||||
/**
|
||||
* The GetWindowLongPtr function retrieves information about the specified window.
|
||||
* The function also retrieves the value at a specified offset into the extra window memory.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be retrieved.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the requested value.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If SetWindowLong or SetWindowLongPtr has not been called previously, GetWindowLongPtr returns zero for
|
||||
* values in the extra window or class memory.
|
||||
*/
|
||||
LONG_PTR GetWindowLongPtr(HWND hWnd, int nIndex);
|
||||
|
||||
/**
|
||||
* The SetWindowLongPtr function changes an attribute of the specified window. The function also
|
||||
* sets a value at the specified offset in the extra window memory.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLongPtr
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the previous value of the specified offset.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the previous value is zero and the function succeeds, the return value is zero, but the function
|
||||
* does not clear the last error information. To determine success or failure, clear the last error
|
||||
* information by calling SetLastError(0), then call SetWindowLongPtr. Function failure will be indicated
|
||||
* by a return value of zero and a GetLastError result that is nonzero.
|
||||
*/
|
||||
LONG_PTR SetWindowLongPtr(HWND hWnd, int nIndex, LONG_PTR dwNewLongPtr);
|
||||
|
||||
/**
|
||||
* The SetWindowLongPtr function changes an attribute of the specified window. The function also
|
||||
* sets a value at the specified offset in the extra window memory.
|
||||
* @param hWnd
|
||||
* Handle to the window and, indirectly, the class to which the window belongs.
|
||||
* @param nIndex
|
||||
* Specifies the zero-based offset to the value to be set.
|
||||
* @param dwNewLongPtr
|
||||
* Specifies the replacement value.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the previous value of the specified offset.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
* If the previous value is zero and the function succeeds, the return value is zero, but the function
|
||||
* does not clear the last error information. To determine success or failure, clear the last error
|
||||
* information by calling SetLastError(0), then call SetWindowLongPtr. Function failure will be indicated
|
||||
* by a return value of zero and a GetLastError result that is nonzero.
|
||||
*/
|
||||
Pointer SetWindowLongPtr(HWND hWnd, int nIndex, Pointer dwNewLongPtr);
|
||||
|
||||
/**
|
||||
* The SetLayeredWindowAttributes function sets the opacity and transparency color key of a layered window.
|
||||
* @param hwnd
|
||||
* Handle to the layered window.
|
||||
* @param crKey
|
||||
* COLORREF structure that specifies the transparency color key to be used when composing the layered window.
|
||||
* @param bAlpha
|
||||
* Alpha value used to describe the opacity of the layered window.
|
||||
* @param dwFlags
|
||||
* Specifies an action to take.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean SetLayeredWindowAttributes(HWND hwnd, int crKey, byte bAlpha,
|
||||
int dwFlags);
|
||||
|
||||
/**
|
||||
* The GetLayeredWindowAttributes function retrieves the opacity and transparency color
|
||||
* key of a layered window.
|
||||
* @param hwnd
|
||||
* Handle to the layered window. A layered window is created by specifying WS_EX_LAYERED
|
||||
* when creating the window with the CreateWindowEx function or by setting WS_EX_LAYERED
|
||||
* via SetWindowLong after the window has been created.
|
||||
* @param pcrKey
|
||||
* Pointer to a COLORREF value that receives the transparency color key to be used when
|
||||
* composing the layered window. All pixels painted by the window in this color will be
|
||||
* transparent. This can be NULL if the argument is not needed.
|
||||
* @param pbAlpha
|
||||
* Pointer to a BYTE that receives the Alpha value used to describe the opacity of the
|
||||
* layered window. Similar to the SourceConstantAlpha member of the BLENDFUNCTION structure.
|
||||
* When the variable referred to by pbAlpha is 0, the window is completely transparent.
|
||||
* When the variable referred to by pbAlpha is 255, the window is opaque. This can be NULL
|
||||
* if the argument is not needed.
|
||||
* @param pdwFlags
|
||||
* Pointer to a DWORD that receives a layering flag. This can be NULL if the argument is not needed.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetLayeredWindowAttributes(HWND hwnd, IntByReference pcrKey,
|
||||
ByteByReference pbAlpha, IntByReference pdwFlags);
|
||||
|
||||
/**
|
||||
* The UpdateLayeredWindow function updates the position, size, shape, content, and
|
||||
* translucency of a layered window.
|
||||
* @param hwnd
|
||||
* Handle to a layered window. A layered window is created by specifying WS_EX_LAYERED
|
||||
* when creating the window with the CreateWindowEx function.
|
||||
* @param hdcDst
|
||||
* Handle to a device context (DC) for the screen. This handle is obtained by specifying NULL
|
||||
* when calling the function. It is used for palette color matching when the window contents
|
||||
* are updated. If hdcDst isNULL, the default palette will be used. If hdcSrc is NULL, hdcDst must be NULL.
|
||||
* @param pptDst
|
||||
* Pointer to a POINT structure that specifies the new screen position of the layered window.
|
||||
* If the current position is not changing, pptDst can be NULL.
|
||||
* @param psize
|
||||
* Pointer to a SIZE structure that specifies the new size of the layered window. If the size of the window
|
||||
* is not changing, psize can be NULL. If hdcSrc is NULL, psize must be NULL.
|
||||
* @param hdcSrc
|
||||
* Handle to a DC for the surface that defines the layered window. This handle can be obtained by calling
|
||||
* the CreateCompatibleDC function. If the shape and visual context of the window are not changing, hdcSrc
|
||||
* can be NULL.
|
||||
* @param pptSrc
|
||||
* Pointer to a POINT structure that specifies the location of the layer in the device context.
|
||||
* If hdcSrc is NULL, pptSrc should be NULL.
|
||||
* @param crKey
|
||||
* Pointer to a COLORREF value that specifies the color key to be used when composing the layered window.
|
||||
* To generate a COLORREF, use the RGB macro.
|
||||
* @param pblend
|
||||
* Pointer to a BLENDFUNCTION structure that specifies the transparency value to be used when composing
|
||||
* the layered window.
|
||||
* @param dwFlags
|
||||
* ULW_* flags.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UpdateLayeredWindow(HWND hwnd, HDC hdcDst, POINT pptDst,
|
||||
SIZE psize, HDC hdcSrc, POINT pptSrc, int crKey,
|
||||
BLENDFUNCTION pblend, int dwFlags);
|
||||
|
||||
/**
|
||||
* This function sets the window region of a window. The window region determines the area within the
|
||||
* window where the system permits drawing. The system does not display any portion of a window that lies
|
||||
* outside of the window region.
|
||||
* @param hWnd
|
||||
* Handle to the window whose window region is to be set.
|
||||
* @param hRgn
|
||||
* Handle to a region. The function sets the window region of the window to this region.
|
||||
* If hRgn is NULL, the function sets the window region to NULL.
|
||||
* @param bRedraw
|
||||
* Specifies whether the system redraws the window after setting the window region.
|
||||
* If bRedraw is TRUE, the system does so; otherwise, it does not.
|
||||
* Typically, you set bRedraw to TRUE if the window is visible.
|
||||
* @return
|
||||
* Nonzero indicates success.
|
||||
* Zero indicates failure.
|
||||
* To get extended error information, call GetLastError.
|
||||
*/
|
||||
int SetWindowRgn(HWND hWnd, HRGN hRgn, boolean bRedraw);
|
||||
|
||||
/**
|
||||
* The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer.
|
||||
* @param lpKeyState
|
||||
* Pointer to the 256-byte array that receives the status data for each virtual key.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean GetKeyboardState(byte[] lpKeyState);
|
||||
|
||||
/**
|
||||
* This function determines whether a key is up or down at the time the function is called,
|
||||
* and whether the key was pressed after a previous call to GetAsyncKeyState.
|
||||
* @param vKey
|
||||
* Specifies one of 256 possible virtual-key codes.
|
||||
* @return
|
||||
* If the function succeeds, the return value specifies whether the key was pressed since the last
|
||||
* call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant
|
||||
* bit is set, the key is down.
|
||||
*/
|
||||
short GetAsyncKeyState(int vKey);
|
||||
|
||||
/**
|
||||
* The SetWindowsHookEx function installs an application-defined hook procedure into a hook chain.
|
||||
* You would install a hook procedure to monitor the system for certain types of events. These
|
||||
* events are associated either with a specific thread or with all threads in the same desktop
|
||||
* as the calling thread.
|
||||
* @param idHook
|
||||
* Specifies the type of hook procedure to be installed.
|
||||
* @param lpfn
|
||||
* Pointer to the hook procedure.
|
||||
* @param hMod
|
||||
* Handle to the DLL containing the hook procedure pointed to by the lpfn parameter.
|
||||
* @param dwThreadId
|
||||
* Specifies the identifier of the thread with which the hook procedure is to be associated.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the handle to the hook procedure.
|
||||
* If the function fails, the return value is NULL. To get extended error information, call GetLastError.
|
||||
*/
|
||||
HHOOK SetWindowsHookEx(int idHook, HOOKPROC lpfn, HINSTANCE hMod,
|
||||
int dwThreadId);
|
||||
|
||||
/**
|
||||
* The CallNextHookEx function passes the hook information to the next hook procedure
|
||||
* in the current hook chain. A hook procedure can call this function either before or
|
||||
* after processing the hook information.
|
||||
* @param hhk
|
||||
* Ignored.
|
||||
* @param nCode
|
||||
* Specifies the hook code passed to the current hook procedure. The next hook procedure
|
||||
* uses this code to determine how to process the hook information.
|
||||
* @param wParam
|
||||
* Specifies the wParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @param lParam
|
||||
* Specifies the lParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @return
|
||||
* This value is returned by the next hook procedure in the chain. The current hook procedure
|
||||
* must also return this value. The meaning of the return value depends on the hook type.
|
||||
*/
|
||||
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* The CallNextHookEx function passes the hook information to the next hook procedure
|
||||
* in the current hook chain. A hook procedure can call this function either before or
|
||||
* after processing the hook information.
|
||||
* @param hhk
|
||||
* Ignored.
|
||||
* @param nCode
|
||||
* Specifies the hook code passed to the current hook procedure. The next hook procedure
|
||||
* uses this code to determine how to process the hook information.
|
||||
* @param wParam
|
||||
* Specifies the wParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @param lParam
|
||||
* Specifies the lParam value passed to the current hook procedure. The meaning of this
|
||||
* parameter depends on the type of hook associated with the current hook chain.
|
||||
* @return
|
||||
* This value is returned by the next hook procedure in the chain. The current hook procedure
|
||||
* must also return this value. The meaning of the return value depends on the hook type.
|
||||
*/
|
||||
LRESULT CallNextHookEx(HHOOK hhk, int nCode, WPARAM wParam, Pointer lParam);
|
||||
|
||||
/**
|
||||
* The UnhookWindowsHookEx function removes a hook procedure installed in
|
||||
* a hook chain by the SetWindowsHookEx function.
|
||||
* @param hhk
|
||||
* Handle to the hook to be removed. This parameter is a hook handle obtained
|
||||
* by a previous call to SetWindowsHookEx.
|
||||
* @return
|
||||
* If the function succeeds, the return value is nonzero.
|
||||
* If the function fails, the return value is zero. To get extended error information, call GetLastError.
|
||||
*/
|
||||
boolean UnhookWindowsHookEx(HHOOK hhk);
|
||||
|
||||
/**
|
||||
* This function retrieves a message from the calling thread's message queue
|
||||
* and places it in the specified structure.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that receives message information from the thread's message queue.
|
||||
* @param hWnd
|
||||
* Handle to the window whose messages are to be retrieved. One value has a special meaning.
|
||||
* @param wMsgFilterMin
|
||||
* Specifies the integer value of the lowest message value to be retrieved.
|
||||
* @param wMsgFilterMax
|
||||
* Specifies the integer value of the highest message value to be retrieved.
|
||||
* @return
|
||||
* Nonzero indicates that the function retrieves a message other than WM_QUIT. Zero indicates
|
||||
* that the function retrieves the WM_QUIT message, or that lpMsg is an invalid pointer. To
|
||||
* get extended error information, call GetLastError.
|
||||
*/
|
||||
int GetMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin, int wMsgFilterMax);
|
||||
|
||||
/**
|
||||
* This function checks a thread message queue for a message and places the
|
||||
* message (if any) in the specified structure.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that receives message information.
|
||||
* @param hWnd
|
||||
* Handle to the window whose messages are to be examined.
|
||||
* @param wMsgFilterMin
|
||||
* Specifies the value of the first message in the range of messages to be examined.
|
||||
* @param wMsgFilterMax
|
||||
* Specifies the value of the last message in the range of messages to be examined.
|
||||
* @param wRemoveMsg
|
||||
* Specifies how messages are handled. This parameter can be one of the following values.
|
||||
* @return
|
||||
* Nonzero indicates success. Zero indicates failure.
|
||||
*/
|
||||
boolean PeekMessage(MSG lpMsg, HWND hWnd, int wMsgFilterMin,
|
||||
int wMsgFilterMax, int wRemoveMsg);
|
||||
|
||||
/**
|
||||
* This function translates virtual-key messages into character messages. The character messages
|
||||
* are posted to the calling thread's message queue, to be read the next time the thread calls the
|
||||
* GetMessage or PeekMessage function.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that contains message information retrieved from the calling thread's
|
||||
* message queue by using the GetMessage or PeekMessage function.
|
||||
* @return
|
||||
* Nonzero indicates that the message is translated, that is, a character message is posted to the
|
||||
* thread's message queue. If the message is WM_KEYDOWN or WM_SYSKEYDOWN, the return value is nonzero,
|
||||
* regardless of the translation. Zero indicates that the message is not translated, that is, a
|
||||
* character message is not posted to the thread's message queue.
|
||||
*/
|
||||
boolean TranslateMessage(MSG lpMsg);
|
||||
|
||||
/**
|
||||
* This function dispatches a message to a window procedure. It is typically used
|
||||
* to dispatch a message retrieved by the GetMessage function.
|
||||
* @param lpMsg
|
||||
* Pointer to an MSG structure that contains the message.
|
||||
* @return
|
||||
* The return value specifies the value returned by the window procedure. Although its meaning
|
||||
* depends on the message being dispatched, the return value generally is ignored.
|
||||
*/
|
||||
LRESULT DispatchMessage(MSG lpMsg);
|
||||
|
||||
/**
|
||||
* This function places a message in the message queue associated with the thread that
|
||||
* created the specified window and then returns without waiting for the thread to process
|
||||
* the message. Messages in a message queue are retrieved by calls to the GetMessage
|
||||
* or PeekMessage function.
|
||||
* @param hWnd
|
||||
* Handle to the window whose window procedure is to receive the message.
|
||||
* @param msg
|
||||
* Specifies the message to be posted.
|
||||
* @param wParam
|
||||
* Specifies additional message-specific information.
|
||||
* @param lParam
|
||||
* Specifies additional message-specific information.
|
||||
*/
|
||||
void PostMessage(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
/**
|
||||
* This function indicates to Windows that a thread has made a request to terminate (quit).
|
||||
* It is typically used in response to a WM_DESTROY message.
|
||||
* @param nExitCode
|
||||
* Specifies an application exit code. This value is used as the wParam parameter of
|
||||
* the WM_QUIT message.
|
||||
*/
|
||||
void PostQuitMessage(int nExitCode);
|
||||
|
||||
/**
|
||||
* The GetSystemMetrics function retrieves various system metrics (widths
|
||||
* and heights of display elements) and system configuration settings. All
|
||||
* dimensions retrieved by GetSystemMetrics are in pixels.
|
||||
* @param nIndex
|
||||
* System metric or configuration setting to retrieve. This
|
||||
* parameter can be one of the following values. Note that all
|
||||
* SM_CX* values are widths and all SM_CY* values are heights.
|
||||
* Also note that all settings designed to return Boolean data
|
||||
* represent TRUE as any nonzero value, and FALSE as a zero
|
||||
* value.
|
||||
* @return
|
||||
* If the function succeeds, the return value is the requested
|
||||
* system metric or configuration setting. If the function fails,
|
||||
* the return value is zero. GetLastError does not provide extended
|
||||
* error information.
|
||||
*/
|
||||
public int GetSystemMetrics(int nIndex);
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
/* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -8,11 +8,11 @@
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.W32API.HRESULT;
|
||||
import com.sun.jna.platform.win32.WinNT.HRESULT;
|
||||
|
||||
/**
|
||||
* Error code definitions for the Win32 API functions.
|
||||
+20
-10
@@ -19,10 +19,10 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.jna.platform.FileMonitor;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLE;
|
||||
import com.sun.jna.platform.win32.W32API.HANDLEByReference;
|
||||
import com.sun.jna.platform.win32.WinBase.OVERLAPPED;
|
||||
import com.sun.jna.platform.win32.WinNT.FILE_NOTIFY_INFORMATION;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLEByReference;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.ptr.PointerByReference;
|
||||
|
||||
@@ -60,22 +60,32 @@ public class W32FileMonitor extends FileMonitor {
|
||||
FileEvent event = null;
|
||||
File file = new File(finfo.file, fni.getFilename());
|
||||
switch(fni.Action) {
|
||||
case 0:
|
||||
break;
|
||||
case WinNT.FILE_ACTION_MODIFIED:
|
||||
event = new FileEvent(file, FILE_MODIFIED); break;
|
||||
event = new FileEvent(file, FILE_MODIFIED);
|
||||
break;
|
||||
case WinNT.FILE_ACTION_ADDED:
|
||||
event = new FileEvent(file, FILE_CREATED); break;
|
||||
event = new FileEvent(file, FILE_CREATED);
|
||||
break;
|
||||
case WinNT.FILE_ACTION_REMOVED:
|
||||
event = new FileEvent(file, FILE_DELETED); break;
|
||||
event = new FileEvent(file, FILE_DELETED);
|
||||
break;
|
||||
case WinNT.FILE_ACTION_RENAMED_OLD_NAME:
|
||||
event = new FileEvent(file, FILE_NAME_CHANGED_OLD); break;
|
||||
event = new FileEvent(file, FILE_NAME_CHANGED_OLD);
|
||||
break;
|
||||
case WinNT.FILE_ACTION_RENAMED_NEW_NAME:
|
||||
event = new FileEvent(file, FILE_NAME_CHANGED_NEW); break;
|
||||
event = new FileEvent(file, FILE_NAME_CHANGED_NEW);
|
||||
break;
|
||||
default:
|
||||
// TODO: other actions...
|
||||
System.err.println("Unrecognized file action '" + fni.Action + "'");
|
||||
}
|
||||
if (event != null)
|
||||
|
||||
if (event != null) {
|
||||
notify(event);
|
||||
}
|
||||
|
||||
fni = fni.next();
|
||||
} while (fni != null);
|
||||
|
||||
@@ -163,7 +173,7 @@ public class W32FileMonitor extends FileMonitor {
|
||||
WinNT.FILE_LIST_DIRECTORY,
|
||||
mask, null, WinNT.OPEN_EXISTING,
|
||||
flags, null);
|
||||
if (Kernel32.INVALID_HANDLE_VALUE.equals(handle)) {
|
||||
if (WinBase.INVALID_HANDLE_VALUE.equals(handle)) {
|
||||
throw new IOException("Unable to open " + file + " ("
|
||||
+ klib.GetLastError() + ")");
|
||||
}
|
||||
@@ -173,7 +183,7 @@ public class W32FileMonitor extends FileMonitor {
|
||||
handleMap.put(handle, finfo);
|
||||
// Existing port is returned
|
||||
port = klib.CreateIoCompletionPort(handle, port, handle.getPointer(), 0);
|
||||
if (Kernel32.INVALID_HANDLE_VALUE.equals(port)) {
|
||||
if (WinBase.INVALID_HANDLE_VALUE.equals(port)) {
|
||||
throw new IOException("Unable to create/use I/O Completion port "
|
||||
+ "for " + file + " ("
|
||||
+ klib.GetLastError() + ")");
|
||||
+12
@@ -1,3 +1,15 @@
|
||||
/* Copyright (c) 2007 Timothy Wall, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import java.io.File;
|
||||
@@ -0,0 +1,207 @@
|
||||
/* Copyright (c) 2010 EugineLev, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.Winsvc.SC_HANDLE;
|
||||
import com.sun.jna.platform.win32.Winsvc.SC_STATUS_TYPE;
|
||||
import com.sun.jna.platform.win32.Winsvc.SERVICE_STATUS_PROCESS;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
|
||||
/**
|
||||
* Win32 Service wrapper
|
||||
* @author EugineLev
|
||||
*/
|
||||
public class W32Service {
|
||||
SC_HANDLE _handle = null;
|
||||
|
||||
/**
|
||||
* Win32 Service
|
||||
* @param handle
|
||||
* A handle to the service. This handle is returned by the CreateService or OpenService
|
||||
* function, and it must have the SERVICE_QUERY_STATUS access right.
|
||||
*/
|
||||
public W32Service(SC_HANDLE handle) {
|
||||
_handle = handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close service.
|
||||
*/
|
||||
public void close() {
|
||||
if (_handle != null) {
|
||||
if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current status of the specified service based on the specified information level.
|
||||
* @return
|
||||
* Service status information
|
||||
*/
|
||||
public SERVICE_STATUS_PROCESS queryStatus() {
|
||||
IntByReference size = new IntByReference();
|
||||
|
||||
Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
|
||||
null, 0, size);
|
||||
|
||||
SERVICE_STATUS_PROCESS status = new SERVICE_STATUS_PROCESS(size.getValue());
|
||||
if(! Advapi32.INSTANCE.QueryServiceStatusEx(_handle, SC_STATUS_TYPE.SC_STATUS_PROCESS_INFO,
|
||||
status, status.size(), size)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void startService() {
|
||||
waitForNonPendingState();
|
||||
// If the service is already running - return
|
||||
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
|
||||
return;
|
||||
}
|
||||
if (! Advapi32.INSTANCE.StartService(_handle, 0, null)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
waitForNonPendingState();
|
||||
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
|
||||
throw new RuntimeException("Unable to start the service");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop service.
|
||||
*/
|
||||
public void stopService() {
|
||||
waitForNonPendingState();
|
||||
// If the service is already stopped - return
|
||||
if (queryStatus().dwCurrentState == Winsvc.SERVICE_STOPPED) {
|
||||
return;
|
||||
}
|
||||
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_STOP,
|
||||
new Winsvc.SERVICE_STATUS())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
waitForNonPendingState();
|
||||
if (queryStatus().dwCurrentState != Winsvc.SERVICE_STOPPED) {
|
||||
throw new RuntimeException("Unable to stop the service");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Continue service.
|
||||
*/
|
||||
public void continueService() {
|
||||
waitForNonPendingState();
|
||||
// If the service is already stopped - return
|
||||
if (queryStatus().dwCurrentState == Winsvc.SERVICE_RUNNING) {
|
||||
return;
|
||||
}
|
||||
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_CONTINUE,
|
||||
new Winsvc.SERVICE_STATUS())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
waitForNonPendingState();
|
||||
if (queryStatus().dwCurrentState != Winsvc.SERVICE_RUNNING) {
|
||||
throw new RuntimeException("Unable to continue the service");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pause service.
|
||||
*/
|
||||
public void pauseService() {
|
||||
waitForNonPendingState();
|
||||
// If the service is already paused - return
|
||||
if (queryStatus().dwCurrentState == Winsvc.SERVICE_PAUSED) {
|
||||
return;
|
||||
}
|
||||
if (! Advapi32.INSTANCE.ControlService(_handle, Winsvc.SERVICE_CONTROL_PAUSE,
|
||||
new Winsvc.SERVICE_STATUS())) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
waitForNonPendingState();
|
||||
if (queryStatus().dwCurrentState != Winsvc.SERVICE_PAUSED) {
|
||||
throw new RuntimeException("Unable to pause the service");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the state to change to something other than a pending state.
|
||||
*/
|
||||
public void waitForNonPendingState() {
|
||||
|
||||
SERVICE_STATUS_PROCESS status = queryStatus();
|
||||
|
||||
int previousCheckPoint = status.dwCheckPoint;
|
||||
int checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();;
|
||||
|
||||
while (isPendingState(status.dwCurrentState)) {
|
||||
|
||||
// if the checkpoint advanced, start new tick count
|
||||
if (status.dwCheckPoint != previousCheckPoint) {
|
||||
previousCheckPoint = status.dwCheckPoint;
|
||||
checkpointStartTickCount = Kernel32.INSTANCE.GetTickCount();
|
||||
}
|
||||
|
||||
// if the time that passed is greater than the wait hint - throw timeout exception
|
||||
if (Kernel32.INSTANCE.GetTickCount() - checkpointStartTickCount > status.dwWaitHint) {
|
||||
throw new RuntimeException("Timeout waiting for service to change to a non-pending state.");
|
||||
}
|
||||
|
||||
// do not wait longer than the wait hint. A good interval is
|
||||
// one-tenth the wait hint, but no less than 1 second and no
|
||||
// more than 10 seconds.
|
||||
|
||||
int dwWaitTime = status.dwWaitHint / 10;
|
||||
|
||||
if (dwWaitTime < 1000)
|
||||
dwWaitTime = 1000;
|
||||
else if (dwWaitTime > 10000)
|
||||
dwWaitTime = 10000;
|
||||
|
||||
try {
|
||||
Thread.sleep( dwWaitTime );
|
||||
} catch (InterruptedException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
status = queryStatus();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPendingState(int state) {
|
||||
switch (state) {
|
||||
case Winsvc.SERVICE_CONTINUE_PENDING:
|
||||
case Winsvc.SERVICE_STOP_PENDING:
|
||||
case Winsvc.SERVICE_PAUSE_PENDING:
|
||||
case Winsvc.SERVICE_START_PENDING:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the service handle.
|
||||
* @return
|
||||
* Returns the service handle.
|
||||
*/
|
||||
public SC_HANDLE getHandle() {
|
||||
return _handle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/* Copyright (c) 2010 EugineLev, All Rights Reserved
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
import com.sun.jna.platform.win32.Winsvc.SC_HANDLE;
|
||||
|
||||
/**
|
||||
* Win32 Service Manager wrapper
|
||||
* @author EugineLev
|
||||
*/
|
||||
public class W32ServiceManager {
|
||||
SC_HANDLE _handle = null;
|
||||
String _machineName = null;
|
||||
String _databaseName = null;
|
||||
|
||||
public W32ServiceManager() {
|
||||
}
|
||||
|
||||
public W32ServiceManager(String machineName, String databaseName) {
|
||||
_machineName = machineName;
|
||||
_databaseName = databaseName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the Service Manager with the supplied permissions.
|
||||
* @param permissions
|
||||
* Permissions.
|
||||
*/
|
||||
public void open(int permissions) {
|
||||
close();
|
||||
|
||||
_handle = Advapi32.INSTANCE.OpenSCManager(
|
||||
_machineName, _databaseName, permissions);
|
||||
|
||||
if (_handle == null) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the previously opened Service Manager.
|
||||
*/
|
||||
public void close() {
|
||||
if (_handle != null) {
|
||||
if (! Advapi32.INSTANCE.CloseServiceHandle(_handle)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
_handle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a Service.
|
||||
* @param serviceName
|
||||
* Service name.
|
||||
* @param permissions
|
||||
* Permissions.
|
||||
* @return
|
||||
* Returns an opened service.
|
||||
*/
|
||||
public W32Service openService(String serviceName, int permissions) {
|
||||
SC_HANDLE serviceHandle = Advapi32.INSTANCE.OpenService(
|
||||
_handle, serviceName, permissions);
|
||||
|
||||
if (serviceHandle == null) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
|
||||
return new W32Service(serviceHandle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service manager handle.
|
||||
* @return
|
||||
* Returns the service manager handle.
|
||||
*/
|
||||
public SC_HANDLE getHandle() {
|
||||
return _handle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010 Digital Rapids Corp.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2010 Timothy Wall, All Rights Reserved
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*/
|
||||
package com.sun.jna.platform.win32;
|
||||
|
||||
/**
|
||||
* Constant defined in WTypes.h
|
||||
* @author scott.palmer
|
||||
*/
|
||||
public interface WTypes {
|
||||
public static final int CLSCTX_INPROC_SERVER = 0x1;
|
||||
public static final int CLSCTX_INPROC_HANDLER = 0x2;
|
||||
public static final int CLSCTX_LOCAL_SERVER = 0x4;
|
||||
public static final int CLSCTX_INPROC_SERVER16 = 0x8;
|
||||
public static final int CLSCTX_REMOTE_SERVER = 0x10;
|
||||
public static final int CLSCTX_INPROC_HANDLER16 = 0x20;
|
||||
public static final int CLSCTX_RESERVED1 = 0x40;
|
||||
public static final int CLSCTX_RESERVED2 = 0x80;
|
||||
public static final int CLSCTX_RESERVED3 = 0x100;
|
||||
public static final int CLSCTX_RESERVED4 = 0x200;
|
||||
public static final int CLSCTX_NO_CODE_DOWNLOAD = 0x400;
|
||||
public static final int CLSCTX_RESERVED5 = 0x800;
|
||||
public static final int CLSCTX_NO_CUSTOM_MARSHAL = 0x1000;
|
||||
public static final int CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000;
|
||||
public static final int CLSCTX_NO_FAILURE_LOG = 0x4000;
|
||||
public static final int CLSCTX_DISABLE_AAA = 0x8000;
|
||||
public static final int CLSCTX_ENABLE_AAA = 0x10000;
|
||||
public static final int CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000;
|
||||
public static final int CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000;
|
||||
public static final int CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000;
|
||||
}
|
||||
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