Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core.native/build.properties6
-rwxr-xr-xcore/org.eclipse.cdt.core.native/plugin.properties2
-rw-r--r--core/org.eclipse.cdt.core.native/plugin.xml5
-rw-r--r--core/org.eclipse.cdt.core.native/schema/WindowsRegistry.exsd66
-rw-r--r--core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/CNativePlugin.java37
-rw-r--r--core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java44
-rwxr-xr-xcore/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/winreg.dllbin39936 -> 0 bytes
-rw-r--r--core/org.eclipse.cdt.core.win32/fragment.xml7
-rw-r--r--core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk14
-rw-r--r--core/org.eclipse.cdt.core.win32/library/cdt-win32.sln33
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/.gitignore1
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp31
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp17
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h25
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/targetver.h21
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp154
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj175
-rw-r--r--core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters36
-rw-r--r--core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java112
19 files changed, 255 insertions, 531 deletions
diff --git a/core/org.eclipse.cdt.core.native/build.properties b/core/org.eclipse.cdt.core.native/build.properties
index c065e6858b0..2e7a449116e 100644
--- a/core/org.eclipse.cdt.core.native/build.properties
+++ b/core/org.eclipse.cdt.core.native/build.properties
@@ -19,8 +19,10 @@ bin.includes = plugin.properties,\
about.ini,\
about.mappings,\
cdt_logo_icon32.png,\
- about.properties
-src.includes = about.html
+ about.properties,\
+ plugin.xml
+src.includes = about.html,\
+ schema/
javadoc.packages = org.eclipse.cdt.utils.*,\
org.eclipse.cdt.utils.pty.*,\
org.eclipse.cdt.utils.spawner.*
diff --git a/core/org.eclipse.cdt.core.native/plugin.properties b/core/org.eclipse.cdt.core.native/plugin.properties
index 40d7fc25cea..1e8e0166d60 100755
--- a/core/org.eclipse.cdt.core.native/plugin.properties
+++ b/core/org.eclipse.cdt.core.native/plugin.properties
@@ -16,6 +16,8 @@
pluginName=C/C++ Development Tools Core Native Utilities
providerName=Eclipse CDT
+WindowsRegistry.name=Windows Registry
+
fragmentName.linux = C/C++ Development Tools Core Native Utilities for Linux
fragmentName.linux.ppc64le = C/C++ Development Tools Core Native Utilities for Linux (ppc64le)
fragmentName.linux.x86_64 = C/C++ Development Tools Core Native Utilities for Linux (x86_64)
diff --git a/core/org.eclipse.cdt.core.native/plugin.xml b/core/org.eclipse.cdt.core.native/plugin.xml
new file mode 100644
index 00000000000..174452ec9f4
--- /dev/null
+++ b/core/org.eclipse.cdt.core.native/plugin.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension-point id="WindowsRegistry" name="%WindowsRegistry.name" schema="schema/WindowsRegistry.exsd"/>
+</plugin>
diff --git a/core/org.eclipse.cdt.core.native/schema/WindowsRegistry.exsd b/core/org.eclipse.cdt.core.native/schema/WindowsRegistry.exsd
new file mode 100644
index 00000000000..eabfd78bfe0
--- /dev/null
+++ b/core/org.eclipse.cdt.core.native/schema/WindowsRegistry.exsd
@@ -0,0 +1,66 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core.native" id="WindowsRegistry" name="Windows Registry Query Exentsion"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="windowsRegistry"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+ <element name="windowsRegistry">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.utils.WindowsRegistry"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="platform" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+</schema>
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/CNativePlugin.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/CNativePlugin.java
index 976fa95387e..db2a72763b3 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/CNativePlugin.java
+++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/internal/core/natives/CNativePlugin.java
@@ -14,7 +14,13 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.natives;
+import org.eclipse.cdt.utils.WindowsRegistry;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
@@ -92,4 +98,35 @@ public class CNativePlugin extends Plugin {
getDefault().getLog().log(status);
}
+ /**
+ * Get the WindowsRegistry contributed class for the platform.
+ */
+ public WindowsRegistry getWindowsRegistry() throws CoreException {
+ IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, "WindowsRegistry"); //$NON-NLS-1$
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ IConfigurationElement defaultContributor = null;
+ for (IExtension extension2 : extensions) {
+ IConfigurationElement[] configElements = extension2.getConfigurationElements();
+ for (IConfigurationElement configElement : configElements) {
+ if (configElement.getName().equals("windowsRegistry")) { //$NON-NLS-1$
+ String platform = configElement.getAttribute("platform"); //$NON-NLS-1$
+ if (platform == null) { // first contributor found with
+ // not platform will be default.
+ if (defaultContributor == null) {
+ defaultContributor = configElement;
+ }
+ } else if (platform.equals(Platform.getOS())) {
+ // found explicit contributor for this platform.
+ return (WindowsRegistry) configElement.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ if (defaultContributor != null) {
+ return (WindowsRegistry) defaultContributor.createExecutableExtension("class"); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
}
diff --git a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java
index 31d31cd6d93..f2054512232 100644
--- a/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java
+++ b/core/org.eclipse.cdt.core.native/src/org/eclipse/cdt/utils/WindowsRegistry.java
@@ -11,38 +11,31 @@
* Contributors:
* QNX Software Systems - initial API and implementation
*******************************************************************************/
-/**
- *
- */
package org.eclipse.cdt.utils;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.cdt.internal.core.natives.CNativePlugin;
+import org.eclipse.core.runtime.CoreException;
/**
* @author DSchaefer
* @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
*/
-public class WindowsRegistry {
+public abstract class WindowsRegistry {
- private static boolean failed = false;
private static WindowsRegistry registry;
- private WindowsRegistry() {
+ /**
+ * @since 6.0
+ */
+ protected WindowsRegistry() {
}
public static WindowsRegistry getRegistry() {
- if (registry == null && !failed) {
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- try {
- System.loadLibrary("winreg"); //$NON-NLS-1$
- registry = new WindowsRegistry();
- } catch (UnsatisfiedLinkError e) {
- failed = true;
- return null;
- }
- } else
- failed = true;
+ if (registry == null) {
+ try {
+ registry = CNativePlugin.getDefault().getWindowsRegistry();
+ } catch (CoreException e) {
+ }
}
return registry;
@@ -56,7 +49,7 @@ public class WindowsRegistry {
* @param name name of the registry value
* @return registry value or null if not found
*/
- public native String getLocalMachineValue(String subkey, String name);
+ public abstract String getLocalMachineValue(String subkey, String name);
/**
* Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
@@ -68,7 +61,7 @@ public class WindowsRegistry {
* @param index index to the subkey's array of values, starting from 0.
* @return name of registry value or null if not found
*/
- public native String getLocalMachineValueName(String subkey, int index);
+ public abstract String getLocalMachineValueName(String subkey, int index);
/**
* Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
@@ -80,7 +73,7 @@ public class WindowsRegistry {
* @param index index to the subkey's array of values, starting from 0.
* @return name of registry value or null if not found
*/
- public native String getLocalMachineKeyName(String subkey, int index);
+ public abstract String getLocalMachineKeyName(String subkey, int index);
/**
* Gets the registry value for the subkey of HKEY_CURRENT_USER with the
@@ -90,7 +83,7 @@ public class WindowsRegistry {
* @param name name of the registry value
* @return registry value or null if not found
*/
- public native String getCurrentUserValue(String subkey, String name);
+ public abstract String getCurrentUserValue(String subkey, String name);
/**
* Given a subkey of HKEY_CURRENT_USER, and an index (starting from 0)
@@ -102,7 +95,7 @@ public class WindowsRegistry {
* @param index index to the subkey's array of values, starting from 0.
* @return name of registry value or null if not found
*/
- public native String getCurrentUserValueName(String subkey, int index);
+ public abstract String getCurrentUserValueName(String subkey, int index);
/**
* Given a subkey of HKEY_CURRENT_USER, and an index (starting from 0)
@@ -114,6 +107,5 @@ public class WindowsRegistry {
* @param index index to the subkey's array of values, starting from 0.
* @return name of registry value or null if not found
*/
- public native String getCurrentUserKeyName(String subkey, int index);
-
+ public abstract String getCurrentUserKeyName(String subkey, int index);
}
diff --git a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/winreg.dll b/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/winreg.dll
deleted file mode 100755
index a8e74e65993..00000000000
--- a/core/org.eclipse.cdt.core.win32.x86_64/os/win32/x86_64/winreg.dll
+++ /dev/null
Binary files differ
diff --git a/core/org.eclipse.cdt.core.win32/fragment.xml b/core/org.eclipse.cdt.core.win32/fragment.xml
index f06998bc1fd..a1807605b60 100644
--- a/core/org.eclipse.cdt.core.win32/fragment.xml
+++ b/core/org.eclipse.cdt.core.win32/fragment.xml
@@ -9,4 +9,11 @@
class="org.eclipse.cdt.internal.core.win32.ProcessList">
</processList>
</extension>
+ <extension
+ point="org.eclipse.cdt.core.native.WindowsRegistry">
+ <windowsRegistry
+ class="org.eclipse.cdt.internal.core.win32.WindowsRegistryImpl"
+ platform="win32">
+ </windowsRegistry>
+ </extension>
</fragment>
diff --git a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk b/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk
index 1d8d016f8c3..aeb5c889190 100644
--- a/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk
+++ b/core/org.eclipse.cdt.core.win32/library/Makefile_x86_64.mk
@@ -30,9 +30,6 @@ INSTALL_DIR = ..\..\org.eclipse.cdt.core.$(OS).$(ARCH)\os\$(OS)\$(ARCH)
DLL_SPAWNER = spawner.dll
OBJS_SPAWNER=StdAfx.obj Win32ProcessEx.obj iostream.obj raise.obj spawner.obj
-DLL_WINREG = winreg.dll
-OBJS_WINREG=winreg/winreg.obj
-
EXE_STARTER = starter.exe
OBJS_STARTER=starter/starter.obj
@@ -45,22 +42,19 @@ OBJS_STARTER=starter/starter.obj
spawner: $(OBJS_SPAWNER)
link /dll /nologo /out:$(DLL_SPAWNER) $(OBJS_SPAWNER) User32.lib
-winreg: $(OBJS_WINREG)
- link /dll /nologo /out:$(DLL_WINREG) $(OBJS_WINREG) Advapi32.lib
-
starter: $(OBJS_STARTER)
link /nologo /out:$(EXE_STARTER) $(OBJS_STARTER) Psapi.Lib Shell32.lib
-
-all: spawner winreg starter
+
+all: spawner starter
clean:
- del *.obj *.lib *.exp *.exe *.dll winreg\*.obj starter\*.obj
+ del *.obj *.lib *.exp *.exe *.dll starter\*.obj
rebuild: clean all
install: all
copy *.dll $(INSTALL_DIR)
copy *.exe $(INSTALL_DIR)
-
+
uninstall:
del $(INSTALL_DIR)\*.dll $(INSTALL_DIR)\*.exe
diff --git a/core/org.eclipse.cdt.core.win32/library/cdt-win32.sln b/core/org.eclipse.cdt.core.win32/library/cdt-win32.sln
deleted file mode 100644
index 01d10abe31e..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/cdt-win32.sln
+++ /dev/null
@@ -1,33 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winreg", "winreg\winreg.vcxproj", "{4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Mixed Platforms = Debug|Mixed Platforms
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Mixed Platforms = Release|Mixed Platforms
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Mixed Platforms.Build.0 = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Win32.ActiveCfg = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|Win32.Build.0 = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Debug|x64.ActiveCfg = Debug|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Mixed Platforms.ActiveCfg = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Mixed Platforms.Build.0 = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Win32.ActiveCfg = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|Win32.Build.0 = Release|Win32
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|x64.ActiveCfg = Release|x64
- {4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/.gitignore b/core/org.eclipse.cdt.core.win32/library/winreg/.gitignore
deleted file mode 100644
index 7d9b212a579..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/winreg.tlog/
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp
deleted file mode 100644
index 1464319edac..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/dllmain.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#include "stdafx.h"
-
-BOOL APIENTRY DllMain( HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
-{
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
-}
-
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp
deleted file mode 100644
index 4033266f9a1..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h b/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h
deleted file mode 100644
index 506fec98540..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/stdafx.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#pragma once
-
-#include "targetver.h"
-
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-// Windows Header Files:
-#include <windows.h>
-#include <jni.h>
-
-
-
-// TODO: reference additional headers your program requires here
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h b/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h
deleted file mode 100644
index 080979afe73..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/targetver.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#pragma once
-
-// Including SDKDDKVer.h defines the highest available Windows platform.
-
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-
-#include <SDKDDKVer.h>
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp
deleted file mode 100644
index 25a77124217..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-#include "stdafx.h"
-
-static jstring getValue(JNIEnv * env, HKEY key, jstring subkey, jstring name) {
- const jchar * csubkey = env->GetStringChars(subkey, NULL);
- const jchar * cname = env->GetStringChars(name, NULL);
- jstring result = NULL;
-
- HKEY skey;
- LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey);
- if (rc == ERROR_SUCCESS) {
- DWORD type;
- wchar_t buffer[256];
- DWORD len = sizeof(buffer);
- rc = RegQueryValueEx(skey, (const wchar_t *)cname, NULL, &type, (BYTE *)&buffer, &len);
- if (rc == ERROR_SUCCESS) {
- result = env->NewString((jchar *) buffer, (jsize) wcslen(buffer));
- }
- RegCloseKey(skey);
- }
-
- env->ReleaseStringChars(subkey, csubkey);
- env->ReleaseStringChars(name, cname);
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValue(
-JNIEnv * env, jobject obj, jstring subkey, jstring name)
-{
- return getValue(env, HKEY_LOCAL_MACHINE, subkey, name);
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValue(
-JNIEnv * env, jobject obj, jstring subkey, jstring name)
-{
- return getValue(env, HKEY_CURRENT_USER, subkey, name);
-}
-
-/*
-* Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0)
-* to the key's array of values, return the name of the indexed value.
-* The return value is null on any error or when the index is invalid.
-*/
-
-static jstring getValueName(JNIEnv * env, HKEY key, jstring subkey, jint index) {
- const jchar * csubkey = env->GetStringChars(subkey, NULL);
- jstring result = NULL;
-
- HKEY skey;
- LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey);
- if (rc != ERROR_SUCCESS)
- return NULL;
-
- wchar_t valueName[256];
- DWORD nameSize = sizeof(valueName) + 2;
-
- rc = RegEnumValue(skey, index,
- valueName, // UNICODE string
- &nameSize,
- NULL, NULL,
- NULL, // data string
- NULL); // size in BYTE of data.
-
- if (rc == ERROR_SUCCESS)
- {
- result = env->NewString((jchar *)valueName, nameSize);
- }
-
- RegCloseKey(skey);
-
- env->ReleaseStringChars(subkey, csubkey);
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineValueName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getValueName(env, HKEY_LOCAL_MACHINE, subkey, index);
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserValueName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getValueName(env, HKEY_CURRENT_USER, subkey, index);
-}
-
-/*
-* Given a subkey (string) under HKEY_LOCAL_MACHINE, and an index (starting from 0)
-* to the key's array of keys, return the name of the indexed key.
-* The return value is null on any error or when the index is invalid.
-*/
-
-static jstring getKeyName(JNIEnv * env, HKEY key, jstring subkey, jint index) {
- const jchar * csubkey = env->GetStringChars(subkey, NULL);
- jstring result = NULL;
-
- HKEY skey;
- LONG rc = RegOpenKeyEx(key, (const wchar_t *)csubkey, 0, KEY_READ, &skey);
- if (rc != ERROR_SUCCESS)
- return NULL;
-
- wchar_t keyName[256];
- DWORD nameSize = sizeof(keyName) + 2;
-
- rc = RegEnumKeyEx(skey, index,
- keyName, // UNICODE string
- &nameSize,
- NULL, NULL,
- NULL,
- NULL); // size in BYTE of data.
-
- if (rc == ERROR_SUCCESS)
- {
- result = env->NewString((jchar *)keyName, nameSize);
- }
-
- RegCloseKey(skey);
-
- env->ReleaseStringChars(subkey, csubkey);
-
- return result;
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getLocalMachineKeyName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getKeyName(env, HKEY_LOCAL_MACHINE, subkey, index);
-}
-
-extern "C"
-JNIEXPORT jstring JNICALL Java_org_eclipse_cdt_utils_WindowsRegistry_getCurrentUserKeyName(
-JNIEnv * env, jobject obj, jstring subkey, jint index)
-{
- return getKeyName(env, HKEY_CURRENT_USER, subkey, index);
-}
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj
deleted file mode 100644
index 0c82aec90f9..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj
+++ /dev/null
@@ -1,175 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{4CA57EA3-42F2-4CC1-8E95-5C707A8E7363}</ProjectGuid>
- <Keyword>Win32Proj</Keyword>
- <RootNamespace>winreg</RootNamespace>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
- <WholeProgramOptimization>true</WholeProgramOptimization>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <LinkIncremental>true</LinkIncremental>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)..\..\org.eclipse.cdt.core.win32.x86\os\win32\x86\</OutDir>
- <IntDir />
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <LinkIncremental>false</LinkIncremental>
- <OutDir>$(SolutionDir)..\..\org.eclipse.cdt.core.win32.x86_64\os\win32\x86_64\</OutDir>
- <IntDir />
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <WarningLevel>Level3</WarningLevel>
- <Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include;C:\Program Files\Java\jdk1.8.0_31\include\win32</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <WarningLevel>Level3</WarningLevel>
- <PrecompiledHeader>Use</PrecompiledHeader>
- <Optimization>MaxSpeed</Optimization>
- <FunctionLevelLinking>true</FunctionLevelLinking>
- <IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WINREG_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\Java\jdk1.8.0_31\include;C:\Program Files\Java\jdk1.8.0_31\include\win32</AdditionalIncludeDirectories>
- <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
- </ClCompile>
- <Link>
- <SubSystem>Windows</SubSystem>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <EnableCOMDATFolding>true</EnableCOMDATFolding>
- <OptimizeReferences>true</OptimizeReferences>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="targetver.h" />
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="dllmain.cpp">
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- </PrecompiledHeader>
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
- <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- </PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="winreg.cpp" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters b/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters
deleted file mode 100644
index afa4a0f572f..00000000000
--- a/core/org.eclipse.cdt.core.win32/library/winreg/winreg.vcxproj.filters
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
- <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
- <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="targetver.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="winreg.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="dllmain.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java
new file mode 100644
index 00000000000..dcb48a8fc7b
--- /dev/null
+++ b/core/org.eclipse.cdt.core.win32/src/org/eclipse/cdt/internal/core/win32/WindowsRegistryImpl.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2020 Torbjörn Svensson
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Torbjörn Svensson - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.core.win32;
+
+import org.eclipse.cdt.internal.core.natives.CNativePlugin;
+import org.eclipse.cdt.utils.WindowsRegistry;
+
+import com.sun.jna.Native;
+import com.sun.jna.platform.win32.Advapi32;
+import com.sun.jna.platform.win32.Advapi32Util;
+import com.sun.jna.platform.win32.Advapi32Util.EnumKey;
+import com.sun.jna.platform.win32.W32Errors;
+import com.sun.jna.platform.win32.Win32Exception;
+import com.sun.jna.platform.win32.WinNT;
+import com.sun.jna.platform.win32.WinReg;
+import com.sun.jna.platform.win32.WinReg.HKEY;
+import com.sun.jna.platform.win32.WinReg.HKEYByReference;
+import com.sun.jna.ptr.IntByReference;
+
+/**
+ * @author Torbjörn Svensson
+ */
+public class WindowsRegistryImpl extends WindowsRegistry {
+
+ @Override
+ public String getLocalMachineValue(String subkey, String name) {
+ return getValue(WinReg.HKEY_LOCAL_MACHINE, subkey, name);
+ }
+
+ @Override
+ public String getLocalMachineValueName(String subkey, int index) {
+ return getValueName(WinReg.HKEY_LOCAL_MACHINE, subkey, index);
+ }
+
+ @Override
+ public String getLocalMachineKeyName(String subkey, int index) {
+ return getKeyName(WinReg.HKEY_LOCAL_MACHINE, subkey, index);
+ }
+
+ @Override
+ public String getCurrentUserValue(String subkey, String name) {
+ return getValue(WinReg.HKEY_CURRENT_USER, subkey, name);
+ }
+
+ @Override
+ public String getCurrentUserValueName(String subkey, int index) {
+ return getValueName(WinReg.HKEY_CURRENT_USER, subkey, index);
+ }
+
+ @Override
+ public String getCurrentUserKeyName(String subkey, int index) {
+ return getKeyName(WinReg.HKEY_CURRENT_USER, subkey, index);
+ }
+
+ private String getValue(HKEY key, String subkey, String name) {
+ try {
+ return Advapi32Util.registryGetStringValue(key, subkey, name);
+ } catch (Win32Exception e) {
+ CNativePlugin.log(String.format("Unable to get value for %s in %s", name, subkey), e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ private String getKeyName(HKEY key, String subkey, int index) {
+ try {
+ HKEYByReference phkKey = Advapi32Util.registryGetKey(key, subkey, WinNT.KEY_READ);
+ try {
+ EnumKey enumKey = Advapi32Util.registryRegEnumKey(phkKey.getValue(), index);
+ return Native.toString(enumKey.lpName);
+ } finally {
+ Advapi32Util.registryCloseKey(phkKey.getValue());
+ }
+ } catch (Win32Exception e) {
+ CNativePlugin.log(String.format("Unable to get keyname for %s at index %d", subkey, index), e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ private String getValueName(HKEY key, String subkey, int index) {
+ try {
+ HKEYByReference phkKey = Advapi32Util.registryGetKey(key, subkey, WinNT.KEY_READ);
+ try {
+ 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);
+
+ if (rc != W32Errors.ERROR_SUCCESS) {
+ throw new Win32Exception(rc);
+ }
+
+ return Native.toString(lpValueName);
+ } finally {
+ Advapi32Util.registryCloseKey(phkKey.getValue());
+ }
+ } catch (Win32Exception e) {
+ CNativePlugin.log(String.format("Unable to get valuename for %s at index %d", subkey, index), e); //$NON-NLS-1$
+ return null;
+ }
+ }
+}

Back to the top