mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 521515: Update to JNA 5.6.0
Change-Id: Id56f6366e0bbaa33b1d0967cd64487fc173b3833
This commit is contained in:
parent
3e485f66d1
commit
9c370cfcf0
9 changed files with 26 additions and 78 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.core.native;singleton:=true
|
||||
Bundle-Version: 6.1.0.qualifier
|
||||
Bundle-Version: 6.1.100.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.internal.core.natives.CNativePlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>6.1.0-SNAPSHOT</version>
|
||||
<version>6.1.100-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.core.native</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.internal.core.natives.CNativePlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
/**
|
||||
* @author DSchaefer
|
||||
|
@ -33,14 +34,19 @@ public abstract class WindowsRegistry {
|
|||
}
|
||||
|
||||
public static WindowsRegistry getRegistry() {
|
||||
if (registry == null) {
|
||||
try {
|
||||
registry = CNativePlugin.getDefault().getWindowsRegistry();
|
||||
} catch (CoreException e) {
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
if (registry == null) {
|
||||
try {
|
||||
registry = CNativePlugin.getDefault().getWindowsRegistry();
|
||||
} catch (CoreException e) {
|
||||
CNativePlugin.log("Failed to load WindowsRegistry", e); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return registry;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,12 +2,12 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %fragmentName.win32
|
||||
Bundle-SymbolicName: org.eclipse.cdt.core.win32; singleton:=true
|
||||
Bundle-Version: 6.0.100.qualifier
|
||||
Bundle-Version: 6.0.200.qualifier
|
||||
Bundle-Vendor: %providerName
|
||||
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.1.0,7.0.0)"
|
||||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Eclipse-PlatformFilter: (osgi.os=win32)
|
||||
Automatic-Module-Name: org.eclipse.cdt.core.win32
|
||||
Require-Bundle: com.sun.jna;bundle-version="4.5.1",
|
||||
com.sun.jna.platform;bundle-version="4.5.1"
|
||||
Require-Bundle: com.sun.jna;bundle-version="[5.6.0,6.0.0)",
|
||||
com.sun.jna.platform;bundle-version="[5.6.0,6.0.0)"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>6.0.100-SNAPSHOT</version>
|
||||
<version>6.0.200-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.core.win32</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
|
|
|
@ -15,79 +15,16 @@
|
|||
package org.eclipse.cdt.internal.core.win32;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.IProcessInfo;
|
||||
import org.eclipse.cdt.core.IProcessList;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.platform.win32.Kernel32;
|
||||
import com.sun.jna.platform.win32.Kernel32Util;
|
||||
import com.sun.jna.platform.win32.PsapiUtil;
|
||||
import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinDef.DWORD;
|
||||
import com.sun.jna.platform.win32.WinNT;
|
||||
import com.sun.jna.platform.win32.WinNT.HANDLE;
|
||||
import com.sun.jna.ptr.IntByReference;
|
||||
import com.sun.jna.win32.W32APIOptions;
|
||||
|
||||
public class ProcessList implements IProcessList {
|
||||
// TODO: Remove this inner class when JNA 5.6 is available
|
||||
private static abstract class PsapiUtil {
|
||||
public interface Psapi extends com.sun.jna.platform.win32.Psapi {
|
||||
Psapi INSTANCE = Native.loadLibrary("psapi", Psapi.class, W32APIOptions.DEFAULT_OPTIONS); //$NON-NLS-1$
|
||||
|
||||
boolean EnumProcesses(int[] lpidProcess, int cb, IntByReference lpcbNeeded);
|
||||
}
|
||||
|
||||
public static int[] enumProcesses() {
|
||||
int size = 0;
|
||||
int[] lpidProcess = null;
|
||||
IntByReference lpcbNeeded = new IntByReference();
|
||||
do {
|
||||
size += 1024;
|
||||
lpidProcess = new int[size];
|
||||
if (!Psapi.INSTANCE.EnumProcesses(lpidProcess, size * DWORD.SIZE, lpcbNeeded)) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
} while (size == lpcbNeeded.getValue() / DWORD.SIZE);
|
||||
|
||||
return Arrays.copyOf(lpidProcess, lpcbNeeded.getValue() / DWORD.SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this inner class when JNA 5.6 is available
|
||||
private static abstract class Kernel32Util extends com.sun.jna.platform.win32.Kernel32Util {
|
||||
public static final String QueryFullProcessImageName(int pid, int dwFlags) {
|
||||
HANDLE hProcess = null;
|
||||
Win32Exception we = null;
|
||||
|
||||
try {
|
||||
hProcess = Kernel32.INSTANCE.OpenProcess(WinNT.PROCESS_QUERY_INFORMATION | WinNT.PROCESS_VM_READ, false,
|
||||
pid);
|
||||
if (hProcess == null) {
|
||||
throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
|
||||
}
|
||||
return QueryFullProcessImageName(hProcess, dwFlags);
|
||||
} catch (Win32Exception e) {
|
||||
we = e;
|
||||
throw we; // re-throw to invoke finally block
|
||||
} finally {
|
||||
try {
|
||||
closeHandle(hProcess);
|
||||
} catch (Win32Exception e) {
|
||||
if (we == null) {
|
||||
we = e;
|
||||
} else {
|
||||
we.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
if (we != null) {
|
||||
throw we;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IProcessInfo[] NOPROCESS = new IProcessInfo[0];
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.utils.WindowsRegistry;
|
|||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Pointer;
|
||||
import com.sun.jna.platform.win32.Advapi32;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.Advapi32Util.EnumKey;
|
||||
|
@ -114,7 +115,7 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
char[] lpValueName = new char[Advapi32.MAX_KEY_LENGTH];
|
||||
IntByReference lpcchValueName = new IntByReference(Advapi32.MAX_KEY_LENGTH);
|
||||
int rc = Advapi32.INSTANCE.RegEnumValue(phkKey.getValue(), index, lpValueName, lpcchValueName, null,
|
||||
null, null, null);
|
||||
null, (Pointer) null, null);
|
||||
|
||||
if (rc != W32Errors.ERROR_SUCCESS) {
|
||||
throw new Win32Exception(rc);
|
||||
|
|
|
@ -216,6 +216,8 @@
|
|||
<bundle id="com.google.gson" version="0.0.0"/>
|
||||
<bundle id="org.freemarker" version="0.0.0"/>
|
||||
<bundle id="org.yaml.snakeyaml" version="0.0.0"/>
|
||||
<bundle id="com.sun.jna" version="0.0.0"/>
|
||||
<bundle id="com.sun.jna.platform" version="0.0.0"/>
|
||||
<bundle id="org.eclipse.tools.templates.core" version="0.0.0"/>
|
||||
<bundle id="org.eclipse.tools.templates.core.source" version="0.0.0"/>
|
||||
<bundle id="org.eclipse.tools.templates.freemarker" version="0.0.0"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?pde version="3.8"?>
|
||||
<target name="cdt" sequenceNumber="102">
|
||||
<target name="cdt" sequenceNumber="103">
|
||||
<locations>
|
||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||
<unit id="org.eclipse.license.feature.group" version="0.0.0"/>
|
||||
|
@ -74,6 +74,8 @@
|
|||
<unit id="org.mockito" version="0.0.0"/>
|
||||
<unit id="org.slf4j.impl.log4j12" version="0.0.0"/>
|
||||
<unit id="org.yaml.snakeyaml" version="0.0.0"/>
|
||||
<unit id="com.sun.jna" version="5.6.0.v20200716-0148"/>
|
||||
<unit id="com.sun.jna.platform" version="5.6.0.v20200722-0209"/>
|
||||
<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20201130205003/repository"/>
|
||||
</location>
|
||||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
|
||||
|
|
Loading…
Add table
Reference in a new issue