public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: dll_list: stat_real_file_once as dll method
@ 2019-04-30 16:35 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-04-30 16:35 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0f5776c47ca08c31c939f4b9faf6c105b61fa688

commit 0f5776c47ca08c31c939f4b9faf6c105b61fa688
Author: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date:   Tue Apr 30 16:14:55 2019 +0200

    Cygwin: dll_list: stat_real_file_once as dll method
    
    Make stat_real_file_once a method of struct dll, to be more flexible on
    where to use.  Also, debug print memory section name queried for a dll.
    This is a preparation to query the file id when loading the dll.

Diff:
---
 winsup/cygwin/dll_init.h  |  1 +
 winsup/cygwin/forkable.cc | 22 ++++++++++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h
index 0a97496..e4fbde8 100644
--- a/winsup/cygwin/dll_init.h
+++ b/winsup/cygwin/dll_init.h
@@ -65,6 +65,7 @@ struct dll
 
   void detach ();
   int init ();
+  bool stat_real_file_once ();
   void nominate_forkable (PCWCHAR);
   bool create_forkable ();
   void run_dtors ()
diff --git a/winsup/cygwin/forkable.cc b/winsup/cygwin/forkable.cc
index 30833c4..912a9ac 100644
--- a/winsup/cygwin/forkable.cc
+++ b/winsup/cygwin/forkable.cc
@@ -155,10 +155,10 @@ rmdirs (WCHAR ntmaxpathbuf[NT_MAX_PATH])
    file name, as GetModuleFileNameW () yields the as-loaded name.
    While we have the file handle open, also read the attributes.
    NOTE: Uses dll_list::nt_max_path_buf (). */
-static bool
-stat_real_file_once (dll *d)
+bool
+dll::stat_real_file_once ()
 {
-  if (d->fii.IndexNumber.QuadPart != -1LL)
+  if (fii.IndexNumber.QuadPart != -1LL)
     return true;
 
   tmp_pathbuf tp;
@@ -171,35 +171,37 @@ stat_real_file_once (dll *d)
   RtlInitEmptyUnicodeString (&msi2.SectionFileName, tp.w_get (), 65535);
 
   /* Retry opening the real file name until that does not change any more. */
-  status = NtQueryVirtualMemory (NtCurrentProcess (), d->handle,
+  status = NtQueryVirtualMemory (NtCurrentProcess (), handle,
 				 MemorySectionName, pmsi1, 65536, NULL);
   while (NT_SUCCESS (status) &&
 	!RtlEqualUnicodeString (&msi2.SectionFileName,
 				&pmsi1->SectionFileName, FALSE))
     {
+      debug_printf ("for %s at %p got memory section name '%W'",
+	ntname, handle, pmsi1->SectionFileName.Buffer);
       RtlCopyUnicodeString (&msi2.SectionFileName, &pmsi1->SectionFileName);
       if (fhandle != INVALID_HANDLE_VALUE)
 	NtClose (fhandle);
       pmsi1->SectionFileName.Buffer[pmsi1->SectionFileName.Length] = L'\0';
       fhandle = dll_list::ntopenfile (pmsi1->SectionFileName.Buffer, &fstatus);
-      status = NtQueryVirtualMemory (NtCurrentProcess (), d->handle,
+      status = NtQueryVirtualMemory (NtCurrentProcess (), handle,
 				     MemorySectionName, pmsi1, 65536, NULL);
     }
   if (!NT_SUCCESS (status))
     system_printf ("WARNING: Unable (ntstatus %y) to query real file for %W",
-		   status, d->ntname);
+		   status, ntname);
   else if (fhandle == INVALID_HANDLE_VALUE)
     system_printf ("WARNING: Unable (ntstatus %y) to open real file for %W",
-		   fstatus, d->ntname);
+		   fstatus, ntname);
   if (fhandle == INVALID_HANDLE_VALUE)
     return false;
 
-  if (!dll_list::read_fii (fhandle, &d->fii))
+  if (!dll_list::read_fii (fhandle, &fii))
     system_printf ("WARNING: Unable to read real file attributes for %W",
 		   pmsi1->SectionFileName.Buffer);
 
   NtClose (fhandle);
-  return d->fii.IndexNumber.QuadPart != -1LL;
+  return fii.IndexNumber.QuadPart != -1LL;
 }
 
 /* easy use of NtOpenFile */
@@ -605,7 +607,7 @@ dll_list::prepare_forkables_nomination ()
 {
   dll *d = &dlls.start;
   while ((d = d->next))
-    stat_real_file_once (d); /* uses nt_max_path_buf () */
+    d->stat_real_file_once (); /* uses nt_max_path_buf () */
 
   PWCHAR pbuf = nt_max_path_buf ();


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-30 16:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 16:35 [newlib-cygwin] Cygwin: dll_list: stat_real_file_once as dll method Corinna Vinschen

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).