public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-patches@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH 2/2] Cygwin: Drop use of loadlib.h in regtool
Date: Sat, 26 Feb 2022 16:40:54 +0000	[thread overview]
Message-ID: <20220226164054.26698-3-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20220226164054.26698-1-jon.turney@dronecode.org.uk>

Link directly with RegDeleteKeyExW(), available since Vista.

(It's unclear the LoadLibrary wrapper was ever doing anything useful
here, as (i) DLL lookup in PATH was avoided as advapi32 is already
loaded into the process, and (ii) advapi32 is a 'known DLL' which is
only ever loaded from system directory)
---
 winsup/utils/regtool.cc | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/winsup/utils/regtool.cc b/winsup/utils/regtool.cc
index fd2dd0590..e919185ae 100644
--- a/winsup/utils/regtool.cc
+++ b/winsup/utils/regtool.cc
@@ -16,7 +16,6 @@ details. */
 #include <windows.h>
 #include <sys/cygwin.h>
 #include <cygwin/version.h>
-#include "loadlib.h"
 
 #define DEFAULT_KEY_SEPARATOR '\\'
 
@@ -589,10 +588,6 @@ cmd_add ()
   return 0;
 }
 
-extern "C" {
-  LONG WINAPI (*regDeleteKeyEx)(HKEY, LPCWSTR, REGSAM, DWORD);
-}
-
 int
 cmd_remove ()
 {
@@ -600,13 +595,7 @@ cmd_remove ()
 
   find_key (2, KEY_ALL_ACCESS);
   if (wow64)
-    {
-      HMODULE mod = LoadLibrary ("advapi32.dll");
-      if (mod)
-	regDeleteKeyEx = (LONG WINAPI (*)(HKEY, LPCWSTR, REGSAM, DWORD)) GetProcAddress (mod, "RegDeleteKeyExW");
-    }
-  if (regDeleteKeyEx)
-    rv = (*regDeleteKeyEx) (key, value, wow64, 0);
+    rv = RegDeleteKeyExW (key, value, wow64, 0);
   else
     rv = RegDeleteKeyW (key, value);
   if (rv != ERROR_SUCCESS)
-- 
2.35.1


  parent reply	other threads:[~2022-02-26 16:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26 16:40 [PATCH 0/2] Drop pointless loadlib.h use in utilities Jon Turney
2022-02-26 16:40 ` [PATCH 1/2] Cygwin: Drop pointless loadlib.h includes " Jon Turney
2022-02-26 16:40 ` Jon Turney [this message]
2022-02-28  9:44   ` [PATCH 2/2] Cygwin: Drop use of loadlib.h in regtool Corinna Vinschen
2022-02-28  9:39 ` [PATCH 0/2] Drop pointless loadlib.h use in utilities Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220226164054.26698-3-jon.turney@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).