[setup - the official Cygwin setup program] branch master, updated. release_2.893

jturney@sourceware.org jturney@sourceware.org
Thu Jul 26 21:47:00 GMT 2018




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=f378fb54ceaa4e27d53cede22f806e8798f5a04d

commit f378fb54ceaa4e27d53cede22f806e8798f5a04d
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Tue Jul 24 22:18:51 2018 +0100

    Teach bitness reporting in user-agent string about WoW64 on ARM64


Diff:
---
 nio-ie5.cc |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/nio-ie5.cc b/nio-ie5.cc
index 6fada0f..6202c01 100644
--- a/nio-ie5.cc
+++ b/nio-ie5.cc
@@ -31,6 +31,10 @@
 #include "getopt++/StringOption.h"
 #include <sstream>
 
+#ifndef IMAGE_FILE_MACHINE_ARM64
+#define IMAGE_FILE_MACHINE_ARM64 0xAA64
+#endif
+
 static StringOption UserAgent ("", '\0', "user-agent", "User agent string for HTTP requests");
 
 const std::string &
@@ -48,9 +52,30 @@ determine_default_useragent(void)
 #ifdef __x86_64__
   bitness = "Win64";
 #else
+  typedef BOOL (WINAPI *PFNISWOW64PROCESS2)(HANDLE, USHORT *, USHORT *);
+  PFNISWOW64PROCESS2 pfnIsWow64Process2 = (PFNISWOW64PROCESS2)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process2");
+
   typedef BOOL (WINAPI *PFNISWOW64PROCESS)(HANDLE, PBOOL);
   PFNISWOW64PROCESS pfnIsWow64Process = (PFNISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process");
-  if (pfnIsWow64Process) {
+
+  std::stringstream native_desc;
+
+  USHORT processMachine, nativeMachine;
+  if ((pfnIsWow64Process2) &&
+      (pfnIsWow64Process2(GetCurrentProcess(), &processMachine, &nativeMachine))) {
+    switch (nativeMachine)
+      {
+      case IMAGE_FILE_MACHINE_AMD64:
+        bitness = "WoW64";
+        break;
+      case IMAGE_FILE_MACHINE_ARM64:
+        bitness = "WoW64-ARM64";
+        break;
+      default:
+        native_desc << "WoW64-" << std::hex << nativeMachine;
+        bitness = native_desc.str();
+      }
+  } else if (pfnIsWow64Process) {
     BOOL bIsWow64 = FALSE;
     if (pfnIsWow64Process(GetCurrentProcess(), &bIsWow64))
       bitness = bIsWow64 ? "WoW64" : "Win32";



More information about the Cygwin-apps-cvs mailing list