From: Stanislav Motylkov Date: Tue, 31 Jul 2018 15:52:09 +0000 (+0300) Subject: [DXDIAG] Fix blank system and BIOS values X-Git-Tag: 0.4.11-dev~169 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=50b0332438d11104e3f7c0436734614f7ef4b675 [DXDIAG] Fix blank system and BIOS values CORE-5961 #resolve --- diff --git a/base/applications/dxdiag/CMakeLists.txt b/base/applications/dxdiag/CMakeLists.txt index fbcaff538ea..a299f85160c 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 5ad492584f2..4e16e04db45 100644 --- a/base/applications/dxdiag/precomp.h +++ b/base/applications/dxdiag/precomp.h @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "resource.h" diff --git a/base/applications/dxdiag/system.c b/base/applications/dxdiag/system.c index b6686a515d6..849a7a5d4e1 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);