diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-30 15:40:08 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-30 15:54:49 -0700 |
commit | fd22e8123b18e52610e36b21f29f3a80850d8dee (patch) | |
tree | e780a68612939ab2c05e20056dd530664723f0b1 | |
parent | 5149bc0df8b8f2b813911f360eca994e323b1138 (diff) | |
download | subsurface-fd22e8123b18e52610e36b21f29f3a80850d8dee.tar.gz |
User survey: detect the machine the app is running on
We build 32bit Windows binaries - but we really want to know if the OS is
x86_64 or i386. This little hack should give us that information.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/usersurvey.cpp | 13 | ||||
-rw-r--r-- | subsurfacesysinfo.cpp | 30 | ||||
-rw-r--r-- | subsurfacesysinfo.h | 2 |
3 files changed, 43 insertions, 2 deletions
diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp index f08168ed3..0a97fdb78 100644 --- a/qt-ui/usersurvey.cpp +++ b/qt-ui/usersurvey.cpp @@ -14,6 +14,7 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), ui(new Ui::UserSurvey) { + QString osArch, arch; ui->setupUi(this); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(closeKey, SIGNAL(activated()), this, SLOT(close())); @@ -25,8 +26,16 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), os = QString("ssrfVers=%1").arg(VERSION_STRING); sysInfo.append(tr("\nOperating System: %1").arg(SubsurfaceSysInfo::prettyOsName())); os.append(QString("&prettyOsName=%1").arg(SubsurfaceSysInfo::prettyOsName())); - sysInfo.append(tr("\nCPU Architecture: %1").arg(SubsurfaceSysInfo::cpuArchitecture())); - os.append(QString("&cpuArch=%1").arg(SubsurfaceSysInfo::cpuArchitecture())); + arch = SubsurfaceSysInfo::cpuArchitecture(); + sysInfo.append(tr("\nCPU Architecture: %1").arg(arch)); + os.append(QString("&appCpuArch=%1").arg(arch)); + if (arch == "i386") { + osArch = SubsurfaceSysInfo::osArch(); + if (!osArch.isEmpty()) { + sysInfo.append(tr("\nOS CPU Architecture %1").arg(osArch)); + os.append(QString("&osCpuArch=%1").arg(osArch)); + } + } sysInfo.append(tr("\nLanguage: %1").arg(uiLanguage(NULL))); os.append(QString("&uiLang=%1").arg(uiLanguage(NULL))); ui->system->setPlainText(sysInfo); diff --git a/subsurfacesysinfo.cpp b/subsurfacesysinfo.cpp index ca3b161a3..75ce38be7 100644 --- a/subsurfacesysinfo.cpp +++ b/subsurfacesysinfo.cpp @@ -442,3 +442,33 @@ QString SubsurfaceSysInfo::prettyOsName() return unknownText(); #endif } + +// detect if the OS we are running on is 64 or 32bit +// we only care when building on Intel for 32bit +QString SubsurfaceSysInfo::osArch() +{ + QString res = ""; +#if defined(Q_PROCESSOR_X86_32) +#if defined(Q_OS_UNIX) + struct utsname u; + if (uname(&u) != -1) { + res = u.machine; + } +#elif defined(Q_OS_WIN) + + /* this code is from + * http://mark.koli.ch/reliably-checking-os-bitness-32-or-64-bit-on-windows-with-a-tiny-c-app + * there is no license given, but 5 lines of code should be fine to reuse unless explicitly forbidden */ + typedef BOOL (WINAPI *IW64PFP)(HANDLE, BOOL *); + BOOL os64 = FALSE; + IW64PFP IW64P = (IW64PFP)GetProcAddress( + GetModuleHandle((LPCSTR)"kernel32"), "IsWow64Process"); + + if(IW64P != NULL){ + IW64P(GetCurrentProcess(), &os64); + } + res = os64 ? "x86_64" : "i386"; +#endif +#endif + return res; +} diff --git a/subsurfacesysinfo.h b/subsurfacesysinfo.h index 2cd8abace..877f7ef00 100644 --- a/subsurfacesysinfo.h +++ b/subsurfacesysinfo.h @@ -212,7 +212,9 @@ public: static QString osKernelVersion(); static QString osVersion(); static QString prettyOsName(); + #endif + static QString osArch(); }; |