public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: jturney@sourceware.org
To: cygwin-apps-cvs@sourceware.org
Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.893
Date: Thu, 26 Jul 2018 21:47:00 -0000	[thread overview]
Message-ID: <20180726214721.34985.qmail@sourceware.org> (raw)




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";


                 reply	other threads:[~2018-07-26 21:47 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=20180726214721.34985.qmail@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-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: link
Be 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).