Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update fork #1

Merged
merged 12 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ pom-jna-platform.xml.asc
.idea
*.iml
/contrib/platform/${build.generated.sources.dir}/
/contrib/platform/${build}/
/contrib/platform/${build}/
/contrib/platform/nbproject/private/
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Features
* [#980](https://github.com/java-native-access/jna/issues/980): Added `PERF_OBJECT_TYPE`, `PERF_COUNTER_BLOCK`, and `PERF_COUNTER_DEFINITION` to `c.s.j.platform.win32.WinPerf` and added `Pointer` constructors to ``PERF_INSTANCE_DEFINITION` and `PERF_DATA_BLOCK` - [@dbwiddis](https://github.com/dbwiddis).
* [#981](https://github.com/java-native-access/jna/issues/981): Added `WTS_PROCESS_INFO_EX`, `WTSEnumerateProcessesEx`, and `WTSFreeMemoryEx` to `c.s.j.platform.win32.Wtsapi32` - [@dbwiddis](https://github.com/dbwiddis).
* [#983](https://github.com/java-native-access/jna/issues/983): Added `GetIfEntry`, `GetIfEntry2`, and `GetNetworkParams` and supporting structures `MIB_IFROW`, `MIB_IF_ROW2`, and `FIXED_INFO` to `c.s.j.platform.win32.IPHlpAPI.java` - [@dbwiddis](https://github.com/dbwiddis).
* [#984](https://github.com/java-native-access/jna/issues/984): Added `CM_Locate_DevNode`, `CM_Get_Parent`, `CM_Get_Child`, `CM_Get_Sibling`, `CM_Get_Device_ID`, and `CM_Get_Device_ID_Size` to `c.s.j.platform.win32.Cfgmgr32.java` and a `c.s.j.platform.win32.Cfgmgr32Util` class for `CM_Get_Device_ID` - [@dbwiddis](https://github.com/dbwiddis).
* [#988](https://github.com/java-native-access/jna/issues/988): Added `PdhLookupPerfIndexByEnglishName` to `c.s.j.platform.win32.PdhUtil` - [@dbwiddis](https://github.com/dbwiddis).

Bug Fixes
---------
Expand Down Expand Up @@ -51,6 +53,7 @@ Bug Fixes
<li>The resulting `sunos-x86.jar` is copied back to the original build system to `lib/native/sunos-x86.jar`</li>
</ol> - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#958](https://github.com/java-native-access/jna/issues/958): Update for PR 863: Old toolchains produce binaries without hard-/softfloat markers. Rasbian is missinng the markers and the oracle JDK is also affected. For hardfloat detection now also the Arm EABI section is also considered - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#974](https://github.com/java-native-access/jna/issues/974): If the callback code failed to attach to the JVM, this lead to a segfault. The success of attaching to the JVM was checked to late and an invalid `JNIEnv` pointer was used to access the JVM - [@matthiasblaesing](https://github.com/matthiasblaesing).

Breaking Changes
----------------
Expand All @@ -75,6 +78,7 @@ Breaking Changes
* the parameters of the methods `gethostname`, `sethostname`, `getdomainname`
and `setdomainname` in the interface `com.sun.jna.platform.unix.LibCAPI`
were changed from `(char[] name, int len)` to `(byte[] name, int len)`
* `com.sun.jna.Platform#isAix` was replaced by `com.sun.jna.Platform#isAIX`
* `com.sun.jna.platform.win32.Sspi.SecBufferDesc` was incompatibly changed to
match the correct native semantics. SecBufferDesc describing more than one
buffer were broken. For most usecases
Expand Down Expand Up @@ -110,6 +114,10 @@ Breaking Changes
consequence `com.sun.jna.platform.win32.Advapi32Util#getFileSecurity` was
changed similarly. The SID accessors `getSidString` and `getSID` were moved
from `ACEStructure` to `ACCESS_ACEStructure`.
* `com.sun.jna.platform.win32.Ole32#CoCreateGuid(GUID.ByReference pguid)` was replaced by
`com.sun.jna.platform.win32.Ole32#CoCreateGuid(GUID pguid)` and
`com.sun.jna.platform.win32.Ole32#CLSIDFromString(WString lpsz, CLSID.ByReference pclsid)` was replaced by
`com.sun.jna.platform.win32.Ole32#CLSIDFromString(String lpsz, CLSID.ByReference pclsid)`

Release 4.5.0
=============
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Java Native Access (JNA)
========================

The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://java-native-access.github.io/jna/4.5.1/javadoc/). Please read the [overview](http://java-native-access.github.io/jna/4.5.1/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).
The definitive JNA reference (including an overview and usage details) is in the [JavaDoc](http://java-native-access.github.io/jna/4.5.2/javadoc/). Please read the [overview](http://java-native-access.github.io/jna/4.5.2/javadoc/overview-summary.html#overview_description). Questions, comments, or exploratory conversations should begin on the [mailing list](http://groups.google.com/group/jna-users), although you may find it easier to find answers to already-solved problems on [StackOverflow](http://stackoverflow.com/questions/tagged/jna).

JNA provides Java programs easy access to native shared libraries without writing anything but Java code - no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes.

Expand Down Expand Up @@ -58,20 +58,20 @@ Pre-built platform support may be found [here](https://github.com/java-native-ac
Download
========

Version 4.5.1
Version 4.5.2

JNA
---

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna)&nbsp;[jna.jar](http://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna)&nbsp;[jna.jar](http://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.2/jna-4.5.2.jar)

This is the core artifact of JNA and contains only the binding library and the
core helper classes.

JNA Platform
------------

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna-platform/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna-platform) &nbsp; [jna-platform.jar](http://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/4.5.1/jna-platform-4.5.1.jar)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna-platform/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna-platform) &nbsp; [jna-platform.jar](http://repo1.maven.org/maven2/net/java/dev/jna/jna-platform/4.5.2/jna-platform-4.5.2.jar)

This artifact holds cross-platform mappings and mappings for a number of commonly used platform
functions, including a large number of Win32 mappings as well as a set of utility classes
Expand Down Expand Up @@ -139,12 +139,12 @@ Using the Library
* [Platform Library](https://github.com/java-native-access/jna/blob/master/www/PlatformLibrary.md)
* [Direct Method Mapping](https://github.com/java-native-access/jna/blob/master/www/DirectMapping.md) (Optimization)
* [Frequently Asked Questions (FAQ)](https://github.com/java-native-access/jna/blob/master/www/FrequentlyAskedQuestions.md)
* [Avoiding Crashes](http://java-native-access.github.io/jna/4.5.1/javadoc/overview-summary.html#crash-protection)
* [Avoiding Crashes](http://java-native-access.github.io/jna/4.5.2/javadoc/overview-summary.html#crash-protection)

Primary Documentation (JavaDoc)
===============================

The definitive JNA reference is in the [JavaDoc](http://java-native-access.github.io/jna/4.5.1/javadoc/).
The definitive JNA reference is in the [JavaDoc](http://java-native-access.github.io/jna/4.5.2/javadoc/).

Developers
==========
Expand Down
8 changes: 4 additions & 4 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
</condition>
<property name="jna.version" value="${jna.major}.${jna.minor}.${jna.revision}${version.suffix}"/>
<!-- jnidispatch library release version -->
<property name="jni.major" value="5"/>
<property name="jni.minor" value="2"/>
<property name="jni.revision" value="1"/>
<property name="jni.major" value="6"/>
<property name="jni.minor" value="0"/>
<property name="jni.revision" value="0"/>
<property name="jni.build" value="0"/> <!--${build.number}-->
<property name="jni.version" value="${jni.major}.${jni.minor}.${jni.revision}"/>
<property name="jni.md5" value="74e8f8e397c43487738c5c1f1363498b"/>
<property name="jni.md5" value="147a998f0cbc89681a1ae6c0dd121629"/>
<property name="spec.title" value="Java Native Access (JNA)"/>
<property name="spec.vendor" value="${vendor}"/>
<property name="spec.version" value="${jna.major}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.Guid.CLSID;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.OaIdl.MEMBERID;
Expand Down Expand Up @@ -87,8 +86,7 @@ public class TypeLibUtil {
public TypeLibUtil(String clsidStr, int wVerMajor, int wVerMinor) {
CLSID.ByReference clsid = new CLSID.ByReference();
// get CLSID from string
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(clsidStr),
clsid);
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(clsidStr, clsid);
COMUtils.checkRC(hr);

// load typelib
Expand Down
192 changes: 192 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/Cfgmgr32.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
/* Copyright (c) 2018 Daniel Widdis, All Rights Reserved
*
* The contents of this file is dual-licensed under 2
* alternative Open Source/Free licenses: LGPL 2.1 or later and
* Apache License 2.0. (starting with JNA version 4.0.0).
*
* You can freely decide which license you want to apply to
* the project.
*
* You may obtain a copy of the LGPL License at:
*
* http://www.gnu.org/licenses/licenses.html
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "LGPL2.1".
*
* You may obtain a copy of the Apache License at:
*
* http://www.apache.org/licenses/
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "AL2.0".
*/
package com.sun.jna.platform.win32;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.W32APIOptions;

/**
* Windows Cfgmgr32.
*
* @author widdis[at]gmail[dot]com
*/
public interface Cfgmgr32 extends Library {
Cfgmgr32 INSTANCE = Native.load("Cfgmgr32", Cfgmgr32.class, W32APIOptions.DEFAULT_OPTIONS);

public final static int CR_SUCCESS = 0;
public final static int CR_BUFFER_SMALL = 0x0000001A;

public final static int CM_LOCATE_DEVNODE_NORMAL = 0;
public final static int CM_LOCATE_DEVNODE_PHANTOM = 1;
public final static int CM_LOCATE_DEVNODE_CANCELREMOVE = 2;
public final static int CM_LOCATE_DEVNODE_NOVALIDATION = 4;
public final static int CM_LOCATE_DEVNODE_BITS = 7;

/**
* The CM_Locate_DevNode function obtains a device instance handle to the
* device node that is associated with a specified device instance ID on the
* local machine.
*
* @param pdnDevInst
* A pointer to a device instance handle that CM_Locate_DevNode
* retrieves. The retrieved handle is bound to the local machine.
* @param pDeviceID
* A pointer to a NULL-terminated string representing a device
* instance ID. If this value is NULL, or if it points to a
* zero-length string, the function retrieves a device instance
* handle to the device at the root of the device tree. *
* @param ulFlags
* A variable of ULONG type that supplies one of the following
* flag values that apply if the caller supplies a device
* instance identifier: CM_LOCATE_DEVNODE_NORMAL,
* CM_LOCATE_DEVNODE_PHANTOM, CM_LOCATE_DEVNODE_CANCELREMOVE, or
* CM_LOCATE_DEVNODE_NOVALIDATION
* @return If the operation succeeds, CM_Locate_DevNode returns CR_SUCCESS.
* Otherwise, the function returns one of the CR_Xxx error codes
* that are defined in Cfgmgr32.h.
* @see <A HREF=
* "https://docs.microsoft.com/en-us/windows/desktop/api/cfgmgr32/nf-cfgmgr32-cm_locate_devnodea">
* CM_Locate_DevNode</A>
*/
int CM_Locate_DevNode(IntByReference pdnDevInst, String pDeviceID, int ulFlags);

/**
* The CM_Get_Parent function obtains a device instance handle to the parent
* node of a specified device node (devnode) in the local machine's device
* tree.
*
* @param pdnDevInst
* Caller-supplied pointer to the device instance handle to the
* parent node that this function retrieves. The retrieved handle
* is bound to the local machine.
* @param dnDevInst
* Caller-supplied device instance handle that is bound to the
* local machine.
* @param ulFlags
* Not used, must be zero.
* @return If the operation succeeds, the function returns CR_SUCCESS.
* Otherwise, it returns one of the CR_-prefixed error codes defined
* in Cfgmgr32.h.
* @see <A HREF=
* "https://docs.microsoft.com/en-us/windows/desktop/api/cfgmgr32/nf-cfgmgr32-cm_get_parent">
* CM_Get_Parent</A>
*/
int CM_Get_Parent(IntByReference pdnDevInst, int dnDevInst, int ulFlags);

/**
* The CM_Get_Child function is used to retrieve a device instance handle to
* the first child node of a specified device node (devnode) in the local
* machine's device tree.
*
* @param pdnDevInst
* Caller-supplied pointer to the device instance handle to the
* child node that this function retrieves. The retrieved handle
* is bound to the local machine.
* @param dnDevInst
* Caller-supplied device instance handle that is bound to the
* local machine.
* @param ulFlags
* Not used, must be zero.
* @return If the operation succeeds, the function returns CR_SUCCESS.
* Otherwise, it returns one of the CR_-prefixed error codes defined
* in Cfgmgr32.h.
* @see <A HREF=
* "https://docs.microsoft.com/en-us/windows/desktop/api/cfgmgr32/nf-cfgmgr32-cm_get_child">
* CM_Get_Child</A>
*/
int CM_Get_Child(IntByReference pdnDevInst, int dnDevInst, int ulFlags);

/**
* The CM_Get_Sibling function obtains a device instance handle to the next
* sibling node of a specified device node (devnode) in the local machine's
* device tree.
*
* @param pdnDevInst
* Caller-supplied pointer to the device instance handle to the
* sibling node that this function retrieves. The retrieved
* handle is bound to the local machine.
* @param dnDevInst
* Caller-supplied device instance handle that is bound to the
* local machine.
* @param ulFlags
* Not used, must be zero.
* @return If the operation succeeds, the function returns CR_SUCCESS.
* Otherwise, it returns one of the CR_-prefixed error codes defined
* in Cfgmgr32.h.
* @see <A HREF=
* "https://docs.microsoft.com/en-us/windows/desktop/api/cfgmgr32/nf-cfgmgr32-cm_get_sibling">
* CM_Get_Sibling</A>
*/
int CM_Get_Sibling(IntByReference pdnDevInst, int dnDevInst, int ulFlags);

/**
* The CM_Get_Device_ID function retrieves the device instance ID for a
* specified device instance on the local machine.
*
* @param devInst
* Caller-supplied device instance handle that is bound to the
* local machine.
* @param Buffer
* Address of a buffer to receive a device instance ID string.
* The required buffer size can be obtained by calling
* CM_Get_Device_ID_Size, then incrementing the received value to
* allow room for the string's terminating NULL.
* @param BufferLen
* Caller-supplied length, in characters, of the buffer specified
* by Buffer.
* @param ulFlags
* Not used, must be zero.
* @return If the operation succeeds, the function returns CR_SUCCESS.
* Otherwise, it returns one of the CR_-prefixed error codes defined
* in Cfgmgr32.h.
* @see <A HREF=
* "https://docs.microsoft.com/en-us/windows/desktop/api/cfgmgr32/nf-cfgmgr32-cm_get_device_idw">
* CM_Get_Device_ID</A>
*/
int CM_Get_Device_ID(int devInst, Pointer Buffer, int BufferLen, int ulFlags);

/**
* The CM_Get_Device_ID_Size function retrieves the buffer size required to
* hold a device instance ID for a device instance on the local machine.
*
* @param pulLen
* Receives a value representing the required buffer size, in
* characters.
* @param dnDevInst
* Caller-supplied device instance handle that is bound to the
* local machine.
* @param ulFlags
* Not used, must be zero.
* @return If the operation succeeds, the function returns CR_SUCCESS.
* Otherwise, it returns one of the CR_-prefixed error codes defined
* in Cfgmgr32.h.
* @see <A HREF=
* "https://docs.microsoft.com/en-us/windows/desktop/api/cfgmgr32/nf-cfgmgr32-cm_get_device_id_size">
* CM_Get_Device_ID_Size</A>
*/
int CM_Get_Device_ID_Size(IntByReference pulLen, int dnDevInst, int ulFlags);
}
Loading