On Sat, 29 Mar 2025, Jeremy Drake via Cygwin-patches wrote:
> I tested x86_64 code on every released Windows version from 9600 to 26100.
> Interestingly, the machine code of the "use_cwd" function
> (RtlpReferenceCurrentDirectory) didn't seem to change until 26100.
>
> (I previously tested the prototype aarch64 code on 16299, 19045, 22631,
> and 26100, but only 22000+ supports x86_64 emulation).
I updated the prototype code with latest updates and tested on arm64 in
16299, 19045, 22631, 26100, and finally 22000. It seems the "thunk"/"fast
forward sequence" differs on 22000, but luckily it's the same size. Do I
need to resend the whole series or just a v4 of the last patch?
diff --git a/winsup/cygwin/aarch64/fastcwd.cc b/winsup/cygwin/aarch64/fastcwd.cc
index a0f169b61a..f075b8cd59 100644
--- a/winsup/cygwin/aarch64/fastcwd.cc
+++ b/winsup/cygwin/aarch64/fastcwd.cc
@@ -23,16 +23,20 @@ GetArm64ProcAddress (HMODULE hModule, LPCSTR procname)
#if defined (__aarch64__)
return proc;
#else
-#if defined(__i386__)
+#if defined (__i386__)
static const BYTE thunk[] = "\x8b\xff\x55\x8b\xec\x5d\x90\xe9";
-#elif defined(__x86_64__)
+ static const BYTE thunk2[0];
+#elif defined (__x86_64__)
/* see
https://learn.microsoft.com/en-us/windows/arm/arm64ec-abi#fast-forward-sequences
*/
static const BYTE thunk[] = "\x48\x8b\xc4\x48\x89\x58\x20\x55\x5d\xe9";
+ /* on windows 11 22000 the thunk is different than documented on that page */
+ static const BYTE thunk2[] = "\x48\x8b\xff\x55\x48\x8b\xec\x5d\x90\xe9";
#else
#error "Unhandled architecture for thunk detection"
#endif
- if (memcmp (proc, thunk, sizeof (thunk) - 1) == 0)
+ if (memcmp (proc, thunk, sizeof (thunk) - 1) == 0 ||
+ sizeof(thunk2) && memcmp (proc, thunk2, sizeof (thunk2) - 1) == 0)
{
proc += sizeof (thunk) - 1;
proc += 4 + *(const int32_t *) proc;