#include "config.h"
+#include <string.h>
#include <errno.h>
#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif
-#ifdef HAVE_OS_X_FRAMEWORKS
+#ifdef HAVE_MACOS_FRAMEWORKS
#include <CoreFoundation/CoreFoundation.h>
#include <wsutil/cfutils.h>
#endif
/*
* Handles the rather elaborate process of getting OS version information
- * from OS X (we want the OS X version, not the Darwin version, the latter
+ * from macOS (we want the macOS version, not the Darwin version, the latter
* being easy to get with uname()).
*/
-#ifdef HAVE_OS_X_FRAMEWORKS
+#ifdef HAVE_MACOS_FRAMEWORKS
/*
* Fetch a string, as a UTF-8 C string, from a dictionary, given a key.
}
/*
- * Get the OS X version information, and append it to the GString.
+ * Get the macOS version information, and append it to the GString.
* Return TRUE if we succeed, FALSE if we fail.
+ *
+ * XXX - this gives the OS name as "Mac OS X" even if Apple called/calls
+ * it "OS X" or "macOS".
*/
static gboolean
-get_os_x_version_info(GString *str)
+get_macos_version_info(GString *str)
{
static const UInt8 server_version_plist_path[] =
"/System/Library/CoreServices/ServerVersion.plist";
char *string;
/*
- * On OS X, report the OS X version number as the OS, and put
+ * On macOS, report the macOS version number as the OS, and put
* the Darwin information in parentheses.
*
* Alas, Gestalt() is deprecated in Mountain Lion, so the build
get_os_version_info(GString *str)
{
#if defined(_WIN32)
+ HMODULE kernel_dll_handle;
OSVERSIONINFOEX info;
SYSTEM_INFO system_info;
nativesi_func_ptr nativesi_func;
memset(&system_info, '\0', sizeof system_info);
/* Look for and use the GetNativeSystemInfo() function if available to get the correct processor
* architecture even when running 32-bit Wireshark in WOW64 (x86 emulation on 64-bit Windows) */
- nativesi_func = (nativesi_func_ptr)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetNativeSystemInfo");
+ kernel_dll_handle = GetModuleHandle(_T("kernel32.dll"));
+ if (kernel_dll_handle == NULL) {
+ /*
+ * XXX - get the failure reason.
+ */
+ g_string_append(str, "unknown Windows version");
+ return;
+ }
+ nativesi_func = (nativesi_func_ptr)GetProcAddress(kernel_dll_handle, "GetNativeSystemInfo");
if(nativesi_func)
nativesi_func(&system_info);
else
case 3:
g_string_append_printf(str, is_nt_workstation ? "Windows 8.1" : "Windows Server 2012 R2");
break;
- case 4:
- g_string_append_printf(str, is_nt_workstation ? "Windows 10" : "Windows Server 10");
- break;
default:
g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
info.dwMajorVersion, info.dwMinorVersion);
}
break;
} /* case 6 */
+
+ case 10: {
+ gboolean is_nt_workstation;
+
+ if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
+ g_string_append(str, "64-bit ");
+ else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
+ g_string_append(str, "32-bit ");
+ is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
+ switch (info.dwMinorVersion) {
+ case 0:
+ g_string_append_printf(str, is_nt_workstation ? "Windows 10" : "Windows Server 2016");
+ break;
+ default:
+ g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
+ info.dwMajorVersion, info.dwMinorVersion);
+ break;
+ }
+ break;
+ } /* case 10 */
+
default:
g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
info.dwMajorVersion, info.dwMinorVersion);
* On Solaris, it's some kind of build information.
* On HP-UX, it appears to be some sort of subrevision
* thing.
- * On *BSD and Darwin/OS X, it's a long string giving
+ * On *BSD and Darwin/macOS, it's a long string giving
* a build date, config file name, etc., etc., etc..
*/
-#ifdef HAVE_OS_X_FRAMEWORKS
+#ifdef HAVE_MACOS_FRAMEWORKS
/*
- * On Mac OS X, report the Mac OS X version number as
- * the OS version if we can, and put the Darwin information
+ * On macOS, report the macOS version number as the OS
+ * version if we can, and put the Darwin information
* in parentheses.
*/
- if (get_os_x_version_info(str)) {
+ if (get_macos_version_info(str)) {
/* Success - append the Darwin information. */
g_string_append_printf(str, " (%s %s)", name.sysname, name.release);
} else {
/* Failure - just use the Darwin information. */
g_string_append_printf(str, "%s %s", name.sysname, name.release);
}
-#else /* HAVE_OS_X_FRAMEWORKS */
+#else /* HAVE_MACOS_FRAMEWORKS */
/*
* XXX - on Linux, are there any APIs to get the distribution
* name and version number? I think some distributions have
* releases.
*/
g_string_append_printf(str, "%s %s", name.sysname, name.release);
-#endif /* HAVE_OS_X_FRAMEWORKS */
+#endif /* HAVE_MACOS_FRAMEWORKS */
}
#else
g_string_append(str, "an unknown OS");