https://git.reactos.org/?p=reactos.git;a=commitdiff;h=50b0332438d11104e3f7c0...
commit 50b0332438d11104e3f7c0436734614f7ef4b675 Author: Stanislav Motylkov x86corez@gmail.com AuthorDate: Tue Jul 31 18:52:09 2018 +0300 Commit: Hermès BÉLUSCA - MAÏTO hermes.belusca-maito@reactos.org CommitDate: Sun Aug 12 14:21:56 2018 +0200
[DXDIAG] Fix blank system and BIOS values
CORE-5961 #resolve --- base/applications/dxdiag/CMakeLists.txt | 6 ++- base/applications/dxdiag/precomp.h | 2 + base/applications/dxdiag/system.c | 71 ++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 7 deletions(-)
diff --git a/base/applications/dxdiag/CMakeLists.txt b/base/applications/dxdiag/CMakeLists.txt index fbcaff538e..a299f85160 100644 --- a/base/applications/dxdiag/CMakeLists.txt +++ b/base/applications/dxdiag/CMakeLists.txt @@ -1,4 +1,8 @@
+include_directories( + ${REACTOS_SOURCE_DIR}/sdk/lib/udmihelp + ${REACTOS_SOURCE_DIR}/sdk/lib/dmilib) + list(APPEND SOURCE system.c display.c @@ -18,7 +22,7 @@ list(APPEND SOURCE add_rc_deps(dxdiag.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/dxdiag.ico) add_executable(dxdiag ${SOURCE} dxdiag.rc) set_module_type(dxdiag win32gui UNICODE) -target_link_libraries(dxdiag dxguid) +target_link_libraries(dxdiag dxguid udmihelp) add_importlibs(dxdiag user32 advapi32 comctl32 dinput8 setupapi dsound ddraw version gdi32 winmm d3d9 msvcrt kernel32 ntdll) add_pch(dxdiag precomp.h SOURCE) add_cd_file(TARGET dxdiag DESTINATION reactos/system32 FOR all) diff --git a/base/applications/dxdiag/precomp.h b/base/applications/dxdiag/precomp.h index 5ad492584f..4e16e04db4 100644 --- a/base/applications/dxdiag/precomp.h +++ b/base/applications/dxdiag/precomp.h @@ -22,6 +22,8 @@ #include <initguid.h> #include <devguid.h> #include <strsafe.h> +#include <udmihelp.h> +#include <dmilib.h>
#include "resource.h"
diff --git a/base/applications/dxdiag/system.c b/base/applications/dxdiag/system.c index b6686a515d..849a7a5d4e 100644 --- a/base/applications/dxdiag/system.c +++ b/base/applications/dxdiag/system.c @@ -153,6 +153,34 @@ VOID GetSystemCPU(WCHAR *szBuffer) } }
+static +SIZE_T +GetBIOSValue( + BOOL UseSMBios, + PCHAR DmiString, + LPWSTR RegValue, + PVOID pBuf, + DWORD cchBuf, + BOOL bTrim) +{ + SIZE_T Length = 0; + BOOL Result; + + if (UseSMBios) + { + Length = GetSMBiosStringW(DmiString, pBuf, cchBuf, bTrim); + } + if (Length == 0) + { + Result = GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\Description\System\BIOS", RegValue, REG_SZ, pBuf, cchBuf * sizeof(WCHAR)); + if (Result) + { + Length = wcslen(pBuf); + } + } + return Length; +} + static VOID InitializeSystemPage(HWND hwndDlg) @@ -162,10 +190,12 @@ InitializeSystemPage(HWND hwndDlg) DWORD Length; DWORDLONG AvailableBytes, UsedBytes; MEMORYSTATUSEX mem; - WCHAR szFormat[40]; + WCHAR szFormat[50]; WCHAR szDesc[50]; SYSTEM_INFO SysInfo; OSVERSIONINFO VersionInfo; + PVOID SMBiosBuf; + PCHAR DmiStrings[ID_STRINGS_MAX] = { 0 };
/* set date/time */ szTime[0] = L'\0'; @@ -225,9 +255,16 @@ InitializeSystemPage(HWND hwndDlg) if (GetLocaleInfo(LOCALE_SYSTEM_DEFAULT,LOCALE_SLANGUAGE , szTime, sizeof(szTime) / sizeof(WCHAR))) SendDlgItemMessageW(hwndDlg, IDC_STATIC_LANG, WM_SETTEXT, 0, (LPARAM)szTime);
+ /* prepare SMBIOS data */ + SMBiosBuf = LoadSMBiosData(DmiStrings); + /* set system manufacturer */ szTime[0] = L'\0'; - if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\Description\System\BIOS", L"SystemManufacturer", REG_SZ, szTime, sizeof(szTime))) + Length = GetBIOSValue(SMBiosBuf != NULL, + DmiStrings[SYS_VENDOR], + L"SystemManufacturer", + szTime, _countof(szTime), FALSE); + if (Length > 0) { szTime[199] = L'\0'; SendDlgItemMessageW(hwndDlg, IDC_STATIC_MANU, WM_SETTEXT, 0, (LPARAM)szTime); @@ -235,22 +272,39 @@ InitializeSystemPage(HWND hwndDlg)
/* set motherboard model */ szTime[0] = L'\0'; - if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\Description\System\BIOS", L"SystemProductName", REG_SZ, szTime, sizeof(szTime))) + Length = GetBIOSValue(SMBiosBuf != NULL, + DmiStrings[SYS_PRODUCT], + L"SystemProductName", + szTime, _countof(szTime), FALSE); + if (Length > 0) { SendDlgItemMessageW(hwndDlg, IDC_STATIC_MODEL, WM_SETTEXT, 0, (LPARAM)szTime); }
/* set bios model */ szTime[0] = L'\0'; - if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\Description\System\BIOS", L"BIOSVendor", REG_SZ, szTime, sizeof(szTime))) + Length = GetBIOSValue(SMBiosBuf != NULL, + DmiStrings[BIOS_VENDOR], + L"BIOSVendor", + szTime, _countof(szTime), TRUE); + if (Length > 0) { DWORD Index; - DWORD StrLength = (sizeof(szTime) / sizeof(WCHAR)); + DWORD StrLength = _countof(szTime);
Index = wcslen(szTime); + if (Index + 1 < _countof(szTime)) + { + szTime[Index++] = L' '; + szTime[Index] = L'\0'; + } StrLength -= Index;
- if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\Description\System\BIOS", L"BIOSReleaseDate", REG_SZ, &szTime[Index], StrLength)) + Length = GetBIOSValue(SMBiosBuf != NULL, + DmiStrings[BIOS_DATE], + L"BIOSReleaseDate", + szTime + Index, StrLength, TRUE); + if (Length > 0) { if (Index + StrLength > (sizeof(szTime)/sizeof(WCHAR))- 15) { @@ -263,9 +317,14 @@ InitializeSystemPage(HWND hwndDlg) SendDlgItemMessageW(hwndDlg, IDC_STATIC_BIOS, WM_SETTEXT, 0, (LPARAM)szTime); } } + + /* clean SMBIOS data */ + FreeSMBiosData(SMBiosBuf); + /* set processor string */ if (GetRegValue(HKEY_LOCAL_MACHINE, L"Hardware\Description\System\CentralProcessor\0", L"ProcessorNameString", REG_SZ, szDesc, sizeof(szDesc))) { + TrimDmiStringW(szDesc); /* FIXME retrieve current speed */ szFormat[0] = L'\0'; GetSystemInfo(&SysInfo);