public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: utils: ldd: use GetFinalPathNameByHandleW Date: Thu, 20 May 2021 21:08:02 +0000 (GMT) [thread overview] Message-ID: <20210520210802.6B219385803D@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6462a0844db160b341a41bfb8c1083d3b9367042 commit 6462a0844db160b341a41bfb8c1083d3b9367042 Author: Corinna Vinschen <corinna@vinschen.de> Date: Thu May 20 23:07:05 2021 +0200 Cygwin: utils: ldd: use GetFinalPathNameByHandleW drop replacement function GetFileNameFromHandle which was only required pre-Vista. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/utils/ldd.cc | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/winsup/utils/ldd.cc b/winsup/utils/ldd.cc index 1e1863c1c..183e02cd4 100644 --- a/winsup/utils/ldd.cc +++ b/winsup/utils/ldd.cc @@ -56,7 +56,6 @@ struct option longopts[] = const char *opts = "dhruvV"; static int process_file (const wchar_t *); -static void *drive_map; static int error (const char *fmt, ...) @@ -155,32 +154,6 @@ get_module_filename (HANDLE hp, HMODULE hm) return buf; } -static BOOL -GetFileNameFromHandle(HANDLE hFile, WCHAR pszFilename[MAX_PATH+1]) -{ - BOOL result = FALSE; - ULONG len = 0; - OBJECT_NAME_INFORMATION *ntfn = (OBJECT_NAME_INFORMATION *) alloca (65536); - NTSTATUS status = NtQueryObject (hFile, ObjectNameInformation, - ntfn, 65536, &len); - if (NT_SUCCESS (status)) - { - PWCHAR win32path = ntfn->Name.Buffer; - win32path[ntfn->Name.Length / sizeof (WCHAR)] = L'\0'; - - /* NtQueryObject returns a native NT path. (Try to) convert to Win32. */ - if (!drive_map) - drive_map = (void *) cygwin_internal (CW_ALLOC_DRIVE_MAP); - if (drive_map) - win32path = (PWCHAR) cygwin_internal (CW_MAP_DRIVE_MAP, drive_map, - win32path); - pszFilename[0] = L'\0'; - wcsncat (pszFilename, win32path, MAX_PATH); - result = TRUE; - } - return result; -} - static wchar_t * load_dll (const wchar_t *fn) { @@ -288,8 +261,8 @@ print_dlls (dlls *dll, const wchar_t *dllfn, const wchar_t *process_fn) if (!fullpath) { // if no path found yet, try getting it from an open handle to the DLL - wchar_t dllname[MAX_PATH+1]; - if (GetFileNameFromHandle (dll->hFile, dllname)) + wchar_t dllname[PATH_MAX]; + if (GetFinalPathNameByHandleW (dll->hFile, dllname, PATH_MAX, 0)) { fn = tocyg (dllname); saw_file (basename (fn)); @@ -465,8 +438,6 @@ main (int argc, char **argv) while ((fn = *argv++)) if (report (fn, multiple)) ret = 1; - if (drive_map) - cygwin_internal (CW_FREE_DRIVE_MAP, drive_map); exit (ret); }
reply other threads:[~2021-05-20 21:08 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210520210802.6B219385803D@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /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: linkBe 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).