public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_4-branch] Cygwin: Adjust CWD magic to accommodate for the latest Windows previews
@ 2023-05-24 21:06 Jon Turney
  0 siblings, 0 replies; only message in thread
From: Jon Turney @ 2023-05-24 21:06 UTC (permalink / raw)
  To: cygwin-cvs

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

commit deca777a958cad67faa73d7457ecccd8c73ed943
Author: Johannes Schindelin <johannes.schindelin@gmx.de>
Date:   Mon May 22 13:36:27 2023 +0200

    Cygwin: Adjust CWD magic to accommodate for the latest Windows previews
    
    Reportedly Windows 11 build 25*** from Insider changed the current
    working directory logic a bit, and Cygwin's "magic" (or:
    "technologically sufficiently advanced") code needs to be adjusted
    accordingly.
    
    This fixes https://github.com/git-for-windows/git/issues/4429
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    (cherry picked from commit 4840a5632520c1a3c1598f73f9d1cdd37df371ba)

Diff:
---
 winsup/cygwin/path.cc | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 5b3df20dd..e788c7d60 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -4578,13 +4578,27 @@ find_fast_cwd_pointer ()
       if (!lock)
 	{
 	  /* Windows 8.1 Preview calls `lea rel(rip),%r12' then some unrelated
-	     or, then `mov %r12,%rcx', then `callq RtlEnterCriticalSection'. */
+	     ops, then `mov %r12,%rcx', then `callq RtlEnterCriticalSection'. */
 	  lock = (const uint8_t *) memmem ((const char *) use_cwd, 80,
 					   "\x4c\x8d\x25", 3);
-	  if (!lock)
-	    return NULL;
 	  call_rtl_offset = 14;
 	}
+
+      if (!lock)
+	{
+	  /* A recent Windows 11 Preview calls `lea rel(rip),%r13' then
+	     some unrelated instructions, then `callq RtlEnterCriticalSection'.
+	     */
+	  lock = (const uint8_t *) memmem ((const char *) use_cwd, 80,
+					   "\x4c\x8d\x2d", 3);
+	  call_rtl_offset = 24;
+	}
+
+      if (!lock)
+	{
+	  return NULL;
+	}
+
       PRTL_CRITICAL_SECTION lockaddr =
         (PRTL_CRITICAL_SECTION) (lock + 7 + peek32 (lock + 3));
       /* Test if lock address is FastPebLock. */

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

only message in thread, other threads:[~2023-05-24 21:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 21:06 [newlib-cygwin/cygwin-3_4-branch] Cygwin: Adjust CWD magic to accommodate for the latest Windows previews Jon Turney

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