dxdiagn: Do fill DMI information on Linux
Ruslan Kabatsayev
b7.10110111 at gmail.com
Sun Aug 28 04:50:36 CDT 2016
This patch makes previously empty fields szSystemManufacturerEnglish,
szSystemManufacturerEnglish and szBIOSEnglish in DxDiag filled with the
DMI information. This is the same information I get on my test Windows
system.
Currently this is only implemented for Linux, on other platforms
the fields remain empty.
Signed-off-by: Ruslan Kabatsayev <b7.10110111 at gmail.com>
---
dlls/dxdiagn/provider.c | 74 +++++++++++++++++++++++++++++++++++++++--------
1 file changed, 62 insertions(+), 12 deletions(-)
diff --git a/dlls/dxdiagn/provider.c b/dlls/dxdiagn/provider.c
index 5665d01..2ecb1d4 100644
--- a/dlls/dxdiagn/provider.c
+++ b/dlls/dxdiagn/provider.c
@@ -21,6 +21,7 @@
*/
#include "config.h"
+#include <stdio.h>
#define COBJMACROS
#define NONAMELESSUNION
@@ -464,6 +465,66 @@ static BOOL is_netmeeting_running(void)
return FALSE;
}
+#ifdef __linux__
+void read_sys_file(const char* path, WCHAR* output, size_t output_len)
+{
+ char *buf_utf8;
+ FILE *file = fopen(path, "r");
+ if(!file)
+ {
+ output[0] = 0;
+ return;
+ }
+ buf_utf8 = malloc(output_len);
+ if(fread(buf_utf8, 1, output_len-1, file))
+ {
+ const int len = strlen(buf_utf8);
+ if(buf_utf8[len-1] == '\n')
+ buf_utf8[len-1] = 0;
+ MultiByteToWideChar(CP_UTF8, 0, buf_utf8, -1, output, output_len);
+ }
+ free(buf_utf8);
+ fclose(file);
+}
+#endif
+
+static HRESULT fill_dmi_information(IDxDiagContainerImpl_Container *node)
+{
+ static const WCHAR szSystemManufacturerEnglish[] = {'s','z','S','y','s','t','e','m','M','a','n','u','f','a','c','t','u','r','e','r','E','n','g','l','i','s','h',0};
+ static const WCHAR szSystemModelEnglish[] = {'s','z','S','y','s','t','e','m','M','o','d','e','l','E','n','g','l','i','s','h',0};
+ static const WCHAR szBIOSEnglish[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
+ HRESULT hr;
+ enum { buf_len = 128 };
+ WCHAR sys_model_english[buf_len];
+ WCHAR sys_manufacturer[buf_len];
+ WCHAR sys_bios_english[buf_len];
+#ifdef __linux__
+ WCHAR bios_date[buf_len], bios_version[buf_len];
+ static const WCHAR bios_string_format[] = {'B','I','O','S',' ','D','a','t','e',':',' ','%','s',' ','V','e','r',':',' ','%','s',0};
+ read_sys_file("/sys/class/dmi/id/product_name", sys_model_english, buf_len);
+ read_sys_file("/sys/class/dmi/id/sys_vendor", sys_manufacturer, buf_len);
+ read_sys_file("/sys/class/dmi/id/bios_date", bios_date, buf_len);
+ read_sys_file("/sys/class/dmi/id/bios_version", bios_version, buf_len);
+ snprintfW(sys_bios_english, buf_len, bios_string_format, bios_date, bios_version);
+#else
+ /* Not supported, fill the properties with empty strings */
+ sys_manufacturer[0] = 0;
+ sys_model_english[0] = 0;
+ sys_bios_english[0] = 0;
+#endif
+
+ hr = add_bstr_property(node, szSystemManufacturerEnglish, sys_manufacturer);
+ if(FAILED(hr))
+ return hr;
+ hr = add_bstr_property(node, szSystemModelEnglish, sys_model_english);
+ if(FAILED(hr))
+ return hr;
+ hr = add_bstr_property(node, szBIOSEnglish, sys_bios_english);
+ if(FAILED(hr))
+ return hr;
+ return S_OK;
+}
+
static HRESULT fill_language_information(IDxDiagContainerImpl_Container *node)
{
static const WCHAR regional_setting_engW[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
@@ -666,9 +727,6 @@ static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node)
static const WCHAR szPageFileEnglish[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
static const WCHAR szMachineNameLocalized[] = {'s','z','M','a','c','h','i','n','e','N','a','m','e','L','o','c','a','l','i','z','e','d',0};
static const WCHAR szMachineNameEnglish[] = {'s','z','M','a','c','h','i','n','e','N','a','m','e','E','n','g','l','i','s','h',0};
- static const WCHAR szSystemManufacturerEnglish[] = {'s','z','S','y','s','t','e','m','M','a','n','u','f','a','c','t','u','r','e','r','E','n','g','l','i','s','h',0};
- static const WCHAR szSystemModelEnglish[] = {'s','z','S','y','s','t','e','m','M','o','d','e','l','E','n','g','l','i','s','h',0};
- static const WCHAR szBIOSEnglish[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
static const WCHAR szSetupParamEnglish[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
@@ -797,15 +855,7 @@ static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node)
if (FAILED(hr))
return hr;
- hr = add_bstr_property(node, szSystemManufacturerEnglish, szEmpty);
- if (FAILED(hr))
- return hr;
-
- hr = add_bstr_property(node, szSystemModelEnglish, szEmpty);
- if (FAILED(hr))
- return hr;
-
- hr = add_bstr_property(node, szBIOSEnglish, szEmpty);
+ hr = fill_dmi_information(node);
if (FAILED(hr))
return hr;
--
1.7.10.2
More information about the wine-patches
mailing list