ReactOS 0.4.15-dev-7934-g1dc8d80
system.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactX Diagnosis Application
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/dxdiag/system.c
5 * PURPOSE: ReactX diagnosis system page
6 * COPYRIGHT: Copyright 2008 Johannes Anderwald
7 *
8 */
9
10#include "precomp.h"
11
13
14BOOL
16{
17 HKEY hKey;
18 LONG res;
19 DWORD dwType;
21
22 if (RegOpenKeyExW(hBaseKey, SubKey, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
23 return FALSE;
24
25 dwSize = Size;
28
29 if (res != ERROR_SUCCESS)
30 return FALSE;
31
32 if (dwType != Type)
33 return FALSE;
34
35 if (Size == sizeof(DWORD))
36 return TRUE;
37
38 Result[(Size / sizeof(WCHAR))-1] = L'\0';
39 return TRUE;
40}
41
42
43static
44BOOL
46{
47 WCHAR szVer[20];
48
49 if (!GetRegValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\DirectX", L"Version", REG_SZ, szVer, sizeof(szVer)))
50 return FALSE;
51
52 if(!wcscmp(szVer, L"4.02.0095"))
53 wcscpy(szBuffer, L"1.0");
54 else if (!wcscmp(szVer, L"4.03.00.1096"))
55 wcscpy(szBuffer, L"2.0");
56 else if (!wcscmp(szVer, L"4.04.0068"))
57 wcscpy(szBuffer, L"3.0");
58 else if (!wcscmp(szVer, L"4.04.0069"))
59 wcscpy(szBuffer, L"3.0");
60 else if (!wcscmp(szVer, L"4.05.00.0155"))
61 wcscpy(szBuffer, L"5.0");
62 else if (!wcscmp(szVer, L"4.05.01.1721"))
63 wcscpy(szBuffer, L"5.0");
64 else if (!wcscmp(szVer, L"4.05.01.1998"))
65 wcscpy(szBuffer, L"5.0");
66 else if (!wcscmp(szVer, L"4.06.02.0436"))
67 wcscpy(szBuffer, L"6.0");
68 else if (!wcscmp(szVer, L"4.07.00.0700"))
69 wcscpy(szBuffer, L"7.0");
70 else if (!wcscmp(szVer, L"4.07.00.0716"))
71 wcscpy(szBuffer, L"7.0a");
72 else if (!wcscmp(szVer, L"4.08.00.0400"))
73 wcscpy(szBuffer, L"8.0");
74 else if (!wcscmp(szVer, L"4.08.01.0881"))
75 wcscpy(szBuffer, L"8.1");
76 else if (!wcscmp(szVer, L"4.08.01.0810"))
77 wcscpy(szBuffer, L"8.1");
78 else if (!wcscmp(szVer, L"4.09.0000.0900"))
79 wcscpy(szBuffer, L"9.0");
80 else if (!wcscmp(szVer, L"4.09.00.0900"))
81 wcscpy(szBuffer, L"9.0");
82 else if (!wcscmp(szVer, L"4.09.0000.0901"))
83 wcscpy(szBuffer, L"9.0a");
84 else if (!wcscmp(szVer, L"4.09.00.0901"))
85 wcscpy(szBuffer, L"9.0a");
86 else if (!wcscmp(szVer, L"4.09.0000.0902"))
87 wcscpy(szBuffer, L"9.0b");
88 else if (!wcscmp(szVer, L"4.09.00.0902"))
89 wcscpy(szBuffer, L"9.0b");
90 else if (!wcscmp(szVer, L"4.09.00.0904"))
91 wcscpy(szBuffer, L"9.0c");
92 else if (!wcscmp(szVer, L"4.09.0000.0904"))
93 wcscpy(szBuffer, L"9.0c");
94 else
95 return FALSE;
96
97 return TRUE;
98}
99
101{
102 SYSTEM_INFO archInfo;
103 ISWOW64PROC fnIsWow64Process;
104 BOOL isWow64 = FALSE;
105
106 /* Find out if the program is running through WOW64 or not. Apparently,
107 IsWow64Process() is not available on all versions of Windows, so the function
108 has to be imported at runtime. If the function cannot be found, then assume
109 the program is not running in WOW64. */
110 fnIsWow64Process = (ISWOW64PROC)GetProcAddress(
111 GetModuleHandleW(L"kernel32"), "IsWow64Process");
112
113 if (fnIsWow64Process != NULL)
114 fnIsWow64Process(GetCurrentProcess(), &isWow64);
115
116 /* If the program is compiled as 32-bit, but is running in WOW64, it will
117 automatically report as 32-bit regardless of the actual system architecture.
118 It detects whether or not the program is using WOW64 or not, and then
119 uses GetNativeSystemInfo(). If it is, it will properly report the actual
120 system architecture to the user. */
121 if (isWow64)
122 GetNativeSystemInfo(&archInfo);
123 else
124 GetSystemInfo(&archInfo);
125
126 /* Now check to see what the system architecture is */
128 {
129 switch(archInfo.wProcessorArchitecture)
130 {
132 {
133 wsprintfW(szBuffer, L"32-bit");
134 break;
135 }
137 {
138 wsprintfW(szBuffer, L"64-bit");
139 break;
140 }
142 {
143 wsprintfW(szBuffer, L"Itanium");
144 break;
145 }
147 {
148 wsprintfW(szBuffer, L"ARM");
149 break;
150 }
151 default:break;
152 }
153 }
154}
155
156static
157SIZE_T
159 BOOL UseSMBios,
160 PCHAR DmiString,
161 LPWSTR RegValue,
162 PVOID pBuf,
163 DWORD cchBuf,
164 BOOL bTrim)
165{
166 SIZE_T Length = 0;
167 BOOL Result;
168
169 if (UseSMBios)
170 {
171 Length = GetSMBiosStringW(DmiString, pBuf, cchBuf, bTrim);
172 }
173 if (Length == 0)
174 {
175 Result = GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\BIOS", RegValue, REG_SZ, pBuf, cchBuf * sizeof(WCHAR));
176 if (Result)
177 {
178 Length = wcslen(pBuf);
179 }
180 }
181 return Length;
182}
183
184static
185VOID
187{
188 WCHAR szTime[200];
189 WCHAR szOSName[50];
191 DWORDLONG AvailableBytes, UsedBytes;
192 MEMORYSTATUSEX mem;
193 WCHAR szFormat[50];
194 WCHAR szDesc[50];
195 SYSTEM_INFO SysInfo;
197 PVOID SMBiosBuf;
198 PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
199 BOOL Result;
200
201 /* set date/time */
202 szTime[0] = L'\0';
204 if (Length)
205 {
206 szTime[Length-1] = L',';
207 szTime[Length++] = L' ';
208 }
210 szTime[_countof(szTime)-1] = L'\0';
212
213 /* set computer name */
214 szTime[0] = L'\0';
218
219 /* set product name */
220 if (GetRegValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName", REG_SZ, szOSName, sizeof(szOSName)))
221 {
222 if (LoadStringW(hInst, IDS_OS_VERSION, szFormat, _countof(szFormat)))
223 {
224 WCHAR szCpuName[50];
225
228
229 GetSystemCPU(szCpuName);
230
232 {
233 szTime[_countof(szTime)-1] = L'\0';
236 }
237 else
238 {
239 /* If the version of the OS cannot be retrieved for some reason, then just give the OS Name and Architecture */
240 szTime[_countof(szTime)-1] = L'\0';
241 wsprintfW(szTime, L"%s %s", szOSName, szCpuName);
243 }
244 }
245 }
246 else
247 {
249 {
250 szTime[_countof(szTime)-1] = L'\0';
252 }
253 }
254
255 /* FIXME set product language/local language */
258
259 /* prepare SMBIOS data */
260 SMBiosBuf = LoadSMBiosData(DmiStrings);
261
262 /* set system manufacturer */
263 szTime[0] = L'\0';
264 Length = GetBIOSValue(SMBiosBuf != NULL,
265 DmiStrings[SYS_VENDOR],
266 L"SystemManufacturer",
268 if (Length > 0)
269 {
270 szTime[_countof(szTime)-1] = L'\0';
272 }
273
274 /* set motherboard model */
275 szTime[0] = L'\0';
276 Length = GetBIOSValue(SMBiosBuf != NULL,
277 DmiStrings[SYS_PRODUCT],
278 L"SystemProductName",
280 if (Length > 0)
281 {
283 }
284
285 /* set bios model */
286 szTime[0] = L'\0';
287 Length = GetBIOSValue(SMBiosBuf != NULL,
288 DmiStrings[BIOS_VENDOR],
289 L"BIOSVendor",
291 if (Length > 0)
292 {
293 DWORD Index;
294 DWORD StrLength = _countof(szTime);
295
297 if (Index + 1 < _countof(szTime))
298 {
299 szTime[Index++] = L' ';
300 szTime[Index] = L'\0';
301 }
302 StrLength -= Index;
303
304 Length = GetBIOSValue(SMBiosBuf != NULL,
305 DmiStrings[BIOS_DATE],
306 L"BIOSReleaseDate",
307 szTime + Index, StrLength, TRUE);
308 if (Length > 0)
309 {
310 if (Index + StrLength > _countof(szTime) - 15)
311 {
312 //FIXME retrieve BiosMajorRelease, BiosMinorRelease
313 //StrLength = wcslen(szTime + Index);
314 //szTime[Index+StrLength] = L' ';
315 //wcscpy(szTime + Index + StrLength, L"Ver: "); //FIXME NON-NLS
316 //szTime[_countof(szTime)-1] = L'\0';
317 }
319 }
320 }
321
322 /* clean SMBIOS data */
323 FreeSMBiosData(SMBiosBuf);
324
325 /* set processor string */
326 Result = GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\CentralProcessor\\0", L"ProcessorNameString", REG_SZ, szDesc, sizeof(szDesc));
327 if (!Result)
328 {
329 /* Processor Brand String not found */
330 /* FIXME: Implement CPU name detection routine */
331
332 /* Finally try to use Identifier string */
333 Result = GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\\Description\\System\\CentralProcessor\\0", L"Identifier", REG_SZ, szDesc, sizeof(szDesc));
334 }
335 if (Result)
336 {
337 TrimDmiStringW(szDesc);
338 /* FIXME retrieve current speed */
339 szFormat[0] = L'\0';
340 GetSystemInfo(&SysInfo);
341 if (SysInfo.dwNumberOfProcessors > 1)
342 LoadStringW(hInst, IDS_FORMAT_MPPROC, szFormat, _countof(szFormat));
343 else
344 LoadStringW(hInst, IDS_FORMAT_UNIPROC, szFormat, _countof(szFormat));
345
346 szFormat[_countof(szFormat)-1] = L'\0';
347 wsprintfW(szTime, szFormat, szDesc, SysInfo.dwNumberOfProcessors);
349 }
350
351 /* retrieve available memory */
352 ZeroMemory(&mem, sizeof(mem));
353 mem.dwLength = sizeof(mem);
355 {
356 if (LoadStringW(hInst, IDS_FORMAT_MB, szFormat, _countof(szFormat)))
357 {
358 /* set total mem string */
359 szFormat[_countof(szFormat)-1] = L'\0';
360 wsprintfW(szTime, szFormat, (mem.ullTotalPhys/1048576));
362 }
363
364 if (LoadStringW(hInst, IDS_FORMAT_SWAP, szFormat, _countof(szFormat)))
365 {
366 /* set swap string */
367 AvailableBytes = (mem.ullTotalPageFile-mem.ullTotalPhys)/1048576;
368 UsedBytes = (mem.ullTotalPageFile-mem.ullAvailPageFile)/1048576;
369
370 szFormat[_countof(szFormat)-1] = L'\0';
371 wsprintfW(szTime, szFormat, (UsedBytes), (AvailableBytes));
373 }
374 }
375 /* set directx version string */
376 wcscpy(szTime, L"ReactX ");
377 if (GetDirectXVersion(szTime + 7))
378 {
380 }
381 else
382 {
384 {
385 szTime[_countof(szTime)-1] = L'\0';
387 }
388 }
389}
390
391
394{
397 switch (message)
398 {
399 case WM_INITDIALOG:
400 {
403 return TRUE;
404 }
405 }
406
407 return FALSE;
408}
Type
Definition: Type.h:7
#define IDS_VERSION_UNKNOWN
Definition: resource.h:115
#define IDC_STATIC_COMPUTER
Definition: resource.h:24
#define IDC_STATIC_SWAP
Definition: resource.h:32
#define IDC_STATIC_PROC
Definition: resource.h:30
#define IDC_STATIC_MEM
Definition: resource.h:31
#define IDS_FORMAT_MPPROC
Definition: resource.h:114
#define IDS_FORMAT_SWAP
Definition: resource.h:112
#define IDS_FORMAT_MB
Definition: resource.h:111
#define IDC_STATIC_MODEL
Definition: resource.h:28
#define IDC_STATIC_BIOS
Definition: resource.h:29
#define IDC_STATIC_OS
Definition: resource.h:25
#define IDC_STATIC_MANU
Definition: resource.h:27
#define IDC_STATIC_VERSION
Definition: resource.h:33
#define IDS_FORMAT_UNIPROC
Definition: resource.h:113
#define IDC_STATIC_LANG
Definition: resource.h:26
#define IDC_STATIC_TIME
Definition: resource.h:23
#define IDS_OS_VERSION
Definition: resource.h:155
static SIZE_T GetBIOSValue(BOOL UseSMBios, PCHAR DmiString, LPWSTR RegValue, PVOID pBuf, DWORD cchBuf, BOOL bTrim)
Definition: system.c:158
BOOL(WINAPI * ISWOW64PROC)(HANDLE, PBOOL)
Definition: system.c:12
static BOOL GetDirectXVersion(WCHAR *szBuffer)
Definition: system.c:45
INT_PTR CALLBACK SystemPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: system.c:393
static VOID InitializeSystemPage(HWND hwndDlg)
Definition: system.c:186
BOOL GetRegValue(HKEY hBaseKey, LPWSTR SubKey, LPWSTR ValueName, DWORD Type, LPWSTR Result, DWORD Size)
Definition: system.c:15
VOID GetSystemCPU(WCHAR *szBuffer)
Definition: system.c:100
OSVERSIONINFOW VersionInfo
Definition: wkssvc.c:40
#define RegCloseKey(hKey)
Definition: registry.h:49
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
#define GetProcAddress(x, y)
Definition: compat.h:753
#define GetCurrentProcess()
Definition: compat.h:759
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
VOID WINAPI GetNativeSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:207
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
@ SYS_PRODUCT
Definition: dmilib.h:17
@ ID_STRINGS_MAX
Definition: dmilib.h:28
@ BIOS_DATE
Definition: dmilib.h:15
@ SYS_VENDOR
Definition: dmilib.h:16
@ BIOS_VENDOR
Definition: dmilib.h:13
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLuint res
Definition: glext.h:9613
BOOL NTAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
Definition: heapmem.c:1272
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define REG_SZ
Definition: layer.c:22
INT WINAPI GetTimeFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpTimeStr, INT cchOut)
Definition: lcformat.c:1093
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
unsigned int UINT
Definition: ndis.h:50
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define PROCESSOR_ARCHITECTURE_ARM
Definition: ketypes.h:110
#define PROCESSOR_ARCHITECTURE_UNKNOWN
Definition: ketypes.h:115
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define PROCESSOR_ARCHITECTURE_INTEL
Definition: ketypes.h:105
#define BOOL
Definition: nt_native.h:43
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define LOCALE_SYSTEM_DEFAULT
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define _countof(array)
Definition: sndvol32.h:68
TCHAR szTime[64]
Definition: solitaire.cpp:20
ULONG dwMinorVersion
Definition: rtltypes.h:248
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:246
ULONG dwMajorVersion
Definition: rtltypes.h:247
ULONG dwBuildNumber
Definition: rtltypes.h:249
DWORD dwNumberOfProcessors
Definition: winbase.h:1177
WORD wProcessorArchitecture
Definition: winbase.h:1169
Definition: mem.c:156
Definition: tftpd.h:60
int32_t INT_PTR
Definition: typedefs.h:64
unsigned char * LPBYTE
Definition: typedefs.h:53
PVOID HANDLE
Definition: typedefs.h:73
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51
SIZE_T GetSMBiosStringW(_In_ PCSTR DmiString, _Out_ PWSTR pBuf, _In_ DWORD cchBuf, _In_ BOOL bTrim)
Definition: udmihelp.c:145
PVOID LoadSMBiosData(_Inout_updates_(ID_STRINGS_MAX) PCHAR *Strings)
Definition: udmihelp.c:30
VOID FreeSMBiosData(_In_ PVOID Buffer)
Definition: udmihelp.c:177
VOID TrimDmiStringW(_Inout_ PWSTR pStr)
Definition: udmihelp.c:110
TCHAR szOSName[50]
Definition: ver.c:29
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define ZeroMemory
Definition: winbase.h:1712
#define GetVersionEx
Definition: winbase.h:3852
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
BOOL * PBOOL
Definition: windef.h:161
#define WINAPI
Definition: msvc.h:6
#define GetLocaleInfo
Definition: winnls.h:1186
#define LOCALE_SLANGUAGE
Definition: winnls.h:26
#define LOCALE_NOUSEROVERRIDE
Definition: winnls.h:19
#define TIME_FORCE24HOURFORMAT
Definition: winnls.h:280
#define DATE_LONGDATE
Definition: winnls.h:197
#define GetDateFormat
Definition: winnls.h:1184
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define SWP_NOACTIVATE
Definition: winuser.h:1242
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOSIZE
Definition: winuser.h:1245
#define WM_INITDIALOG
Definition: winuser.h:1739
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SETTEXT
Definition: winuser.h:1617
#define SWP_NOOWNERZORDER
Definition: winuser.h:1249
#define SWP_NOZORDER
Definition: winuser.h:1247
#define SendDlgItemMessage
Definition: winuser.h:5842
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:293
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184