Date: Wed, 19 Jun 2024 12:37:43 +0200
Subject: [PATCH 46/78] adjust to changed API
---
src/main/java/module-info.java | 4 ++--
.../ExplorerSidebarService.java | 18 +++++++++---------
...tomator.integrations.sidebar.SidebarService | 1 +
.../ExplorerSidebarServiceIT.java | 6 ++++--
4 files changed, 16 insertions(+), 13 deletions(-)
rename src/main/java/org/cryptomator/windows/{filemanagersidebar => sidebar}/ExplorerSidebarService.java (91%)
create mode 100644 src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index ce2e1b8..7bed1f5 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,10 +1,10 @@
import org.cryptomator.integrations.autostart.AutoStartProvider;
-import org.cryptomator.integrations.filemanagersidebar.SidebarService;
+import org.cryptomator.integrations.sidebar.SidebarService;
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
import org.cryptomator.integrations.revealpath.RevealPathService;
import org.cryptomator.integrations.uiappearance.UiAppearanceProvider;
import org.cryptomator.windows.autostart.WindowsAutoStart;
-import org.cryptomator.windows.filemanagersidebar.ExplorerSidebarService;
+import org.cryptomator.windows.sidebar.ExplorerSidebarService;
import org.cryptomator.windows.keychain.WindowsProtectedKeychainAccess;
import org.cryptomator.windows.revealpath.ExplorerRevealPathService;
import org.cryptomator.windows.uiappearance.WinUiAppearanceProvider;
diff --git a/src/main/java/org/cryptomator/windows/filemanagersidebar/ExplorerSidebarService.java b/src/main/java/org/cryptomator/windows/sidebar/ExplorerSidebarService.java
similarity index 91%
rename from src/main/java/org/cryptomator/windows/filemanagersidebar/ExplorerSidebarService.java
rename to src/main/java/org/cryptomator/windows/sidebar/ExplorerSidebarService.java
index ed738e2..d7224ec 100644
--- a/src/main/java/org/cryptomator/windows/filemanagersidebar/ExplorerSidebarService.java
+++ b/src/main/java/org/cryptomator/windows/sidebar/ExplorerSidebarService.java
@@ -1,9 +1,9 @@
-package org.cryptomator.windows.filemanagersidebar;
+package org.cryptomator.windows.sidebar;
import org.cryptomator.integrations.common.OperatingSystem;
import org.cryptomator.integrations.common.Priority;
-import org.cryptomator.integrations.filemanagersidebar.SidebarService;
-import org.cryptomator.integrations.filemanagersidebar.SidebarServiceException;
+import org.cryptomator.integrations.sidebar.SidebarService;
+import org.cryptomator.integrations.sidebar.SidebarServiceException;
import org.cryptomator.windows.common.RegistryKey;
import org.cryptomator.windows.common.WindowsException;
import org.cryptomator.windows.common.WindowsRegistry;
@@ -14,7 +14,7 @@
import java.util.UUID;
/**
- * Implementation of the FileManagerSidebarService for Windows Explorer
+ * Implementation of the {@link SidebarService} for Windows Explorer
*
* Based on a Microsoft docs example.
*/
@@ -94,7 +94,7 @@ public SidebarEntry add(Path target, String displayName) throws SidebarServiceEx
}
t.commit();
} catch (WindowsException e) {
- throw new RuntimeException("Adding entry to Explorer via Windows registry failed.", e);
+ throw new SidebarServiceException("Adding entry to Explorer sidebar via Windows registry failed.", e);
}
return new ExplorerSidebarEntry(clsid);
}
@@ -109,7 +109,7 @@ private ExplorerSidebarEntry(String clsid) {
}
@Override
- public synchronized void remove() {
+ public synchronized void remove() throws SidebarServiceException {
if (isClosed) {
return;
}
@@ -128,15 +128,15 @@ public synchronized void remove() {
}
//undo everything else
- try (var baseKey = t.openRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\{%s}".formatted(clsid))) {
+ try (var baseKey = t.openRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\" + clsid)) {
LOG.trace("Wiping everything under RegKey {} and key itself.", baseKey);
baseKey.deleteAllValuesAndSubtrees();
}
- t.deleteRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\{%s}".formatted(clsid), true);
+ t.deleteRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\"+clsid, true);
t.commit();
isClosed = true;
} catch (WindowsException e) {
- LOG.error("Removing explorer sidebar entry with CLSID {} failed", clsid, e);
+ throw new SidebarServiceException("Removing entry from Explorer sidebar via Windows registry failed.", e);
}
}
}
diff --git a/src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService b/src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService
new file mode 100644
index 0000000..568d8ad
--- /dev/null
+++ b/src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService
@@ -0,0 +1 @@
+org.cryptomator.windows.sidebar.ExplorerSidebarService
\ No newline at end of file
diff --git a/src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java b/src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java
index f2defc0..743a8d3 100644
--- a/src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java
+++ b/src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java
@@ -1,7 +1,8 @@
package org.cryptomator.filemanagersidebar;
-import org.cryptomator.integrations.filemanagersidebar.SidebarServiceException;
-import org.cryptomator.windows.filemanagersidebar.ExplorerSidebarService;
+import org.cryptomator.integrations.sidebar.SidebarServiceException;
+import org.cryptomator.windows.sidebar.ExplorerSidebarService;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -18,6 +19,7 @@ public class ExplorerSidebarServiceIT {
@Test
@DisplayName("Integrates a temp dir for 20s into the file explorer sidebar")
+ @Disabled
public void testExplorerSidebarIntegration() throws IOException, InterruptedException, SidebarServiceException {
var p = base.resolve("integration-win-testVault");
Files.createDirectory(p);
From 5a05857371112c7c5af1a59c723abfc006afffb3 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Thu, 20 Jun 2024 17:37:06 +0200
Subject: [PATCH 47/78] renaming to quick access
---
pom.xml | 4 +--
src/main/java/module-info.java | 6 ++--
.../ExplorerQuickAccessService.java} | 32 +++++++++----------
...ntegrations.quickaccess.QuickAccessService | 1 +
...omator.integrations.sidebar.SidebarService | 1 -
.../ExplorerQuickAccessServiceIT.java} | 11 +++----
6 files changed, 27 insertions(+), 28 deletions(-)
rename src/main/java/org/cryptomator/windows/{sidebar/ExplorerSidebarService.java => quickaccess/ExplorerQuickAccessService.java} (84%)
create mode 100644 src/main/resources/META-INF/services/org.cryptomator.integrations.quickaccess.QuickAccessService
delete mode 100644 src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService
rename src/test/java/org/cryptomator/{filemanagersidebar/ExplorerSidebarServiceIT.java => windows/quickaccess/ExplorerQuickAccessServiceIT.java} (68%)
diff --git a/pom.xml b/pom.xml
index 3a21542..b6c06aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
org.cryptomator
integrations-win
- 1.3.0-sidebar
+ 1.3.0-quickaccess
Cryptomator Integrations for Windows
Provides optional Windows services used by Cryptomator
@@ -37,7 +37,7 @@
22
- 1.4.0-sidebar
+ 1.4.0-quickaccess
2.0.13
2.17.1
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index 7bed1f5..e30da94 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -1,11 +1,11 @@
import org.cryptomator.integrations.autostart.AutoStartProvider;
-import org.cryptomator.integrations.sidebar.SidebarService;
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
+import org.cryptomator.integrations.quickaccess.QuickAccessService;
import org.cryptomator.integrations.revealpath.RevealPathService;
import org.cryptomator.integrations.uiappearance.UiAppearanceProvider;
import org.cryptomator.windows.autostart.WindowsAutoStart;
-import org.cryptomator.windows.sidebar.ExplorerSidebarService;
import org.cryptomator.windows.keychain.WindowsProtectedKeychainAccess;
+import org.cryptomator.windows.quickaccess.ExplorerQuickAccessService;
import org.cryptomator.windows.revealpath.ExplorerRevealPathService;
import org.cryptomator.windows.uiappearance.WinUiAppearanceProvider;
@@ -21,5 +21,5 @@
provides KeychainAccessProvider with WindowsProtectedKeychainAccess;
provides UiAppearanceProvider with WinUiAppearanceProvider;
provides RevealPathService with ExplorerRevealPathService;
- provides SidebarService with ExplorerSidebarService;
+ provides QuickAccessService with ExplorerQuickAccessService;
}
\ No newline at end of file
diff --git a/src/main/java/org/cryptomator/windows/sidebar/ExplorerSidebarService.java b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
similarity index 84%
rename from src/main/java/org/cryptomator/windows/sidebar/ExplorerSidebarService.java
rename to src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
index d7224ec..8d86281 100644
--- a/src/main/java/org/cryptomator/windows/sidebar/ExplorerSidebarService.java
+++ b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
@@ -1,9 +1,9 @@
-package org.cryptomator.windows.sidebar;
+package org.cryptomator.windows.quickaccess;
import org.cryptomator.integrations.common.OperatingSystem;
import org.cryptomator.integrations.common.Priority;
-import org.cryptomator.integrations.sidebar.SidebarService;
-import org.cryptomator.integrations.sidebar.SidebarServiceException;
+import org.cryptomator.integrations.quickaccess.QuickAccessService;
+import org.cryptomator.integrations.quickaccess.QuickAccessServiceException;
import org.cryptomator.windows.common.RegistryKey;
import org.cryptomator.windows.common.WindowsException;
import org.cryptomator.windows.common.WindowsRegistry;
@@ -14,18 +14,18 @@
import java.util.UUID;
/**
- * Implementation of the {@link SidebarService} for Windows Explorer
+ * Implementation of the {@link QuickAccessService} for Windows Explorer
*
* Based on a Microsoft docs example.
*/
@Priority(100)
@OperatingSystem(OperatingSystem.Value.WINDOWS)
-public class ExplorerSidebarService implements SidebarService {
+public class ExplorerQuickAccessService implements QuickAccessService {
- private static final Logger LOG = LoggerFactory.getLogger(ExplorerSidebarService.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ExplorerQuickAccessService.class);
@Override
- public SidebarEntry add(Path target, String displayName) throws SidebarServiceException {
+ public QuickAccessEntry add(Path target, String displayName) throws QuickAccessServiceException {
if (displayName == null) {
throw new IllegalArgumentException("Parameter 'displayname' must not be null.");
}
@@ -34,7 +34,7 @@ public SidebarEntry add(Path target, String displayName) throws SidebarServiceEx
}
var entryName = "Vault - " + displayName;
var clsid = "{" + UUID.randomUUID() + "}";
- LOG.debug("Creating sidebar entry with CLSID {}", clsid);
+ LOG.debug("Creating navigation pane entry with CLSID {}", clsid);
//1. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /ve /t REG_SZ /d "MyCloudStorageApp" /f
try (var t = WindowsRegistry.startTransaction()) {
try (var baseKey = t.createRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\" + clsid, true)) {
@@ -94,27 +94,27 @@ public SidebarEntry add(Path target, String displayName) throws SidebarServiceEx
}
t.commit();
} catch (WindowsException e) {
- throw new SidebarServiceException("Adding entry to Explorer sidebar via Windows registry failed.", e);
+ throw new QuickAccessServiceException("Adding entry to Explorer navigation pane via Windows registry failed.", e);
}
- return new ExplorerSidebarEntry(clsid);
+ return new ExplorerQuickAccessEntry(clsid);
}
- static class ExplorerSidebarEntry implements SidebarEntry {
+ static class ExplorerQuickAccessEntry implements QuickAccessService.QuickAccessEntry {
private final String clsid;
private volatile boolean isClosed = false;
- private ExplorerSidebarEntry(String clsid) {
+ private ExplorerQuickAccessEntry(String clsid) {
this.clsid = clsid;
}
@Override
- public synchronized void remove() throws SidebarServiceException {
+ public synchronized void remove() throws QuickAccessServiceException {
if (isClosed) {
return;
}
- LOG.debug("Removing sidebar entry with CLSID {}", clsid);
+ LOG.debug("Removing navigation pane entry with CLSID {}", clsid);
try (var t = WindowsRegistry.startTransaction()) {
//undo step 11.
var nameSpaceSubkey = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\" + clsid;
@@ -132,11 +132,11 @@ public synchronized void remove() throws SidebarServiceException {
LOG.trace("Wiping everything under RegKey {} and key itself.", baseKey);
baseKey.deleteAllValuesAndSubtrees();
}
- t.deleteRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\"+clsid, true);
+ t.deleteRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\" + clsid, true);
t.commit();
isClosed = true;
} catch (WindowsException e) {
- throw new SidebarServiceException("Removing entry from Explorer sidebar via Windows registry failed.", e);
+ throw new QuickAccessServiceException("Removing entry from Explorer navigation pane via Windows registry failed.", e);
}
}
}
diff --git a/src/main/resources/META-INF/services/org.cryptomator.integrations.quickaccess.QuickAccessService b/src/main/resources/META-INF/services/org.cryptomator.integrations.quickaccess.QuickAccessService
new file mode 100644
index 0000000..512fc9f
--- /dev/null
+++ b/src/main/resources/META-INF/services/org.cryptomator.integrations.quickaccess.QuickAccessService
@@ -0,0 +1 @@
+org.cryptomator.windows.quickaccess.ExplorerQuickAccessService
\ No newline at end of file
diff --git a/src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService b/src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService
deleted file mode 100644
index 568d8ad..0000000
--- a/src/main/resources/META-INF/services/org.cryptomator.integrations.sidebar.SidebarService
+++ /dev/null
@@ -1 +0,0 @@
-org.cryptomator.windows.sidebar.ExplorerSidebarService
\ No newline at end of file
diff --git a/src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java b/src/test/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessServiceIT.java
similarity index 68%
rename from src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java
rename to src/test/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessServiceIT.java
index 743a8d3..5db6c01 100644
--- a/src/test/java/org/cryptomator/filemanagersidebar/ExplorerSidebarServiceIT.java
+++ b/src/test/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessServiceIT.java
@@ -1,7 +1,6 @@
-package org.cryptomator.filemanagersidebar;
+package org.cryptomator.windows.quickaccess;
-import org.cryptomator.integrations.sidebar.SidebarServiceException;
-import org.cryptomator.windows.sidebar.ExplorerSidebarService;
+import org.cryptomator.integrations.quickaccess.QuickAccessServiceException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -12,7 +11,7 @@
import java.nio.file.Path;
import java.time.Duration;
-public class ExplorerSidebarServiceIT {
+public class ExplorerQuickAccessServiceIT {
@TempDir
Path base;
@@ -20,13 +19,13 @@ public class ExplorerSidebarServiceIT {
@Test
@DisplayName("Integrates a temp dir for 20s into the file explorer sidebar")
@Disabled
- public void testExplorerSidebarIntegration() throws IOException, InterruptedException, SidebarServiceException {
+ public void testExplorerSidebarIntegration() throws IOException, InterruptedException, QuickAccessServiceException {
var p = base.resolve("integration-win-testVault");
Files.createDirectory(p);
Files.createFile(p.resolve("firstLevel.file"));
var sub = Files.createDirectory(p.resolve("subdir"));
Files.createFile(sub.resolve("secondLevel.file"));
- var entry = new ExplorerSidebarService().add(p, "integration-win-tempDir");
+ var entry = new ExplorerQuickAccessService().add(p, "integration-win-tempDir");
Thread.sleep(Duration.ofSeconds(20));
From 88907902b250bfe3a718b25888644dd7263f21e9 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Thu, 27 Jun 2024 13:16:21 +0200
Subject: [PATCH 48/78] use beta1 of integrations-api
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index b6c06aa..1a1a203 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,7 +37,7 @@
22
- 1.4.0-quickaccess
+ 1.4.0-beta1
2.0.13
2.17.1
From b4d7be3377c18bbfe6e70d520644817cbca82a2f Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Thu, 27 Jun 2024 13:26:41 +0200
Subject: [PATCH 49/78] reset version to prepare PR
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 1a1a203..29d49fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
org.cryptomator
integrations-win
- 1.3.0-quickaccess
+ 1.3.0-SNAPSHOT
Cryptomator Integrations for Windows
Provides optional Windows services used by Cryptomator
From 4aa601ead2769febf1db9beb2b7925ac84d8c0da Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Thu, 27 Jun 2024 13:32:21 +0200
Subject: [PATCH 50/78] migrate ci to use JDK 22
---
.github/workflows/build.yml | 2 +-
.github/workflows/codeql-analysis.yml | 2 +-
.github/workflows/dependency-check.yml | 2 +-
.github/workflows/publish-central.yml | 2 +-
.github/workflows/publish-github.yml | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a85c28c..9cc3824 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,7 +18,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
- java-version: 17
+ java-version: 22
cache: 'maven'
- name: Ensure to use tagged version
if: startsWith(github.ref, 'refs/tags/')
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index cd30ed4..e786bc1 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -25,7 +25,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
- java-version: 17
+ java-version: 22
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml
index d0c8357..ca8baa1 100644
--- a/.github/workflows/dependency-check.yml
+++ b/.github/workflows/dependency-check.yml
@@ -14,7 +14,7 @@ jobs:
with:
runner-os: 'windows-latest'
java-distribution: 'temurin'
- java-version: 17
+ java-version: 22
secrets:
nvd-api-key: ${{ secrets.NVD_API_KEY }}
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml
index 8f4b440..dc96c04 100644
--- a/.github/workflows/publish-central.yml
+++ b/.github/workflows/publish-central.yml
@@ -21,7 +21,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
- java-version: 17
+ java-version: 22
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml
index 9c2d18d..2c9c5cf 100644
--- a/.github/workflows/publish-github.yml
+++ b/.github/workflows/publish-github.yml
@@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
- java-version: 17
+ java-version: 22
cache: 'maven'
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
From 6f490e834f1730848921bc1832734f13f95207cd Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Thu, 27 Jun 2024 16:37:03 +0200
Subject: [PATCH 51/78] use icon from executable if present, otherwise default
to folder icon
---
.../windows/quickaccess/ExplorerQuickAccessService.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
index 8d86281..da509d0 100644
--- a/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
+++ b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
@@ -41,8 +41,14 @@ public QuickAccessEntry add(Path target, String displayName) throws QuickAccessS
baseKey.setStringValue("", entryName, false);
//2. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\imageres.dll,-1043 /f
+ //TODO: should this be customizable?
try (var iconKey = t.createRegKey(baseKey, "DefaultIcon", true)) {
- iconKey.setStringValue("", "C:\\Program Files\\Cryptomator\\Cryptomator.exe", false);
+ var exePath = ProcessHandle.current().info().command();
+ if(exePath.isPresent()) {
+ iconKey.setStringValue("", exePath.get(), false);
+ } else {
+ iconKey.setStringValue("", "%SystemRoot%\\system32\\shell32.dll,4", true); //the regular folder icon
+ }
}
//3. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f
From 0ba6bd7f6a50d87a330c867e576043dbf28c2e93 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Mon, 1 Jul 2024 16:28:46 +0200
Subject: [PATCH 52/78] Apply code review notes
Co-authored-by: Sebastian Stenzel
---
README.md | 2 +-
pom.xml | 3 --
.../ExplorerQuickAccessService.java | 28 +++++++++----------
3 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
index fd40c21..5bd462d 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ This project uses the following JVM properties:
This project uses JNI, hence you'll nedd Java as well as GCC build tools:
-* JDK 17
+* JDK 22
* Maven
* MinGW GCC compiler (`choco install mingw --version=10.2.0`)
* Make (`choco install make`)
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 29d49fc..e4c667f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -399,9 +399,6 @@
jextract
-
- false
-
diff --git a/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
index da509d0..de589b5 100644
--- a/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
+++ b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
@@ -16,7 +16,7 @@
/**
* Implementation of the {@link QuickAccessService} for Windows Explorer
*
- * Based on a Microsoft docs example.
+ * Uses shell namespace extensions and based on a Microsoft docs example.
*/
@Priority(100)
@OperatingSystem(OperatingSystem.Value.WINDOWS)
@@ -35,65 +35,65 @@ public QuickAccessEntry add(Path target, String displayName) throws QuickAccessS
var entryName = "Vault - " + displayName;
var clsid = "{" + UUID.randomUUID() + "}";
LOG.debug("Creating navigation pane entry with CLSID {}", clsid);
- //1. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /ve /t REG_SZ /d "MyCloudStorageApp" /f
+ //1. Creates the shell extension and names it
try (var t = WindowsRegistry.startTransaction()) {
try (var baseKey = t.createRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\" + clsid, true)) {
baseKey.setStringValue("", entryName, false);
- //2. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\DefaultIcon /ve /t REG_EXPAND_SZ /d %%SystemRoot%%\system32\imageres.dll,-1043 /f
+ //2. Set icon
//TODO: should this be customizable?
try (var iconKey = t.createRegKey(baseKey, "DefaultIcon", true)) {
var exePath = ProcessHandle.current().info().command();
- if(exePath.isPresent()) {
+ if (exePath.isPresent()) {
iconKey.setStringValue("", exePath.get(), false);
} else {
iconKey.setStringValue("", "%SystemRoot%\\system32\\shell32.dll,4", true); //the regular folder icon
}
}
- //3. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /v System.IsPinnedToNameSpaceTree /t REG_DWORD /d 0x1 /f
+ //3. Pin the entry to navigation pane
baseKey.setDwordValue("System.IsPinnedToNameSpaceTree", 0x1);
- //4. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /v SortOrderIndex /t REG_DWORD /d 0x42 /f
+ //4. Place it in the top section of the navigation pane
baseKey.setDwordValue("SortOrderIndex", 0x41);
- //5. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\InProcServer32 /ve /t REG_EXPAND_SZ /d /f
+ //5. Regsiter as a namespace extension
try (var inProcServer32Key = t.createRegKey(baseKey, "InProcServer32", true)) {
inProcServer32Key.setStringValue("", "%systemroot%\\system32\\shell32.dll", true);
}
- //6. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\Instance /v CLSID /t REG_SZ /d {0E5AAE11-A475-4c5b-AB00-C66DE400274E} /f
+ //6. This extenstion works like a folder
try (var instanceKey = t.createRegKey(baseKey, "Instance", true)) {
instanceKey.setStringValue("CLSID", "{0E5AAE11-A475-4c5b-AB00-C66DE400274E}", false);
- //7. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\Instance\InitPropertyBag /v Attributes /t REG_DWORD /d 0x411 /f
+ //7. Set directory attributes for this "folder"
// Attributes are READ_ONLY, DIRECTORY, REPARSE_POINT
try (var initPropertyBagKey = t.createRegKey(instanceKey, "InitPropertyBag", true)) {
initPropertyBagKey.setDwordValue("Attributes", 0x411);
- //8. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\Instance\InitPropertyBag /v TargetFolderPath /t REG_EXPAND_SZ /d %%USERPROFILE%%\MyCloudStorageApp /f
+ //8. Set the target folder
initPropertyBagKey.setStringValue("TargetFolderPath", target.toString(), false);
}
}
- //9. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\ShellFolder /v FolderValueFlags /t REG_DWORD /d 0x28 /f
+ //9. Pin extenstion to the File Explorer tree
try (var shellFolderKey = t.createRegKey(baseKey, "ShellFolder", true)) {
shellFolderKey.setDwordValue("FolderValueFlags", 0x28);
- //10. reg add HKCU\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3}\ShellFolder /v Attributes /t REG_DWORD /d 0xF080004D /f
+ //10. Set SFGAO attributes for the shell folder
shellFolderKey.setDwordValue("Attributes", 0xF080004D);
}
LOG.trace("Created RegKey {} and subkeys, including Values", baseKey);
}
- //11. reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /ve /t REG_SZ /d MyCloudStorageApp /f
+ //11. register extenstion in name space root
var nameSpaceSubKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\" + clsid;
try (var nameSpaceKey = t.createRegKey(RegistryKey.HKEY_CURRENT_USER, nameSpaceSubKey, true)) {
nameSpaceKey.setStringValue("", entryName, false);
LOG.trace("Created RegKey {} and setting default value", nameSpaceKey);
}
- //12. reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v {0672A6D1-A6E0-40FE-AB16-F25BADC6D9E3} /t REG_DWORD /d 0x1 /f
+ //12. Hide extension from Desktop
try (var newStartPanelKey = t.createRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel", true)) {
newStartPanelKey.setDwordValue(clsid, 0x1);
LOG.trace("Set value {} for RegKey {}", clsid, newStartPanelKey);
From d67ae9d6e242e5c76afc6a951f80357e68480103 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Mon, 1 Jul 2024 16:29:18 +0200
Subject: [PATCH 53/78] Don't allow actual closing of predefined reg keys
---
.../windows/common/RegistryKey.java | 24 +++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index 37786b9..c2884ae 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -18,10 +18,10 @@
public class RegistryKey implements AutoCloseable {
- public static final RegistryKey HKEY_CURRENT_USER = new RegistryKey(Winreg_h.HKEY_CURRENT_USER(), "HKEY_CURRENT_USER");
- public static final RegistryKey HKEY_LOCAL_MACHINE = new RegistryKey(Winreg_h.HKEY_LOCAL_MACHINE(), "HKEY_LOCAL_MACHINE");
- public static final RegistryKey HKEY_CLASSES_ROOT = new RegistryKey(Winreg_h.HKEY_CLASSES_ROOT(), "HKEY_CLASSES_ROOT");
- public static final RegistryKey HKEY_USERS = new RegistryKey(Winreg_h.HKEY_USERS(), "HKEY_USERS");
+ public static final RegistryKey HKEY_CURRENT_USER = new RegistryRoot(Winreg_h.HKEY_CURRENT_USER(), "HKEY_CURRENT_USER");
+ public static final RegistryKey HKEY_LOCAL_MACHINE = new RegistryRoot(Winreg_h.HKEY_LOCAL_MACHINE(), "HKEY_LOCAL_MACHINE");
+ public static final RegistryKey HKEY_CLASSES_ROOT = new RegistryRoot(Winreg_h.HKEY_CLASSES_ROOT(), "HKEY_CLASSES_ROOT");
+ public static final RegistryKey HKEY_USERS = new RegistryRoot(Winreg_h.HKEY_USERS(), "HKEY_USERS");
private final String path;
private MemorySegment handle;
@@ -168,4 +168,20 @@ MemorySegment getHandle() {
public String getPath() {
return path;
}
+
+
+ /**
+ * Closing predefined registry keys has undefined behaviour. Hence, we shade the super method and do nothing on close.
+ */
+ private static class RegistryRoot extends RegistryKey {
+
+ RegistryRoot(MemorySegment handle, String path) {
+ super(handle, path);
+ }
+
+ @Override
+ public void close() {
+ //no-op
+ }
+ }
}
From b2856be9ce5d4b2a3ba108ca084eab15ca4ab36c Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Mon, 1 Jul 2024 17:08:37 +0200
Subject: [PATCH 54/78] fix broken RegistryKey::getValue method
---
.../windows/common/RegistryKey.java | 77 +++++++++----------
.../windows/common/WindowsRegistry.java | 2 -
2 files changed, 38 insertions(+), 41 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index c2884ae..c59f4d0 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -17,6 +17,7 @@
import static org.cryptomator.windows.capi.winreg.Winreg_h.RRF_RT_REG_SZ;
public class RegistryKey implements AutoCloseable {
+ private static final long MAX_DATA_SIZE = (1L << 32) - 1L; //unsinged integer
public static final RegistryKey HKEY_CURRENT_USER = new RegistryRoot(Winreg_h.HKEY_CURRENT_USER(), "HKEY_CURRENT_USER");
public static final RegistryKey HKEY_LOCAL_MACHINE = new RegistryRoot(Winreg_h.HKEY_LOCAL_MACHINE(), "HKEY_LOCAL_MACHINE");
@@ -35,53 +36,51 @@ public class RegistryKey implements AutoCloseable {
//-- GetValue functions --
public String getStringValue(String name, boolean isExpandable) throws RegistryValueException {
- try (var arena = Arena.ofConfined()) {
- var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
- var data = getValue(lpValueName, isExpandable ? RRF_RT_REG_EXPAND_SZ() : RRF_RT_REG_SZ(), 256L);
- return data.getString(0, StandardCharsets.UTF_16LE);
- }
+ var data = getValue(name, isExpandable ? RRF_RT_REG_EXPAND_SZ() : RRF_RT_REG_SZ(), 256L);
+ return data.getString(0, StandardCharsets.UTF_16LE);
}
public int getDwordValue(String name) throws RegistryValueException {
- try (var arena = Arena.ofConfined()) {
- var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
- var data = getValue(lpValueName, RRF_RT_REG_DWORD(), 5L);
- return data.get(ValueLayout.JAVA_INT, 0);
- }
+ var data = getValue(name, RRF_RT_REG_DWORD(), 5L);
+ return data.get(ValueLayout.JAVA_INT, 0);
}
- private MemorySegment getValue(MemorySegment lpValueName, int dwFlags, long seed) throws RegistryValueException {
- long bufferSize = seed - 1;
+ private MemorySegment getValue(String name, int dwFlags, long initBufferSizePlus1) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
- var lpDataSize = arena.allocateFrom(ValueLayout.JAVA_INT, (int) bufferSize);
-
- try (var dataArena = Arena.ofConfined()) {
- var lpData = dataArena.allocate(bufferSize);
-
- int result = Winreg_h.RegGetValueW(handle, NULL, lpValueName, dwFlags, NULL, lpData, lpDataSize);
- if (result == ERROR_MORE_DATA()) {
- throw new BufferTooSmallException();
- } else if (result != ERROR_SUCCESS()) {
- throw new RegistryValueException("winreg_h:RegGetValue", path, lpValueName.getString(0, StandardCharsets.UTF_16LE), result);
- }
-
- var returnBuffer = Arena.ofAuto().allocate(Integer.toUnsignedLong(lpDataSize.get(ValueLayout.JAVA_INT, 0)));
- MemorySegment.copy(lpData, 0L, returnBuffer, 0L, returnBuffer.byteSize());
- return returnBuffer;
- } catch (BufferTooSmallException _) {
- if (bufferSize <= WindowsRegistry.MAX_DATA_SIZE) {
- return getValue(lpValueName, dwFlags, seed << 1);
- } else {
- throw new RuntimeException("Getting value %s for key %s failed. Maximum buffer size of %d reached.".formatted(lpValueName.getString(0, StandardCharsets.UTF_16LE), path, bufferSize));
+ var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
+ var lpDataSize = arena.allocateFrom(ValueLayout.JAVA_INT, 0);
+
+ long bufferSizePlus1 = initBufferSizePlus1;
+ do {
+ long bufferSize = bufferSizePlus1 - 1;
+
+ //for every try, free old data memory and allocate a new one doubled in size
+ try (var dataArena = Arena.ofConfined()) {
+ var lpData = dataArena.allocate(bufferSize);
+ lpDataSize.set(ValueLayout.JAVA_INT_UNALIGNED, 0, (int) bufferSize);
+
+ int result = Winreg_h.RegGetValueW(handle, NULL, lpValueName, dwFlags, NULL, lpData, lpDataSize);
+
+ if (result == ERROR_SUCCESS()) {
+ //success. Copy the data to a longer segment with auto lifecycle
+ var returnBuffer = Arena.ofAuto().allocate(Integer.toUnsignedLong(lpDataSize.get(ValueLayout.JAVA_INT, 0)));
+ MemorySegment.copy(lpData, 0L, returnBuffer, 0L, returnBuffer.byteSize());
+ return returnBuffer;
+ } else if (result == ERROR_MORE_DATA()) {
+ //increase buffer size and retry
+ if (bufferSize <= MAX_DATA_SIZE) {
+ bufferSizePlus1 = bufferSizePlus1 << 1;
+ } else {
+ throw new RuntimeException("Getting value %s for key %s failed. Maximum buffer size of %d reached.".formatted(lpValueName.getString(0, StandardCharsets.UTF_16LE), path, bufferSize));
+ }
+ } else {
+ throw new RegistryValueException("winreg_h:RegGetValue", path, lpValueName.getString(0, StandardCharsets.UTF_16LE), result);
+ }
}
- }
+ } while (true);
}
}
- private static class BufferTooSmallException extends RuntimeException {
-
- }
-
//-- SetValue functions --
public void setStringValue(String name, String data, boolean isExpandable) throws RegistryValueException {
@@ -101,8 +100,8 @@ public void setDwordValue(String name, int data) throws RegistryValueException {
}
private void setValue(MemorySegment lpValueName, MemorySegment data, int dwFlags) throws RegistryValueException {
- if (data.byteSize() > WindowsRegistry.MAX_DATA_SIZE) {
- throw new IllegalArgumentException("Data must be smaller than " + WindowsRegistry.MAX_DATA_SIZE + "bytes.");
+ if (data.byteSize() > MAX_DATA_SIZE) {
+ throw new IllegalArgumentException("Data must be smaller than " + MAX_DATA_SIZE + "bytes.");
}
int result = Winreg_h.RegSetKeyValueW(handle, NULL, lpValueName, dwFlags, data, (int) data.byteSize());
diff --git a/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java b/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
index cd3030e..a98363e 100644
--- a/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
+++ b/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
@@ -17,8 +17,6 @@
public class WindowsRegistry {
- public static final long MAX_DATA_SIZE = (1L << 32) - 1L; //unsinged integer
-
public static RegistryTransaction startTransaction() throws WindowsException {
var transactionHandle = Ktmw32_h.CreateTransaction(NULL, NULL, 0, 0, 0, 0, NULL);
if (transactionHandle.address() == INVALID_HANDLE_VALUE().address()) {
From 4c88ab1b510b82aca294861f2d252987e2e7d2e2 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Mon, 1 Jul 2024 18:05:44 +0200
Subject: [PATCH 55/78] exclude generated code from automatic review
---
.coderabbit/config.yml | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 .coderabbit/config.yml
diff --git a/.coderabbit/config.yml b/.coderabbit/config.yml
new file mode 100644
index 0000000..7ecd0c6
--- /dev/null
+++ b/.coderabbit/config.yml
@@ -0,0 +1,3 @@
+path_filters:
+ exclude:
+ - src/main/java/org/cryptomator/windows/capi/**
\ No newline at end of file
From 35fcd7716381880c1c4caeecd5fd2bae4388a2d0 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Thu, 4 Jul 2024 13:37:39 +0200
Subject: [PATCH 56/78] simplify RegistryKey::getValue function and add test to
set/get big value data
---
.../windows/common/RegistryKey.java | 71 +++++++++----------
.../windows/common/WindowsRegistryIT.java | 25 +++++++
2 files changed, 58 insertions(+), 38 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index c59f4d0..cc1546f 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -17,7 +17,8 @@
import static org.cryptomator.windows.capi.winreg.Winreg_h.RRF_RT_REG_SZ;
public class RegistryKey implements AutoCloseable {
- private static final long MAX_DATA_SIZE = (1L << 32) - 1L; //unsinged integer
+ //allocate at most 128MiB when reading from the registry to keep the library responsive
+ static final int MAX_DATA_SIZE = (1 << 27);
public static final RegistryKey HKEY_CURRENT_USER = new RegistryRoot(Winreg_h.HKEY_CURRENT_USER(), "HKEY_CURRENT_USER");
public static final RegistryKey HKEY_LOCAL_MACHINE = new RegistryRoot(Winreg_h.HKEY_LOCAL_MACHINE(), "HKEY_LOCAL_MACHINE");
@@ -36,48 +37,42 @@ public class RegistryKey implements AutoCloseable {
//-- GetValue functions --
public String getStringValue(String name, boolean isExpandable) throws RegistryValueException {
- var data = getValue(name, isExpandable ? RRF_RT_REG_EXPAND_SZ() : RRF_RT_REG_SZ(), 256L);
- return data.getString(0, StandardCharsets.UTF_16LE);
+ try (var arena = Arena.ofConfined()) {
+ var data = getValue(arena, name, isExpandable ? RRF_RT_REG_EXPAND_SZ() : RRF_RT_REG_SZ());
+ return data.getString(0, StandardCharsets.UTF_16LE);
+ }
}
public int getDwordValue(String name) throws RegistryValueException {
- var data = getValue(name, RRF_RT_REG_DWORD(), 5L);
- return data.get(ValueLayout.JAVA_INT, 0);
+ try (var arena = Arena.ofConfined()) {
+ var data = getValue(arena, name, RRF_RT_REG_DWORD());
+ return data.get(ValueLayout.JAVA_INT, 0);
+ }
}
- private MemorySegment getValue(String name, int dwFlags, long initBufferSizePlus1) throws RegistryValueException {
- try (var arena = Arena.ofConfined()) {
- var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
- var lpDataSize = arena.allocateFrom(ValueLayout.JAVA_INT, 0);
-
- long bufferSizePlus1 = initBufferSizePlus1;
- do {
- long bufferSize = bufferSizePlus1 - 1;
-
- //for every try, free old data memory and allocate a new one doubled in size
- try (var dataArena = Arena.ofConfined()) {
- var lpData = dataArena.allocate(bufferSize);
- lpDataSize.set(ValueLayout.JAVA_INT_UNALIGNED, 0, (int) bufferSize);
-
- int result = Winreg_h.RegGetValueW(handle, NULL, lpValueName, dwFlags, NULL, lpData, lpDataSize);
-
- if (result == ERROR_SUCCESS()) {
- //success. Copy the data to a longer segment with auto lifecycle
- var returnBuffer = Arena.ofAuto().allocate(Integer.toUnsignedLong(lpDataSize.get(ValueLayout.JAVA_INT, 0)));
- MemorySegment.copy(lpData, 0L, returnBuffer, 0L, returnBuffer.byteSize());
- return returnBuffer;
- } else if (result == ERROR_MORE_DATA()) {
- //increase buffer size and retry
- if (bufferSize <= MAX_DATA_SIZE) {
- bufferSizePlus1 = bufferSizePlus1 << 1;
- } else {
- throw new RuntimeException("Getting value %s for key %s failed. Maximum buffer size of %d reached.".formatted(lpValueName.getString(0, StandardCharsets.UTF_16LE), path, bufferSize));
- }
- } else {
- throw new RegistryValueException("winreg_h:RegGetValue", path, lpValueName.getString(0, StandardCharsets.UTF_16LE), result);
- }
- }
- } while (true);
+ private MemorySegment getValue(Arena arena, String name, int dwFlags) throws RegistryValueException {
+ var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
+ var lpDataSize = arena.allocateFrom(ValueLayout.JAVA_INT, 0);
+
+ int result;
+ int bufferSize = 128; //will be doubled in first iteration
+ MemorySegment lpData;
+ do {
+ bufferSize = bufferSize << 1;
+ if (bufferSize >= MAX_DATA_SIZE) {
+ throw new RuntimeException("Getting value %s for key %s failed. Maximum buffer size of %d reached.".formatted(lpValueName.getString(0, StandardCharsets.UTF_16LE), path, bufferSize));
+ }
+ lpData = arena.allocate(bufferSize);
+ lpDataSize.set(ValueLayout.JAVA_INT, 0, bufferSize);
+
+ result = Winreg_h.RegGetValueW(handle, NULL, lpValueName, dwFlags, NULL, lpData, lpDataSize);
+
+ } while (result == ERROR_MORE_DATA());
+
+ if (result == ERROR_SUCCESS()) {
+ return lpData;
+ } else {
+ throw new RegistryValueException("winreg_h:RegGetValue", path, lpValueName.getString(0, StandardCharsets.UTF_16LE), result);
}
}
diff --git a/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java b/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java
index 26e96c9..795b96c 100644
--- a/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java
+++ b/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java
@@ -230,4 +230,29 @@ public void testDeleteCommit() throws WindowsException {
});
Assertions.assertEquals(ERROR_FILE_NOT_FOUND(), regException.getSystemErrorCode());
}
+
+ @Test
+ @DisplayName("Set and get big value data")
+ @Order(11)
+ public void testLottaData() throws WindowsException {
+ var filler = "I like big nums and i cannot lie".repeat(1 << 16); //2 MiB
+
+ try (var t = WindowsRegistry.startTransaction();
+ var k = t.createRegKey(RegistryKey.HKEY_CURRENT_USER, "org.cryptomator.integrations-win", true)) {
+ k.setStringValue("bigData", filler, false);
+ t.commit();
+ }
+
+ try (var t = WindowsRegistry.startTransaction();
+ var k = t.openRegKey(RegistryKey.HKEY_CURRENT_USER, "org.cryptomator.integrations-win")) {
+ var value = k.getStringValue("bigData", false);
+ Assertions.assertEquals(filler, value);
+ }
+
+ try (var t = WindowsRegistry.startTransaction()) {
+ t.deleteRegKey(RegistryKey.HKEY_CURRENT_USER, "org.cryptomator.integrations-win");
+ t.commit();
+ }
+
+ }
}
From 7fe1522d24e0094d86080625281009c5e5edd920 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Fri, 5 Jul 2024 11:38:42 +0200
Subject: [PATCH 57/78] Make api misuse resistant: * remove methods
RegistryKey::deleteAllValuesSubtrees and RegistryKey::deleteSubtree * rename
method RegistryKey::deleteValuesSubtrees to deleteTree and make public * add
doc to method
---
.../windows/common/RegistryKey.java | 22 +++++++++----------
.../ExplorerQuickAccessService.java | 2 +-
.../windows/common/WindowsRegistryIT.java | 4 ++--
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index cc1546f..71833e3 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -122,18 +122,16 @@ public void deleteValue(String valueName, boolean ignoreNotExisting) throws Regi
}
}
- public void deleteSubtree(String subkey) throws RegistryKeyException {
- if (subkey == null || subkey.isBlank()) {
- throw new IllegalArgumentException("Subkey must not be empty");
- }
- deleteValuesAndSubtrees(subkey);
- }
-
- public void deleteAllValuesAndSubtrees() throws RegistryKeyException {
- deleteValuesAndSubtrees("");
- }
-
- private void deleteValuesAndSubtrees(String subkey) throws RegistryKeyException {
+ /**
+ * Deletes recursively content of this registry key.
+ *
+ * If a non-empty subkey name is specified, then the corresponding subkey and its descendants are deleted.
+ * If an empty string or {@code null} is specified as the subkey, this method deletes all subtrees and values of this registry key.
+ *
+ * @param subkey Name of the subkey, being the root of the subtree to be deleted. Can be {@code null} or empty.
+ * @throws RegistryKeyException, if winreg.h:RegDeleteTreeW returns a result != ERROR_SUCCESS
+ */
+ public void deleteTree(String subkey) throws RegistryKeyException {
try (var arena = Arena.ofConfined()) {
var lpSubkey = arena.allocateFrom(subkey, StandardCharsets.UTF_16LE);
int result = Winreg_h.RegDeleteTreeW(handle, lpSubkey);
diff --git a/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
index de589b5..b6a561f 100644
--- a/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
+++ b/src/main/java/org/cryptomator/windows/quickaccess/ExplorerQuickAccessService.java
@@ -136,7 +136,7 @@ public synchronized void remove() throws QuickAccessServiceException {
//undo everything else
try (var baseKey = t.openRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\" + clsid)) {
LOG.trace("Wiping everything under RegKey {} and key itself.", baseKey);
- baseKey.deleteAllValuesAndSubtrees();
+ baseKey.deleteTree("");
}
t.deleteRegKey(RegistryKey.HKEY_CURRENT_USER, "Software\\Classes\\CLSID\\" + clsid, true);
t.commit();
diff --git a/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java b/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java
index 795b96c..92006d6 100644
--- a/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java
+++ b/src/test/java/org/cryptomator/windows/common/WindowsRegistryIT.java
@@ -169,7 +169,7 @@ public void testOpenDeleteValueCommit() throws WindowsException {
public void testOpenDeleteTreeRollback() throws WindowsException {
try (var t = WindowsRegistry.startTransaction();
var k = t.openRegKey(RegistryKey.HKEY_CURRENT_USER, "org.cryptomator.integrations-win")) {
- k.deleteAllValuesAndSubtrees();
+ k.deleteTree("");
}
Assertions.assertDoesNotThrow(() -> {
@@ -187,7 +187,7 @@ public void testOpenDeleteTreeCommit() throws WindowsException {
try (var t = WindowsRegistry.startTransaction();
var k = t.openRegKey(RegistryKey.HKEY_CURRENT_USER, "org.cryptomator.integrations-win");
var subk = t.createRegKey(k, "subkey", true)) {
- k.deleteAllValuesAndSubtrees();
+ k.deleteTree("");
t.commit();
}
From 85a8f231c57f9ef53822723f255971c731e08dd6 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Fri, 5 Jul 2024 11:53:27 +0200
Subject: [PATCH 58/78] add javadoc
---
.../windows/common/RegistryKey.java | 52 ++++++++++++++++++-
1 file changed, 51 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index 71833e3..0a03d2c 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -36,6 +36,15 @@ public class RegistryKey implements AutoCloseable {
//-- GetValue functions --
+ /**
+ * Gets a REG_SZ or REG_EXPAND_SZ value.
+ *
+ * @param name name of the value
+ * @param isExpandable flag indicating if the value is of type REG_EXPAND_SZ
+ * @return the data of the value
+ * @throws RegistryValueException, if winreg.h:RegGetValueW returns a result != ERROR_SUCCESS
+ * @implNote This method is restricted to read at most {@value MAX_DATA_SIZE} from the registry. If the value exceeds the size, a runtime exception is thrown.
+ */
public String getStringValue(String name, boolean isExpandable) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
var data = getValue(arena, name, isExpandable ? RRF_RT_REG_EXPAND_SZ() : RRF_RT_REG_SZ());
@@ -43,6 +52,13 @@ public String getStringValue(String name, boolean isExpandable) throws RegistryV
}
}
+ /**
+ * Gets a DWORD value.
+ *
+ * @param name name of the value
+ * @return the data of the value
+ * @throws RegistryValueException, if winreg.h:RegGetValueW returns a result != ERROR_SUCCESS
+ */
public int getDwordValue(String name) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
var data = getValue(arena, name, RRF_RT_REG_DWORD());
@@ -78,6 +94,14 @@ private MemorySegment getValue(Arena arena, String name, int dwFlags) throws Reg
//-- SetValue functions --
+ /**
+ * Sets a REG_SZ or REG_EXPAND_SZ value for this registry key.
+ *
+ * @param name name of the value
+ * @param data Data to be set
+ * @param isExpandable flag marking if the value is of type REG_EXPAND_SZ
+ * @throws RegistryValueException, if winreg.h:RegSetKeyValueW returns a result != ERROR_SUCCESS
+ */
public void setStringValue(String name, String data, boolean isExpandable) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
@@ -86,6 +110,13 @@ public void setStringValue(String name, String data, boolean isExpandable) throw
}
}
+ /**
+ * Sets a DWORD value for this registry key.
+ *
+ * @param name name of the value
+ * @param data Data to be set
+ * @throws RegistryValueException, if winreg.h:RegSetKeyValueW returns a result != ERROR_SUCCESS
+ */
public void setDwordValue(String name, int data) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
var lpValueName = arena.allocateFrom(name, StandardCharsets.UTF_16LE);
@@ -107,10 +138,24 @@ private void setValue(MemorySegment lpValueName, MemorySegment data, int dwFlags
//-- delete operations
+ /**
+ * Deletes a value of this registry key.
+ *
+ * @param valueName name of the value
+ * @throws RegistryValueException, if winreg.h:RegDeleteKeyValueW returns a result != ERROR_SUCCESS
+ * @see RegistryKey#deleteValue(String, boolean)
+ */
public void deleteValue(String valueName) throws RegistryValueException {
deleteValue(valueName, false);
}
+ /**
+ * Deletes a value of this registry key.
+ *
+ * @param valueName name of the value
+ * @param ignoreNotExisting flag indicating wether a not existing value should be ignored
+ * @throws RegistryValueException, if winreg.h:RegDeleteKeyValueW returns a result != ERROR_SUCCESS, except the result is ERROR_FILE_NOT_FOUND and {@code ignoreNotExisting == true}
+ */
public void deleteValue(String valueName, boolean ignoreNotExisting) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
var lpValueName = arena.allocateFrom(valueName, StandardCharsets.UTF_16LE);
@@ -141,8 +186,13 @@ public void deleteTree(String subkey) throws RegistryKeyException {
}
}
+ /**
+ * Closes this registry key.
+ *
+ * @throws RuntimeException wrapping a {@link RegistryKeyException}, if winreg.h:RegCloseKey returns a result != ERROR_SUCCESS
+ */
@Override
- public synchronized void close() {
+ public synchronized void close() throws RuntimeException {
if (!isClosed) {
int result = Winreg_h.RegCloseKey(handle);
if (result != ERROR_SUCCESS()) {
From a74aa374fc4373285bb8f48ec4560bcf88bf4649 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Fri, 5 Jul 2024 11:54:00 +0200
Subject: [PATCH 59/78] Remove unnecessary string conversions
---
.../java/org/cryptomator/windows/common/RegistryKey.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index 0a03d2c..2cc6358 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -76,7 +76,7 @@ private MemorySegment getValue(Arena arena, String name, int dwFlags) throws Reg
do {
bufferSize = bufferSize << 1;
if (bufferSize >= MAX_DATA_SIZE) {
- throw new RuntimeException("Getting value %s for key %s failed. Maximum buffer size of %d reached.".formatted(lpValueName.getString(0, StandardCharsets.UTF_16LE), path, bufferSize));
+ throw new RuntimeException("Getting value %s for key %s failed. Maximum buffer size of %d reached.".formatted(name, path, bufferSize));
}
lpData = arena.allocate(bufferSize);
lpDataSize.set(ValueLayout.JAVA_INT, 0, bufferSize);
@@ -88,7 +88,7 @@ private MemorySegment getValue(Arena arena, String name, int dwFlags) throws Reg
if (result == ERROR_SUCCESS()) {
return lpData;
} else {
- throw new RegistryValueException("winreg_h:RegGetValue", path, lpValueName.getString(0, StandardCharsets.UTF_16LE), result);
+ throw new RegistryValueException("winreg_h:RegGetValue", path, name, result);
}
}
@@ -162,7 +162,7 @@ public void deleteValue(String valueName, boolean ignoreNotExisting) throws Regi
int result = Winreg_h.RegDeleteKeyValueW(handle, NULL, lpValueName);
if (result != ERROR_SUCCESS() //
&& !(result == ERROR_FILE_NOT_FOUND() && ignoreNotExisting)) {
- throw new RegistryValueException("winreg_h:RegSetKeyValueW", path, lpValueName.getString(0, StandardCharsets.UTF_16LE), result);
+ throw new RegistryValueException("winreg_h:RegSetKeyValueW", path, valueName, result);
}
}
}
From 541361925b65e150b2cdcf855cef6d9ba99a83d2 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Fri, 5 Jul 2024 17:29:07 +0200
Subject: [PATCH 60/78] Rework close method of registry transaction: * does not
throw anymore * the handle is always discarded * use logger
---
.../windows/common/WindowsRegistry.java | 29 ++++++++++++-------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java b/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
index a98363e..13cea4b 100644
--- a/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
+++ b/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
@@ -3,6 +3,8 @@
import org.cryptomator.windows.capi.common.Windows_h;
import org.cryptomator.windows.capi.ktmw32.Ktmw32_h;
import org.cryptomator.windows.capi.winreg.Winreg_h;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.lang.foreign.AddressLayout;
import java.lang.foreign.Arena;
@@ -17,6 +19,8 @@
public class WindowsRegistry {
+ private static final Logger LOG = LoggerFactory.getLogger(WindowsRegistry.class);
+
public static RegistryTransaction startTransaction() throws WindowsException {
var transactionHandle = Ktmw32_h.CreateTransaction(NULL, NULL, 0, 0, 0, 0, NULL);
if (transactionHandle.address() == INVALID_HANDLE_VALUE().address()) {
@@ -129,26 +133,31 @@ public synchronized void rollback() throws WindowsException {
closeInternal();
}
- ;
-
+ /**
+ * Closes this transaction.
+ *
+ * If this transaction is not commited, it is rolled back.
+ * The close method always discards the transaction handle. If an error occurs in either rolling back or closing the handle, the error is logged, but no exception thrown.
+ */
@Override
- public synchronized void close() throws WindowsException {
- if (!isCommited) {
- try {
+ public synchronized void close() {
+ try {
+ if (!isCommited) {
rollback();
- } catch (WindowsException e) {
- System.err.printf("Failed to rollback uncommited transaction on close: %s%n", e.getMessage());
}
+ } catch (WindowsException e) {
+ LOG.error("Failed to rollback uncommited transaction on close: {}", e.getMessage());
+ } finally {
+ closeInternal();
}
- closeInternal();
}
- private synchronized void closeInternal() throws WindowsException {
+ private synchronized void closeInternal() {
if (!isClosed) {
int result = Windows_h.CloseHandle(transactionHandle);
if (result == 0) {
int error = Windows_h.GetLastError();
- throw new WindowsException("Windows.h:CloseHandle", error);
+ LOG.error("Closing transaction handle failed. Function Windows.h:CloseHandle set system error code to {}", error);
}
transactionHandle = null;
isClosed = true;
From 7037aad3b8a084496bc92bbdbc333e38d98bff06 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Fri, 5 Jul 2024 17:29:20 +0200
Subject: [PATCH 61/78] doc doc doc
---
.../windows/common/WindowsRegistry.java | 52 ++++++++++++++++++-
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java b/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
index 13cea4b..bb11c3c 100644
--- a/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
+++ b/src/main/java/org/cryptomator/windows/common/WindowsRegistry.java
@@ -41,6 +41,17 @@ public static class RegistryTransaction implements AutoCloseable {
this.transactionHandle = handle;
}
+ /**
+ * Creates and opens a registry key.
+ *
+ * If the registry key already exists, it is just opened. The key is opened with the access rights KEY_READ and KEY_WRITE.
+ *
+ * @param key handle to an already opened registry key
+ * @param subkey name/path of a subkey that this function opens or creates
+ * @param isVolatile flag indicating if this key is volatile. A volatile key is not preserved over a system restart.
+ * @return the opened {@link RegistryKey}
+ * @throws RegistryKeyException if Winreg_h.RegCreateKeyTransactedW returns with a result != ERROR_SUCCESS
+ */
public RegistryKey createRegKey(RegistryKey key, String subkey, boolean isVolatile) throws RegistryKeyException {
var pointerToResultKey = Arena.ofAuto().allocate(AddressLayout.ADDRESS);
try (var arena = Arena.ofConfined()) {
@@ -61,10 +72,22 @@ public RegistryKey createRegKey(RegistryKey key, String subkey, boolean isVolati
if (result != ERROR_SUCCESS()) {
throw new RegistryKeyException("winreg.h:RegCreateKeyTransactedW", key.getPath() + "\\" + subkey, result);
}
+ //TODO: we can check if a registry root is opened (key is any regRoot && subkey == "")
+ // if so, we should wrap it in the corresponding class
return new RegistryKey(pointerToResultKey.get(C_POINTER, 0), key.getPath() + "\\" + subkey);
}
}
+ /**
+ * Opens a registry key.
+ *
+ * The key is opened with the access rights KEY_READ and KEY_WRITE.
+ *
+ * @param key handle to an already opened registry key
+ * @param subkey name/path of a subkey that this function opens
+ * @return the opened {@link RegistryKey}
+ * @throws RegistryKeyException if Winreg_h.RegOpenKeyTransactedW returns with a result != ERROR_SUCCESS
+ */
public RegistryKey openRegKey(RegistryKey key, String subkey) throws RegistryKeyException {
var pointerToResultKey = Arena.ofAuto().allocate(AddressLayout.ADDRESS);
try (var arena = Arena.ofConfined()) {
@@ -85,10 +108,26 @@ public RegistryKey openRegKey(RegistryKey key, String subkey) throws RegistryKey
}
}
- public void deleteRegKey(RegistryKey key, String subkey) throws WindowsException {
+ /**
+ * Deletes a registry key.
+ *
+ * @param key handle to an already opened registry key
+ * @param subkey name/path of a subkey that this function opens or creates
+ * @throws RegistryKeyException if Winreg_h.RegDeleteKeyTransactedW returns with a result != ERROR_SUCCESS
+ */
+ public void deleteRegKey(RegistryKey key, String subkey) throws RegistryKeyException {
deleteRegKey(key, subkey, false);
}
+ /**
+ * Deletes a registry key.
+ *
+ * If the key does not exists and {@code ignoreNotExisting == true}, no exceptions is thrown.
+ *
+ * @param key handle to an already opened registry key
+ * @param subkey name/path of a subkey that this function opens or creates
+ * @throws RegistryKeyException if Winreg_h.RegDeleteKeyTransactedW returns with a result != ERROR_SUCCESS, except the result is ERROR_FILE_NOT_FOUND and {@code ignoreNotExisting == true}
+ */
public void deleteRegKey(RegistryKey key, String subkey, boolean ignoreNotExisting) throws RegistryKeyException {
try (var arena = Arena.ofConfined()) {
var lpSubkey = arena.allocateFrom(subkey, StandardCharsets.UTF_16LE);
@@ -107,7 +146,11 @@ public void deleteRegKey(RegistryKey key, String subkey, boolean ignoreNotExisti
}
}
-
+ /**
+ * Commits and closes this transaction.
+ *
+ * @throws WindowsException if Ktmw32_h:CommitTransaction returned 0. The exception contains the system error code.
+ */
public synchronized void commit() throws WindowsException {
if (isClosed) {
throw new IllegalStateException("Transaction already closed");
@@ -121,6 +164,11 @@ public synchronized void commit() throws WindowsException {
closeInternal();
}
+ /**
+ * Rolls this transaction back and closes it.
+ *
+ * @throws WindowsException if Ktmw32_h:RollbackTransaction returned 0. The exception contains the system error code.
+ */
public synchronized void rollback() throws WindowsException {
if (isClosed) {
throw new IllegalStateException("Transaction already closed");
From fcd11c44019b9222b4a6af166a4d33310e84288c Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Fri, 5 Jul 2024 17:35:29 +0200
Subject: [PATCH 62/78] fix doc doc
---
.../cryptomator/windows/common/RegistryKey.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/cryptomator/windows/common/RegistryKey.java b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
index 2cc6358..42fe644 100644
--- a/src/main/java/org/cryptomator/windows/common/RegistryKey.java
+++ b/src/main/java/org/cryptomator/windows/common/RegistryKey.java
@@ -38,12 +38,13 @@ public class RegistryKey implements AutoCloseable {
/**
* Gets a REG_SZ or REG_EXPAND_SZ value.
+ *
+ * The size of the data is restricted to at most {@value MAX_DATA_SIZE}. If the the value exceeds the size, a runtime exception is thrown.
*
* @param name name of the value
* @param isExpandable flag indicating if the value is of type REG_EXPAND_SZ
* @return the data of the value
- * @throws RegistryValueException, if winreg.h:RegGetValueW returns a result != ERROR_SUCCESS
- * @implNote This method is restricted to read at most {@value MAX_DATA_SIZE} from the registry. If the value exceeds the size, a runtime exception is thrown.
+ * @throws RegistryValueException if winreg.h:RegGetValueW returns a result != ERROR_SUCCESS
*/
public String getStringValue(String name, boolean isExpandable) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
@@ -57,7 +58,7 @@ public String getStringValue(String name, boolean isExpandable) throws RegistryV
*
* @param name name of the value
* @return the data of the value
- * @throws RegistryValueException, if winreg.h:RegGetValueW returns a result != ERROR_SUCCESS
+ * @throws RegistryValueException if winreg.h:RegGetValueW returns a result != ERROR_SUCCESS
*/
public int getDwordValue(String name) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
@@ -100,7 +101,7 @@ private MemorySegment getValue(Arena arena, String name, int dwFlags) throws Reg
* @param name name of the value
* @param data Data to be set
* @param isExpandable flag marking if the value is of type REG_EXPAND_SZ
- * @throws RegistryValueException, if winreg.h:RegSetKeyValueW returns a result != ERROR_SUCCESS
+ * @throws RegistryValueException if winreg.h:RegSetKeyValueW returns a result != ERROR_SUCCESS
*/
public void setStringValue(String name, String data, boolean isExpandable) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
@@ -115,7 +116,7 @@ public void setStringValue(String name, String data, boolean isExpandable) throw
*
* @param name name of the value
* @param data Data to be set
- * @throws RegistryValueException, if winreg.h:RegSetKeyValueW returns a result != ERROR_SUCCESS
+ * @throws RegistryValueException if winreg.h:RegSetKeyValueW returns a result != ERROR_SUCCESS
*/
public void setDwordValue(String name, int data) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
@@ -142,7 +143,7 @@ private void setValue(MemorySegment lpValueName, MemorySegment data, int dwFlags
* Deletes a value of this registry key.
*
* @param valueName name of the value
- * @throws RegistryValueException, if winreg.h:RegDeleteKeyValueW returns a result != ERROR_SUCCESS
+ * @throws RegistryValueException if winreg.h:RegDeleteKeyValueW returns a result != ERROR_SUCCESS
* @see RegistryKey#deleteValue(String, boolean)
*/
public void deleteValue(String valueName) throws RegistryValueException {
@@ -154,7 +155,7 @@ public void deleteValue(String valueName) throws RegistryValueException {
*
* @param valueName name of the value
* @param ignoreNotExisting flag indicating wether a not existing value should be ignored
- * @throws RegistryValueException, if winreg.h:RegDeleteKeyValueW returns a result != ERROR_SUCCESS, except the result is ERROR_FILE_NOT_FOUND and {@code ignoreNotExisting == true}
+ * @throws RegistryValueException if winreg.h:RegDeleteKeyValueW returns a result != ERROR_SUCCESS, except the result is ERROR_FILE_NOT_FOUND and {@code ignoreNotExisting == true}
*/
public void deleteValue(String valueName, boolean ignoreNotExisting) throws RegistryValueException {
try (var arena = Arena.ofConfined()) {
@@ -174,7 +175,7 @@ public void deleteValue(String valueName, boolean ignoreNotExisting) throws Regi
* If an empty string or {@code null} is specified as the subkey, this method deletes all subtrees and values of this registry key.
*
* @param subkey Name of the subkey, being the root of the subtree to be deleted. Can be {@code null} or empty.
- * @throws RegistryKeyException, if winreg.h:RegDeleteTreeW returns a result != ERROR_SUCCESS
+ * @throws RegistryKeyException if winreg.h:RegDeleteTreeW returns a result != ERROR_SUCCESS
*/
public void deleteTree(String subkey) throws RegistryKeyException {
try (var arena = Arena.ofConfined()) {
From 5f3489121d6f695c90fa22aa5ea44d977d5ba7a3 Mon Sep 17 00:00:00 2001
From: Armin Schrenk
Date: Mon, 8 Jul 2024 10:05:51 +0200
Subject: [PATCH 63/78] Update org.owasp:dependency-check-maven from 9.2.0 to
10.0.2
---
pom.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 758df39..5048aaa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
5.12.0
- 9.2.0
+ 10.0.2
1.7.0
@@ -392,4 +392,4 @@