[git] GpgOL - branch, master, updated. gpgol-2.3.1-13-gb4c45c3

by Andre Heinecke cvs at cvs.gnupg.org
Thu Oct 25 11:53:01 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  b4c45c3a3ec98b900bcd785ea9261e33f5562e08 (commit)
      from  326f0abbbaf1b1d59e0fc72730923b40cfa3bf09 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b4c45c3a3ec98b900bcd785ea9261e33f5562e08
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 25 11:50:58 2018 +0200

    Read HKLM fallback from cross registry view
    
    * src/addin-options.cpp (open-gpgolconfig): Do not pass w64 again.
    * src/common.cpp (CROSS_ACCESS): New define.
    (_readRegStr): Helper for readRegStr.
    (readRegStr): More explicit fallbacks.
    
    --
    This should be more robust to handle cases where either
    HKLM is set up as 32 bit registry key or as 64 bit registry
    key.

diff --git a/src/addin-options.cpp b/src/addin-options.cpp
index c228b17..137d880 100644
--- a/src/addin-options.cpp
+++ b/src/addin-options.cpp
@@ -188,10 +188,6 @@ open_gpgolconfig (LPVOID arg)
   args.push_back (std::string ("--lang"));
   args.push_back (std::string (gettext_localename ()));
 
-#ifdef _WIN64
-  args.push_back (std::string ("--w64"));
-#endif
-
   auto ctx = GpgME::Context::createForEngine (GpgME::SpawnEngine);
   if (!ctx)
     {
diff --git a/src/common.cpp b/src/common.cpp
index 72fa16f..2140f25 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -107,50 +107,38 @@ get_root_key(const char *root)
     return NULL;
   return root_key;
 }
+#if defined(_WIN64)
+#define CROSS_ACCESS KEY_WOW64_32KEY
+#else
+#define CROSS_ACCESS KEY_WOW64_64KEY
+#endif
 
-static std::string
-readRegStr (const char *root, const char *dir, const char *name)
+std::string
+_readRegStr (HKEY root_key, const char *dir,
+             const char *name, bool alternate)
 {
 #ifndef _WIN32
-    (void)root; (void)dir; (void)name;
+    (void) root_key; (void)alternate; (void)dir; (void)name;
     return std::string();
 #else
-
-    HKEY root_key, key_handle;
+    HKEY key_handle;
     DWORD n1, nbytes, type;
     std::string ret;
 
-    if (!(root_key = get_root_key(root))) {
-        return ret;
-    }
+    DWORD flags = KEY_READ;
 
-    if (RegOpenKeyExA(root_key, dir, 0, KEY_READ, &key_handle)) {
-        if (root) {
-            /* no need for a RegClose, so return direct */
-            return ret;
-        }
-        /* Fallback to HKLM */
+    if (alternate) {
+        flags |= CROSS_ACCESS;
+    }
 
-        if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle)) {
-            return ret;
-        }
+    if (RegOpenKeyExA(root_key, dir, 0, flags, &key_handle)) {
+        return ret;
     }
 
     nbytes = 1;
     if (RegQueryValueExA(key_handle, name, 0, nullptr, nullptr, &nbytes)) {
-        if (root) {
-            RegCloseKey (key_handle);
-            return ret;
-        }
-        /* Try to fallback to HKLM also vor a missing value.  */
         RegCloseKey (key_handle);
-        if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, dir, 0, KEY_READ, &key_handle)) {
-            return ret;
-        }
-        if (RegQueryValueExA(key_handle, name, 0, nullptr, nullptr, &nbytes)) {
-            RegCloseKey(key_handle);
-            return ret;
-        }
+        return ret;
     }
     n1 = nbytes+1;
     char result[n1];
@@ -182,6 +170,33 @@ readRegStr (const char *root, const char *dir, const char *name)
         }
     }
     return ret;
+
+#endif
+}
+
+std::string
+readRegStr (const char *root, const char *dir, const char *name)
+{
+#ifndef _WIN32
+    (void)root; (void)dir; (void)name;
+    return std::string();
+#else
+    HKEY root_key;
+    std::string ret;
+    if (!(root_key = get_root_key(root))) {
+        return ret;
+    }
+    ret = _readRegStr (root_key, dir, name, false);
+
+    if (ret.empty()) {
+        // Try local machine as fallback.
+        ret = _readRegStr (HKEY_LOCAL_MACHINE, dir, name, false);
+        if (ret.empty()) {
+            // Try alternative registry view as fallback
+            ret = _readRegStr (HKEY_LOCAL_MACHINE, dir, name, true);
+        }
+    }
+    return ret;
 #endif
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/addin-options.cpp |  4 ---
 src/common.cpp        | 73 +++++++++++++++++++++++++++++++--------------------
 2 files changed, 44 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list