1 /*
2 * Copyright (c) 2010-2014 Colin Harrison All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 *
22 * Except as contained in this notice, the name(s) of the above copyright
23 * holders shall not be used in advertising or otherwise to promote the sale,
24 * use or other dealings in this Software without prior written authorization.
25 *
26 * Author: Colin Harrison
27 */
28
29 #ifdef HAVE_XWIN_CONFIG_H
30 #include <xwin-config.h>
31 #endif
32 #include "win.h"
33
34 typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
35
36 static const char*
IsWow64(void)37 IsWow64(void)
38 {
39 #ifdef __x86_64__
40 return " (64-bit)";
41 #else
42 WINBOOL bIsWow64;
43 LPFN_ISWOW64PROCESS fnIsWow64Process =
44 (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")),
45 "IsWow64Process");
46 if (NULL != fnIsWow64Process) {
47 if (fnIsWow64Process(GetCurrentProcess(), &bIsWow64))
48 return bIsWow64 ? " (WoW64)" : " (32-bit)";
49 }
50
51 /* OS doesn't support IsWow64Process() */
52 return "";
53 #endif
54 }
55
56 /*
57 * Report the OS version
58 */
59
60 void
winOS(void)61 winOS(void)
62 {
63 OSVERSIONINFOEX osvi = {0};
64
65 /* Get operating system version information */
66 osvi.dwOSVersionInfoSize = sizeof(osvi);
67 GetVersionEx((LPOSVERSIONINFO)&osvi);
68
69 ErrorF("OS: Windows NT %d.%d build %d%s\n",
70 (int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion,
71 (int)osvi.dwBuildNumber, IsWow64());
72 }
73