Page MenuHome GnuPG

Gpg4win: Replace GpgEX functionality through Windows registry
Open, NormalPublic

Description

With GPA gone from Gpg4win there is no need anymore for a UIserver connection, we can just call Kleopatra like we do on Linux also on Windows.

This will also allow us to modify the context menu of Windows 11 as this is only modifyable by the registry. Currently GpgEX options on Win 11 are only shown if you open the legacy context menu.

Revisions and Commits

Event Timeline

aheinecke triaged this task as Normal priority.Jan 5 2023, 11:26 AM
aheinecke created this task.
aheinecke moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Jan 10 2023, 1:08 PM

Note to self after spending some time searching again for the documentation I saw previously about this: https://learn.microsoft.com/en-us/windows/win32/shell/context-menu-handlers#suppressing-verbs-and-controlling-visibility

So most of the code is basically:

# Explorer entry for unknown files
WriteRegStr SHCTX "Software\Classes\*\Kleopatra" "" "$(T_SIGN_ENCRYPT)"
# Filter out all our known
WriteRegStr SHCTX "Software\Classes\*\Kleopatra" "$\"AppliesTo$\" $\"System.FileName:~!$\".gpg$\" AND System.FileName:~!$\".asc$\" AND System.FileName:~!$\".cer$\" AND System.FileName:~!$\".p10$\" AND System.FileName:~!$\".p12$\" AND System.FileName:~!$\".p7c$\" AND System.FileName:~!$\".pfx$\" AND System.FileName:~!$\".crt$\" AND System.FileName:~!$\".der$\" AND System.FileName:~!$\".sig$\" AND System.FileName:~!$\".p7m$\" AND System.FileName:~!$\".p7s$\" AND System.FileName:~!$\".pem$\" AND System.FileName:~!$\".kgrp$\""
WriteRegStr SHCTX "Software\Classes\command" "" "$\"$INSTDIR\bin\Kleopatra.exe$\" -- $\"%1$\""

And then added keys for each extension with different Strings for the action.

But, it is of course more difficult then I thought, as Windows does not provide a way for multiple file selection to be passed to a command. Instead it sequentially calls the command with each parameter. This "should" work in theory in Kleopatra as we implement it as a Unique Service that should only run once. But for that my own code in kuniqueservice_win has to be improved. First thing I noticed that it should be above the "setAboutData" call in main as that is a very expensive call (checking the Version file and the signature of the Version file and calling gpgconf.exe for versions). I wonder if we could delay this some more as most of the about data is only needed once about is clicked. This really eats 1.5s on a slow machine of mine currently.

Still it is too slow to detect a race between two Kleopatras. Fixing this will actually also fix a bug we currently have that if you quadruple click kleopatra or an associated file you can start two instances.

aheinecke mentioned this in Unknown Object (Maniphest Task).Sep 15 2023, 10:31 AM
aheinecke moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Nov 3 2023, 8:47 AM