2011-06-14 15:01:51 +02:00
|
|
|
/*
|
|
|
|
* DxDiag information collection
|
|
|
|
*
|
|
|
|
* Copyright 2011 Andrew Nguyen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-06-14 15:02:05 +02:00
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <dxdiag.h>
|
|
|
|
|
2011-06-14 15:01:51 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dxdiag_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
|
|
|
|
|
2011-06-15 14:11:11 +02:00
|
|
|
struct property_list
|
|
|
|
{
|
|
|
|
const WCHAR *property_name;
|
|
|
|
WCHAR **output;
|
|
|
|
};
|
|
|
|
|
2011-06-14 15:02:05 +02:00
|
|
|
static BOOL property_to_string(IDxDiagContainer *container, const WCHAR *property, WCHAR **output)
|
|
|
|
{
|
|
|
|
VARIANT var;
|
|
|
|
HRESULT hr;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
VariantInit(&var);
|
|
|
|
|
|
|
|
hr = IDxDiagContainer_GetProp(container, property, &var);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (V_VT(&var) == VT_BSTR)
|
|
|
|
{
|
|
|
|
WCHAR *bstr = V_BSTR(&var);
|
|
|
|
|
2019-04-29 11:52:43 +02:00
|
|
|
*output = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(bstr) + 1) * sizeof(WCHAR));
|
2011-06-14 15:02:05 +02:00
|
|
|
if (*output)
|
|
|
|
{
|
2019-04-29 11:52:43 +02:00
|
|
|
lstrcpyW(*output, bstr);
|
2011-06-14 15:02:05 +02:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VariantClear(&var);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_system_information(struct dxdiag_information *dxdiag_info)
|
|
|
|
{
|
|
|
|
struct system_information *system_info = &dxdiag_info->system_info;
|
2011-06-15 14:11:11 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szTimeEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szTimeLocalized);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szMachineNameEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szOSExLongEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szOSExLocalized);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szLanguagesEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szLanguagesLocalized);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szSystemManufacturerEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szSystemModelEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szBIOSEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szProcessorEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szPhysicalMemoryEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szPageFileEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szPageFileLocalized);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szWindowsDir);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szDirectXVersionLongEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szSetupParamEnglish);
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info->szDxDiagVersion);
|
2011-06-14 15:02:05 +02:00
|
|
|
}
|
|
|
|
|
2011-06-15 14:11:11 +02:00
|
|
|
static inline void fill_system_property_list(struct dxdiag_information *dxdiag_info, struct property_list *list)
|
2011-06-14 15:02:05 +02:00
|
|
|
{
|
2011-06-15 14:11:11 +02:00
|
|
|
struct system_information *system_info = &dxdiag_info->system_info;
|
2011-06-14 15:02:05 +02:00
|
|
|
|
2020-10-05 23:22:50 +02:00
|
|
|
list[0].property_name = L"szTimeEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[0].output = &system_info->szTimeEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[1].property_name = L"szTimeLocalized";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[1].output = &system_info->szTimeLocalized;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[2].property_name = L"szMachineNameEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[2].output = &system_info->szMachineNameEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[3].property_name = L"szOSExLongEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[3].output = &system_info->szOSExLongEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[4].property_name = L"szOSExLocalized";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[4].output = &system_info->szOSExLocalized;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[5].property_name = L"szLanguagesEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[5].output = &system_info->szLanguagesEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[6].property_name = L"szLanguagesLocalized";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[6].output = &system_info->szLanguagesLocalized;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[7].property_name = L"szSystemManufacturerEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[7].output = &system_info->szSystemManufacturerEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[8].property_name = L"szSystemModelEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[8].output = &system_info->szSystemModelEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[9].property_name = L"szBIOSEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[9].output = &system_info->szBIOSEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[10].property_name = L"szProcessorEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[10].output = &system_info->szProcessorEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[11].property_name = L"szPhysicalMemoryEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[11].output = &system_info->szPhysicalMemoryEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[12].property_name = L"szPageFileEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[12].output = &system_info->szPageFileEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[13].property_name = L"szPageFileLocalized";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[13].output = &system_info->szPageFileLocalized;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[14].property_name = L"szWindowsDir";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[14].output = &system_info->szWindowsDir;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[15].property_name = L"szDirectXVersionLongEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[15].output = &system_info->szDirectXVersionLongEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[16].property_name = L"szSetupParamEnglish";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[16].output = &system_info->szSetupParamEnglish;
|
2020-10-05 23:22:50 +02:00
|
|
|
list[17].property_name = L"szDxDiagVersion";
|
2011-06-15 14:11:11 +02:00
|
|
|
list[17].output = &system_info->szDxDiagVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL fill_system_information(IDxDiagContainer *container, struct dxdiag_information *dxdiag_info)
|
|
|
|
{
|
2011-06-14 15:02:05 +02:00
|
|
|
struct system_information *system_info = &dxdiag_info->system_info;
|
|
|
|
size_t i;
|
2011-06-15 14:11:11 +02:00
|
|
|
struct property_list property_list[18];
|
|
|
|
|
|
|
|
fill_system_property_list(dxdiag_info, property_list);
|
2011-06-14 15:02:05 +02:00
|
|
|
|
2018-08-21 23:10:19 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(property_list); i++)
|
2011-06-14 15:02:05 +02:00
|
|
|
{
|
|
|
|
if (!property_to_string(container, property_list[i].property_name, property_list[i].output))
|
|
|
|
{
|
|
|
|
WINE_ERR("Failed to retrieve property %s\n", wine_dbgstr_w(property_list[i].property_name));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
system_info->win64 = TRUE;
|
|
|
|
#else
|
|
|
|
system_info->win64 = FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct information_fillers
|
|
|
|
{
|
|
|
|
const WCHAR *child_container_name;
|
|
|
|
BOOL (*fill_function)(IDxDiagContainer *, struct dxdiag_information *);
|
|
|
|
void (*free_function)(struct dxdiag_information *);
|
|
|
|
} filler_list[] =
|
|
|
|
{
|
2020-10-05 23:22:50 +02:00
|
|
|
{L"DxDiag_SystemInfo", fill_system_information, free_system_information},
|
2011-06-14 15:02:05 +02:00
|
|
|
};
|
|
|
|
|
2011-06-14 15:01:51 +02:00
|
|
|
void free_dxdiag_information(struct dxdiag_information *system_info)
|
|
|
|
{
|
2011-06-14 15:02:05 +02:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (!system_info)
|
|
|
|
return;
|
|
|
|
|
2018-08-21 23:10:19 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(filler_list); i++)
|
2011-06-14 15:02:05 +02:00
|
|
|
filler_list[i].free_function(system_info);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, system_info);
|
2011-06-14 15:01:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct dxdiag_information *collect_dxdiag_information(BOOL whql_check)
|
|
|
|
{
|
2011-06-14 15:02:05 +02:00
|
|
|
IDxDiagProvider *pddp = NULL;
|
|
|
|
IDxDiagContainer *root = NULL;
|
|
|
|
struct dxdiag_information *ret = NULL;
|
2011-06-15 14:11:11 +02:00
|
|
|
DXDIAG_INIT_PARAMS params = {sizeof(DXDIAG_INIT_PARAMS), DXDIAG_DX9_SDK_VERSION};
|
2011-06-14 15:02:05 +02:00
|
|
|
HRESULT hr;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/* Initialize the DxDiag COM instances. */
|
|
|
|
hr = CoCreateInstance(&CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IDxDiagProvider, (void **)&pddp);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2022-02-04 09:56:19 +01:00
|
|
|
WINE_ERR("IDxDiagProvider instance creation failed with 0x%08lx\n", hr);
|
2011-06-14 15:02:05 +02:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:11:11 +02:00
|
|
|
params.bAllowWHQLChecks = whql_check;
|
2011-06-14 15:02:05 +02:00
|
|
|
hr = IDxDiagProvider_Initialize(pddp, ¶ms);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
hr = IDxDiagProvider_GetRootContainer(pddp, &root);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
|
|
|
|
if (!ret)
|
|
|
|
goto error;
|
|
|
|
|
2018-08-21 23:10:19 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(filler_list); i++)
|
2011-06-14 15:02:05 +02:00
|
|
|
{
|
|
|
|
IDxDiagContainer *child;
|
|
|
|
BOOL success;
|
|
|
|
|
|
|
|
hr = IDxDiagContainer_GetChildContainer(root, filler_list[i].child_container_name, &child);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
success = filler_list[i].fill_function(child, ret);
|
|
|
|
IDxDiagContainer_Release(child);
|
|
|
|
if (!success)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDxDiagContainer_Release(root);
|
|
|
|
IDxDiagProvider_Release(pddp);
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
error:
|
|
|
|
free_dxdiag_information(ret);
|
|
|
|
if (root) IDxDiagContainer_Release(root);
|
|
|
|
if (pddp) IDxDiagProvider_Release(pddp);
|
2011-06-14 15:01:51 +02:00
|
|
|
return NULL;
|
|
|
|
}
|