2004-04-16 02:26:14 +02:00
|
|
|
/*
|
|
|
|
* IDxDiagProvider Implementation
|
|
|
|
*
|
2005-11-08 11:57:39 +01:00
|
|
|
* Copyright 2004-2005 Raphael Junqueira
|
2011-04-04 03:55:39 +02:00
|
|
|
* Copyright 2010 Andrew Nguyen
|
2004-04-16 02:26:14 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-16 02:26:14 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-11-08 11:57:39 +01:00
|
|
|
|
|
|
|
#define COBJMACROS
|
2007-07-31 18:59:43 +02:00
|
|
|
#define NONAMELESSUNION
|
2009-06-30 06:06:30 +02:00
|
|
|
#define NONAMELESSSTRUCT
|
2005-11-08 11:57:39 +01:00
|
|
|
#include "dxdiag_private.h"
|
|
|
|
#include "winver.h"
|
|
|
|
#include "objidl.h"
|
2012-10-28 20:54:53 +01:00
|
|
|
#include "uuids.h"
|
2005-11-08 11:57:39 +01:00
|
|
|
#include "vfw.h"
|
|
|
|
#include "mmddk.h"
|
2009-01-03 18:22:51 +01:00
|
|
|
#include "d3d9.h"
|
2009-06-30 06:06:30 +02:00
|
|
|
#include "strmif.h"
|
|
|
|
#include "initguid.h"
|
2018-06-26 16:05:33 +02:00
|
|
|
#include "wine/fil_data.h"
|
2011-04-04 03:55:39 +02:00
|
|
|
#include "psapi.h"
|
2012-08-31 15:59:22 +02:00
|
|
|
#include "wbemcli.h"
|
2020-11-12 17:37:48 +01:00
|
|
|
#include "dsound.h"
|
2004-04-16 02:26:14 +02:00
|
|
|
|
2007-07-31 18:59:43 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2004-04-16 02:26:14 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
static HRESULT build_information_tree(IDxDiagContainerImpl_Container **pinfo_root);
|
|
|
|
static void free_information_tree(IDxDiagContainerImpl_Container *node);
|
|
|
|
|
2011-08-10 23:58:23 +02:00
|
|
|
struct IDxDiagProviderImpl
|
|
|
|
{
|
|
|
|
IDxDiagProvider IDxDiagProvider_iface;
|
|
|
|
LONG ref;
|
|
|
|
BOOL init;
|
|
|
|
DXDIAG_INIT_PARAMS params;
|
|
|
|
IDxDiagContainerImpl_Container *info_root;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline IDxDiagProviderImpl *impl_from_IDxDiagProvider(IDxDiagProvider *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDxDiagProviderImpl, IDxDiagProvider_iface);
|
|
|
|
}
|
|
|
|
|
2004-04-16 02:26:14 +02:00
|
|
|
/* IDxDiagProvider IUnknown parts follow: */
|
2011-08-10 23:58:23 +02:00
|
|
|
static HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(IDxDiagProvider *iface, REFIID riid,
|
|
|
|
void **ppobj)
|
2004-04-16 02:26:14 +02:00
|
|
|
{
|
2011-08-10 23:58:23 +02:00
|
|
|
IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
|
2004-04-16 02:26:14 +02:00
|
|
|
|
2009-12-22 11:14:56 +01:00
|
|
|
if (!ppobj) return E_INVALIDARG;
|
|
|
|
|
2004-04-16 02:26:14 +02:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDxDiagProvider)) {
|
2006-06-10 11:58:14 +02:00
|
|
|
IUnknown_AddRef(iface);
|
2004-04-16 02:26:14 +02:00
|
|
|
*ppobj = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
|
2009-12-22 11:14:56 +01:00
|
|
|
*ppobj = NULL;
|
2004-04-16 02:26:14 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-08-10 23:58:23 +02:00
|
|
|
static ULONG WINAPI IDxDiagProviderImpl_AddRef(IDxDiagProvider *iface)
|
|
|
|
{
|
|
|
|
IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-06 23:01:04 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
2005-02-01 15:21:37 +01:00
|
|
|
DXDIAGN_LockModule();
|
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
2011-08-10 23:58:23 +02:00
|
|
|
static ULONG WINAPI IDxDiagProviderImpl_Release(IDxDiagProvider *iface)
|
|
|
|
{
|
|
|
|
IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-06 23:01:04 +02:00
|
|
|
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
|
|
|
if (!refCount) {
|
2011-02-15 08:14:09 +01:00
|
|
|
free_information_tree(This->info_root);
|
2004-04-16 02:26:14 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2005-02-01 15:21:37 +01:00
|
|
|
|
|
|
|
DXDIAGN_UnlockModule();
|
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDxDiagProvider Interface follow: */
|
2011-08-10 23:58:23 +02:00
|
|
|
static HRESULT WINAPI IDxDiagProviderImpl_Initialize(IDxDiagProvider *iface,
|
|
|
|
DXDIAG_INIT_PARAMS *pParams)
|
|
|
|
{
|
|
|
|
IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
|
2011-02-15 08:14:09 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2004-04-19 04:57:09 +02:00
|
|
|
TRACE("(%p,%p)\n", iface, pParams);
|
|
|
|
|
|
|
|
if (NULL == pParams) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2009-12-22 11:15:18 +01:00
|
|
|
if (pParams->dwSize != sizeof(DXDIAG_INIT_PARAMS) ||
|
|
|
|
pParams->dwDxDiagHeaderVersion != DXDIAG_DX9_SDK_VERSION) {
|
2004-04-19 04:57:09 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
if (!This->info_root)
|
|
|
|
{
|
|
|
|
hr = build_information_tree(&This->info_root);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2004-04-19 04:57:09 +02:00
|
|
|
This->init = TRUE;
|
|
|
|
memcpy(&This->params, pParams, pParams->dwSize);
|
|
|
|
return S_OK;
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
2011-08-10 23:58:23 +02:00
|
|
|
static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(IDxDiagProvider *iface,
|
|
|
|
IDxDiagContainer **ppInstance)
|
|
|
|
{
|
|
|
|
IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
|
2011-02-01 11:32:34 +01:00
|
|
|
|
2004-04-19 04:57:09 +02:00
|
|
|
TRACE("(%p,%p)\n", iface, ppInstance);
|
|
|
|
|
|
|
|
if (FALSE == This->init) {
|
2009-12-22 11:15:15 +01:00
|
|
|
return CO_E_NOTINITIALIZED;
|
2004-04-19 04:57:09 +02:00
|
|
|
}
|
2011-02-01 11:32:34 +01:00
|
|
|
|
2011-02-15 08:17:16 +01:00
|
|
|
return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, This->info_root,
|
2011-08-10 23:58:23 +02:00
|
|
|
&This->IDxDiagProvider_iface, (void **)ppInstance);
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
|
2004-04-16 02:26:14 +02:00
|
|
|
{
|
|
|
|
IDxDiagProviderImpl_QueryInterface,
|
|
|
|
IDxDiagProviderImpl_AddRef,
|
|
|
|
IDxDiagProviderImpl_Release,
|
|
|
|
IDxDiagProviderImpl_Initialize,
|
|
|
|
IDxDiagProviderImpl_GetRootContainer
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
|
|
|
|
IDxDiagProviderImpl* provider;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
|
2009-12-22 11:15:07 +01:00
|
|
|
|
|
|
|
*ppobj = NULL;
|
|
|
|
if (punkOuter) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2004-04-16 02:26:14 +02:00
|
|
|
provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
|
2009-12-22 11:15:07 +01:00
|
|
|
if (NULL == provider) return E_OUTOFMEMORY;
|
2011-08-10 23:58:23 +02:00
|
|
|
provider->IDxDiagProvider_iface.lpVtbl = &DxDiagProvider_Vtbl;
|
2004-04-16 02:26:14 +02:00
|
|
|
provider->ref = 0; /* will be inited with QueryInterface */
|
2011-08-10 23:58:23 +02:00
|
|
|
return IDxDiagProviderImpl_QueryInterface(&provider->IDxDiagProvider_iface, riid, ppobj);
|
2008-11-03 05:26:20 +01:00
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
static void free_property_information(IDxDiagContainerImpl_Property *prop)
|
|
|
|
{
|
|
|
|
VariantClear(&prop->vProp);
|
|
|
|
HeapFree(GetProcessHeap(), 0, prop->propName);
|
|
|
|
HeapFree(GetProcessHeap(), 0, prop);
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
static void free_information_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Container *ptr, *cursor2;
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
return;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, node->contName);
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(ptr, cursor2, &node->subContainers, IDxDiagContainerImpl_Container, entry)
|
|
|
|
{
|
2011-02-15 08:14:19 +01:00
|
|
|
IDxDiagContainerImpl_Property *prop, *prop_cursor2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(prop, prop_cursor2, &ptr->properties, IDxDiagContainerImpl_Property, entry)
|
|
|
|
{
|
|
|
|
list_remove(&prop->entry);
|
|
|
|
free_property_information(prop);
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
list_remove(&ptr->entry);
|
|
|
|
free_information_tree(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
static IDxDiagContainerImpl_Container *allocate_information_node(const WCHAR *name)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Container *ret;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
{
|
2019-06-04 09:05:32 +02:00
|
|
|
ret->contName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(*name));
|
2011-02-15 08:14:09 +01:00
|
|
|
if (!ret->contName)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-04 09:05:32 +02:00
|
|
|
lstrcpyW(ret->contName, name);
|
2011-02-15 08:14:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
list_init(&ret->subContainers);
|
|
|
|
list_init(&ret->properties);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
static IDxDiagContainerImpl_Property *allocate_property_information(const WCHAR *name)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Property *ret;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2019-06-04 09:05:32 +02:00
|
|
|
ret->propName = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(*name));
|
2011-02-15 08:14:19 +01:00
|
|
|
if (!ret->propName)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-06-04 09:05:32 +02:00
|
|
|
lstrcpyW(ret->propName, name);
|
2011-02-15 08:14:19 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
static inline void add_subcontainer(IDxDiagContainerImpl_Container *node, IDxDiagContainerImpl_Container *subCont)
|
|
|
|
{
|
|
|
|
list_add_tail(&node->subContainers, &subCont->entry);
|
|
|
|
++node->nSubContainers;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
static inline HRESULT add_bstr_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, const WCHAR *str)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Property *prop;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
prop = allocate_property_information(propName);
|
|
|
|
if (!prop)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
bstr = SysAllocString(str);
|
|
|
|
if (!bstr)
|
|
|
|
{
|
|
|
|
free_property_information(prop);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(&prop->vProp) = VT_BSTR;
|
|
|
|
V_BSTR(&prop->vProp) = bstr;
|
|
|
|
|
|
|
|
list_add_tail(&node->properties, &prop->entry);
|
|
|
|
++node->nProperties;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT add_ui4_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, DWORD data)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Property *prop;
|
|
|
|
|
|
|
|
prop = allocate_property_information(propName);
|
|
|
|
if (!prop)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
V_VT(&prop->vProp) = VT_UI4;
|
|
|
|
V_UI4(&prop->vProp) = data;
|
|
|
|
|
|
|
|
list_add_tail(&node->properties, &prop->entry);
|
|
|
|
++node->nProperties;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2018-05-24 03:48:32 +02:00
|
|
|
static inline HRESULT add_i4_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, LONG data)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Property *prop;
|
|
|
|
|
|
|
|
prop = allocate_property_information(propName);
|
|
|
|
if (!prop)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
V_VT(&prop->vProp) = VT_I4;
|
|
|
|
V_I4(&prop->vProp) = data;
|
|
|
|
|
|
|
|
list_add_tail(&node->properties, &prop->entry);
|
|
|
|
++node->nProperties;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
static inline HRESULT add_bool_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, BOOL data)
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Property *prop;
|
|
|
|
|
|
|
|
prop = allocate_property_information(propName);
|
|
|
|
if (!prop)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
V_VT(&prop->vProp) = VT_BOOL;
|
2015-10-21 13:48:09 +02:00
|
|
|
V_BOOL(&prop->vProp) = data ? VARIANT_TRUE : VARIANT_FALSE;
|
2011-02-15 08:14:19 +01:00
|
|
|
|
|
|
|
list_add_tail(&node->properties, &prop->entry);
|
|
|
|
++node->nProperties;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline HRESULT add_ull_as_bstr_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, ULONGLONG data )
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Property *prop;
|
2015-12-21 22:51:36 +01:00
|
|
|
HRESULT hr;
|
2011-02-15 08:14:19 +01:00
|
|
|
|
|
|
|
prop = allocate_property_information(propName);
|
|
|
|
if (!prop)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
V_VT(&prop->vProp) = VT_UI8;
|
|
|
|
V_UI8(&prop->vProp) = data;
|
|
|
|
|
2015-12-21 22:51:36 +01:00
|
|
|
hr = VariantChangeType(&prop->vProp, &prop->vProp, 0, VT_BSTR);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
free_property_information(prop);
|
|
|
|
return hr;
|
|
|
|
}
|
2011-02-15 08:14:19 +01:00
|
|
|
|
|
|
|
list_add_tail(&node->properties, &prop->entry);
|
|
|
|
++node->nProperties;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-04 03:55:39 +02:00
|
|
|
/* Copied from programs/taskkill/taskkill.c. */
|
|
|
|
static DWORD *enumerate_processes(DWORD *list_count)
|
|
|
|
{
|
|
|
|
DWORD *pid_list, alloc_bytes = 1024 * sizeof(*pid_list), needed_bytes;
|
|
|
|
|
|
|
|
pid_list = HeapAlloc(GetProcessHeap(), 0, alloc_bytes);
|
|
|
|
if (!pid_list)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
DWORD *realloc_list;
|
|
|
|
|
|
|
|
if (!EnumProcesses(pid_list, alloc_bytes, &needed_bytes))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pid_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EnumProcesses can't signal an insufficient buffer condition, so the
|
|
|
|
* only way to possibly determine whether a larger buffer is required
|
|
|
|
* is to see whether the written number of bytes is the same as the
|
|
|
|
* buffer size. If so, the buffer will be reallocated to twice the
|
|
|
|
* size. */
|
|
|
|
if (alloc_bytes != needed_bytes)
|
|
|
|
break;
|
|
|
|
|
|
|
|
alloc_bytes *= 2;
|
|
|
|
realloc_list = HeapReAlloc(GetProcessHeap(), 0, pid_list, alloc_bytes);
|
|
|
|
if (!realloc_list)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pid_list);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pid_list = realloc_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
*list_count = needed_bytes / sizeof(*pid_list);
|
|
|
|
return pid_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copied from programs/taskkill/taskkill.c. */
|
|
|
|
static BOOL get_process_name_from_pid(DWORD pid, WCHAR *buf, DWORD chars)
|
|
|
|
{
|
|
|
|
HANDLE process;
|
|
|
|
HMODULE module;
|
|
|
|
DWORD required_size;
|
|
|
|
|
|
|
|
process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
|
|
|
|
if (!process)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!EnumProcessModules(process, &module, sizeof(module), &required_size))
|
|
|
|
{
|
|
|
|
CloseHandle(process);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!GetModuleBaseNameW(process, module, buf, chars))
|
|
|
|
{
|
|
|
|
CloseHandle(process);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(process);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
|
|
|
|
static BOOL is_netmeeting_running(void)
|
|
|
|
{
|
|
|
|
DWORD list_count;
|
|
|
|
DWORD *pid_list = enumerate_processes(&list_count);
|
|
|
|
|
|
|
|
if (pid_list)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
WCHAR process_name[MAX_PATH];
|
|
|
|
|
|
|
|
for (i = 0; i < list_count; i++)
|
|
|
|
{
|
2018-07-28 00:04:52 +02:00
|
|
|
if (get_process_name_from_pid(pid_list[i], process_name, ARRAY_SIZE(process_name)) &&
|
2020-11-18 00:06:41 +01:00
|
|
|
!lstrcmpW(L"conf.exe", process_name))
|
2011-04-05 16:01:04 +02:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, pid_list);
|
2011-04-04 03:55:39 +02:00
|
|
|
return TRUE;
|
2011-04-05 16:01:04 +02:00
|
|
|
}
|
2011-04-04 03:55:39 +02:00
|
|
|
}
|
2011-04-05 16:01:04 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pid_list);
|
2011-04-04 03:55:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-04-04 03:55:32 +02:00
|
|
|
static HRESULT fill_language_information(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
WCHAR system_lang[80], regional_setting[100], user_lang[80], language_str[300];
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* szLanguagesLocalized */
|
2018-07-28 00:04:52 +02:00
|
|
|
GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SNATIVELANGNAME, system_lang, ARRAY_SIZE(system_lang));
|
|
|
|
LoadStringW(dxdiagn_instance, IDS_REGIONAL_SETTING, regional_setting, ARRAY_SIZE(regional_setting));
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SNATIVELANGNAME, user_lang, ARRAY_SIZE(user_lang));
|
2011-04-04 03:55:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(language_str, ARRAY_SIZE(language_str), L"%s (%s: %s)", system_lang, regional_setting,
|
|
|
|
user_lang);
|
2011-04-04 03:55:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szLanguagesLocalized", language_str);
|
2011-04-04 03:55:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* szLanguagesEnglish */
|
2018-07-28 00:04:52 +02:00
|
|
|
GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, system_lang, ARRAY_SIZE(system_lang));
|
|
|
|
GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, user_lang, ARRAY_SIZE(user_lang));
|
2011-04-04 03:55:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(language_str, ARRAY_SIZE(language_str), L"%s (%s: %s)", system_lang,
|
|
|
|
L"Regional Setting", user_lang);
|
2011-04-04 03:55:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szLanguagesEnglish", language_str);
|
2011-04-04 03:55:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-04 03:55:53 +02:00
|
|
|
static HRESULT fill_datetime_information(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
SYSTEMTIME curtime;
|
|
|
|
WCHAR date_str[80], time_str[80], datetime_str[200];
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
GetLocalTime(&curtime);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
GetTimeFormatW(LOCALE_NEUTRAL, 0, &curtime, L"HH':'mm':'ss", time_str, ARRAY_SIZE(time_str));
|
2011-04-04 03:55:53 +02:00
|
|
|
|
|
|
|
/* szTimeLocalized */
|
2018-07-28 00:04:52 +02:00
|
|
|
GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &curtime, NULL, date_str, ARRAY_SIZE(date_str));
|
2011-04-04 03:55:53 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(datetime_str, ARRAY_SIZE(datetime_str), L"%s, %s", date_str, time_str);
|
2011-04-04 03:55:53 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szTimeLocalized", datetime_str);
|
2011-04-04 03:55:53 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* szTimeEnglish */
|
2020-11-18 00:06:41 +01:00
|
|
|
GetDateFormatW(LOCALE_NEUTRAL, 0, &curtime, L"M'/'d'/'yyyy", date_str, ARRAY_SIZE(date_str));
|
2011-04-04 03:55:53 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(datetime_str, ARRAY_SIZE(datetime_str), L"%s, %s", date_str, time_str);
|
2011-04-04 03:55:53 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szTimeEnglish", datetime_str);
|
2011-04-04 03:55:53 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-04-04 03:56:07 +02:00
|
|
|
static HRESULT fill_os_string_information(IDxDiagContainerImpl_Container *node, OSVERSIONINFOW *info)
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
static const WCHAR *prop_list[] =
|
|
|
|
{
|
|
|
|
L"szOSLocalized", L"szOSExLocalized", L"szOSExLongLocalized",
|
|
|
|
L"szOSEnglish", L"szOSExEnglish", L"szOSExLongEnglish"
|
|
|
|
};
|
2011-04-04 03:56:07 +02:00
|
|
|
size_t i;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* FIXME: OS detection should be performed, and localized OS strings
|
|
|
|
* should contain translated versions of the "build" phrase. */
|
2018-07-28 00:04:52 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(prop_list); i++)
|
2011-04-04 03:56:07 +02:00
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, prop_list[i], L"Windows XP Professional");
|
2011-04-04 03:56:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-31 15:59:22 +02:00
|
|
|
static HRESULT fill_processor_information(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
IWbemLocator *wbem_locator;
|
|
|
|
IWbemServices *wbem_service;
|
|
|
|
IWbemClassObject *wbem_class;
|
|
|
|
IEnumWbemClassObject *wbem_enum;
|
|
|
|
VARIANT cpu_name, cpu_no, clock_speed;
|
|
|
|
WCHAR print_buf[200];
|
|
|
|
BSTR bstr;
|
|
|
|
ULONG no;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void**)&wbem_locator);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
bstr = SysAllocString(L"\\\\.\\root\\cimv2");
|
2012-08-31 15:59:22 +02:00
|
|
|
if(!bstr) {
|
|
|
|
IWbemLocator_Release(wbem_locator);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
hr = IWbemLocator_ConnectServer(wbem_locator, bstr, NULL, NULL, NULL, 0, NULL, NULL, &wbem_service);
|
|
|
|
IWbemLocator_Release(wbem_locator);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
bstr = SysAllocString(L"Win32_Processor");
|
2012-08-31 15:59:22 +02:00
|
|
|
if(!bstr) {
|
|
|
|
IWbemServices_Release(wbem_service);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
hr = IWbemServices_CreateInstanceEnum(wbem_service, bstr, WBEM_FLAG_SYSTEM_ONLY, NULL, &wbem_enum);
|
|
|
|
IWbemServices_Release(wbem_service);
|
|
|
|
SysFreeString(bstr);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IEnumWbemClassObject_Next(wbem_enum, 1000, 1, &wbem_class, &no);
|
|
|
|
IEnumWbemClassObject_Release(wbem_enum);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = IWbemClassObject_Get(wbem_class, L"NumberOfLogicalProcessors", 0, &cpu_no, NULL, NULL);
|
2012-08-31 15:59:22 +02:00
|
|
|
if(FAILED(hr)) {
|
|
|
|
IWbemClassObject_Release(wbem_class);
|
|
|
|
return hr;
|
|
|
|
}
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = IWbemClassObject_Get(wbem_class, L"MaxClockSpeed", 0, &clock_speed, NULL, NULL);
|
2012-08-31 15:59:22 +02:00
|
|
|
if(FAILED(hr)) {
|
|
|
|
IWbemClassObject_Release(wbem_class);
|
|
|
|
return hr;
|
|
|
|
}
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = IWbemClassObject_Get(wbem_class, L"Name", 0, &cpu_name, NULL, NULL);
|
2012-08-31 15:59:22 +02:00
|
|
|
IWbemClassObject_Release(wbem_class);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(print_buf, ARRAY_SIZE(print_buf), L"%s(%d CPUs), ~%dMHz",
|
2019-06-04 09:05:32 +02:00
|
|
|
V_BSTR(&cpu_name), V_I4(&cpu_no), V_I4(&clock_speed));
|
2012-08-31 15:59:22 +02:00
|
|
|
VariantClear(&cpu_name);
|
|
|
|
VariantClear(&cpu_no);
|
|
|
|
VariantClear(&clock_speed);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
return add_bstr_property(node, L"szProcessorEnglish", print_buf);
|
2012-08-31 15:59:22 +02:00
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
2011-02-15 08:14:19 +01:00
|
|
|
HRESULT hr;
|
|
|
|
MEMORYSTATUSEX msex;
|
|
|
|
OSVERSIONINFOW info;
|
2011-04-04 03:56:02 +02:00
|
|
|
DWORD count, usedpage_mb, availpage_mb;
|
|
|
|
WCHAR buffer[MAX_PATH], computer_name[MAX_COMPUTERNAME_LENGTH + 1], print_buf[200], localized_pagefile_fmt[200];
|
2011-11-19 15:10:13 +01:00
|
|
|
DWORD_PTR args[2];
|
2011-02-15 08:14:19 +01:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwDirectXVersionMajor", 9);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwDirectXVersionMinor", 0);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szDirectXVersionLetter", L"c");
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szDirectXVersionEnglish", L"4.09.0000.0904");
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szDirectXVersionLongEnglish", L"= \"DirectX 9.0c (4.09.0000.0904)");
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(node, L"bDebug", FALSE);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(node, L"bNECPC98", FALSE);
|
2011-04-04 03:55:43 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
msex.dwLength = sizeof(msex);
|
|
|
|
GlobalMemoryStatusEx(&msex);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ull_as_bstr_property(node, L"ullPhysicalMemory", msex.ullTotalPhys);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ull_as_bstr_property(node, L"ullUsedPageFile", msex.ullTotalPageFile - msex.ullAvailPageFile);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ull_as_bstr_property(node, L"ullAvailPageFile", msex.ullAvailPageFile);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(node, L"bNetMeetingRunning", is_netmeeting_running());
|
2011-04-04 03:55:39 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
info.dwOSVersionInfoSize = sizeof(info);
|
|
|
|
GetVersionExW(&info);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwOSMajorVersion", info.dwMajorVersion);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwOSMinorVersion", info.dwMinorVersion);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwOSBuildNumber", info.dwBuildNumber);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwOSPlatformID", info.dwPlatformId);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szCSDVersion", info.szCSDVersion);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-04-04 03:55:58 +02:00
|
|
|
/* FIXME: Roundoff should not be done with truncated division. */
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(print_buf, ARRAY_SIZE(print_buf), L"%uMB RAM", (DWORD)(msex.ullTotalPhys / (1024 * 1024)));
|
|
|
|
hr = add_bstr_property(node, L"szPhysicalMemoryEnglish", print_buf);
|
2011-04-04 03:55:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-04-04 03:56:02 +02:00
|
|
|
usedpage_mb = (DWORD)((msex.ullTotalPageFile - msex.ullAvailPageFile) / (1024 * 1024));
|
|
|
|
availpage_mb = (DWORD)(msex.ullAvailPageFile / (1024 * 1024));
|
2018-07-28 00:04:52 +02:00
|
|
|
LoadStringW(dxdiagn_instance, IDS_PAGE_FILE_FORMAT, localized_pagefile_fmt,
|
|
|
|
ARRAY_SIZE(localized_pagefile_fmt));
|
2011-11-19 15:10:13 +01:00
|
|
|
args[0] = usedpage_mb;
|
|
|
|
args[1] = availpage_mb;
|
2018-07-28 00:04:52 +02:00
|
|
|
FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, localized_pagefile_fmt,
|
|
|
|
0, 0, print_buf, ARRAY_SIZE(print_buf), (__ms_va_list*)args);
|
2011-04-04 03:56:02 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szPageFileLocalized", print_buf);
|
2011-04-04 03:56:02 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(print_buf, ARRAY_SIZE(print_buf), L"%uMB used, %uMB available", usedpage_mb, availpage_mb);
|
2011-04-04 03:56:02 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szPageFileEnglish", print_buf);
|
2011-04-04 03:56:02 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
GetWindowsDirectoryW(buffer, MAX_PATH);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szWindowsDir", buffer);
|
2011-02-15 08:14:19 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2018-07-28 00:04:52 +02:00
|
|
|
count = ARRAY_SIZE(computer_name);
|
2011-04-04 03:55:17 +02:00
|
|
|
if (!GetComputerNameW(computer_name, &count))
|
|
|
|
return E_FAIL;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szMachineNameLocalized", computer_name);
|
2011-04-04 03:55:17 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szMachineNameEnglish", computer_name);
|
2011-04-04 03:55:17 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szSystemManufacturerEnglish", L"");
|
2011-06-14 15:01:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szSystemModelEnglish", L"");
|
2011-06-14 15:01:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szBIOSEnglish", L"");
|
2011-06-14 15:01:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2012-08-31 15:59:22 +02:00
|
|
|
hr = fill_processor_information(node);
|
2011-06-14 15:01:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szSetupParamEnglish", L"Not present");
|
2011-06-14 15:01:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szDxDiagVersion", L"");
|
2011-06-14 15:01:58 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-04-04 03:55:32 +02:00
|
|
|
hr = fill_language_information(node);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-04-04 03:55:53 +02:00
|
|
|
hr = fill_datetime_information(node);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-04-04 03:56:07 +02:00
|
|
|
hr = fill_os_string_information(node, &info);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:10:52 +02:00
|
|
|
/* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
|
|
|
|
static DWORD depth_for_pixelformat(D3DFORMAT format)
|
|
|
|
{
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case D3DFMT_P8: return 8;
|
|
|
|
case D3DFMT_X1R5G5B5: return 15;
|
|
|
|
case D3DFMT_R5G6B5: return 16;
|
|
|
|
/* This case will fail to distinguish an original bpp of 24. */
|
|
|
|
case D3DFMT_X8R8G8B8: return 32;
|
|
|
|
default:
|
|
|
|
FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format);
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL get_texture_memory(GUID *adapter, DWORD *available_mem)
|
|
|
|
{
|
|
|
|
IDirectDraw7 *pDirectDraw;
|
|
|
|
HRESULT hr;
|
|
|
|
DDSCAPS2 dd_caps;
|
|
|
|
|
|
|
|
hr = DirectDrawCreateEx(adapter, (void **)&pDirectDraw, &IID_IDirectDraw7, NULL);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
|
2015-02-28 09:22:59 +01:00
|
|
|
dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.u1.dwCaps4 = 0;
|
2011-06-15 14:10:52 +02:00
|
|
|
hr = IDirectDraw7_GetAvailableVidMem(pDirectDraw, &dd_caps, available_mem, NULL);
|
|
|
|
IDirectDraw7_Release(pDirectDraw);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:11:07 +02:00
|
|
|
static const WCHAR *vendor_id_to_manufacturer_string(DWORD vendor_id)
|
|
|
|
{
|
2019-01-08 17:04:49 +01:00
|
|
|
unsigned int i;
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
const WCHAR *name;
|
|
|
|
}
|
|
|
|
vendors[] =
|
2011-06-15 14:11:07 +02:00
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
{0x1002, L"ATI Technologies Inc."},
|
|
|
|
{0x10de, L"NVIDIA"},
|
|
|
|
{0x15ad, L"VMware"},
|
|
|
|
{0x1af4, L"Red Hat"},
|
|
|
|
{0x8086, L"Intel Corporation"},
|
2011-06-15 14:11:07 +02:00
|
|
|
};
|
|
|
|
|
2019-01-08 17:04:49 +01:00
|
|
|
for (i = 0; i < ARRAY_SIZE(vendors); ++i)
|
2011-06-15 14:11:07 +02:00
|
|
|
{
|
2019-01-08 17:04:49 +01:00
|
|
|
if (vendors[i].id == vendor_id)
|
|
|
|
return vendors[i].name;
|
2011-06-15 14:11:07 +02:00
|
|
|
}
|
2019-01-08 17:04:49 +01:00
|
|
|
|
|
|
|
FIXME("Unknown PCI vendor ID 0x%04x.\n", vendor_id);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
return L"Unknown";
|
2011-06-15 14:11:07 +02:00
|
|
|
}
|
|
|
|
|
2011-06-15 14:10:52 +02:00
|
|
|
static HRESULT fill_display_information_d3d(IDxDiagContainerImpl_Container *node)
|
2011-02-15 08:14:09 +01:00
|
|
|
{
|
2011-06-15 14:10:52 +02:00
|
|
|
IDxDiagContainerImpl_Container *display_adapter;
|
|
|
|
HRESULT hr;
|
|
|
|
IDirect3D9 *pDirect3D9;
|
|
|
|
WCHAR buffer[256];
|
|
|
|
UINT index, count;
|
|
|
|
|
|
|
|
pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION);
|
|
|
|
if (!pDirect3D9)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
count = IDirect3D9_GetAdapterCount(pDirect3D9);
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
D3DADAPTER_IDENTIFIER9 adapter_info;
|
|
|
|
D3DDISPLAYMODE adapter_mode;
|
2014-03-24 02:18:45 +01:00
|
|
|
D3DCAPS9 device_caps;
|
2011-06-15 14:10:52 +02:00
|
|
|
DWORD available_mem = 0;
|
2014-03-24 02:18:45 +01:00
|
|
|
BOOL hardware_accel;
|
2011-06-15 14:10:52 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"%u", index);
|
2011-06-15 14:10:52 +02:00
|
|
|
display_adapter = allocate_information_node(buffer);
|
|
|
|
if (!display_adapter)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_subcontainer(node, display_adapter);
|
|
|
|
|
|
|
|
hr = IDirect3D9_GetAdapterIdentifier(pDirect3D9, index, 0, &adapter_info);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2011-06-15 14:11:07 +02:00
|
|
|
WCHAR driverW[sizeof(adapter_info.Driver)];
|
2011-06-15 14:10:52 +02:00
|
|
|
WCHAR descriptionW[sizeof(adapter_info.Description)];
|
2011-06-15 14:11:07 +02:00
|
|
|
WCHAR devicenameW[sizeof(adapter_info.DeviceName)];
|
2011-06-15 14:10:52 +02:00
|
|
|
|
2018-07-28 00:04:52 +02:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, adapter_info.Driver, -1, driverW, ARRAY_SIZE(driverW));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, adapter_info.Description, -1, descriptionW,
|
|
|
|
ARRAY_SIZE(descriptionW));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, adapter_info.DeviceName, -1, devicenameW,
|
|
|
|
ARRAY_SIZE(devicenameW));
|
2011-06-15 14:10:52 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverName", driverW);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDescription", descriptionW);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDeviceName", devicenameW);
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"%u.%u.%04u.%04u",
|
|
|
|
HIWORD(adapter_info.DriverVersion.u.HighPart), LOWORD(adapter_info.DriverVersion.u.HighPart),
|
|
|
|
HIWORD(adapter_info.DriverVersion.u.LowPart), LOWORD(adapter_info.DriverVersion.u.LowPart));
|
2011-06-15 14:11:07 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverVersion", buffer);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"0x%04x", adapter_info.VendorId);
|
|
|
|
hr = add_bstr_property(display_adapter, L"szVendorId", buffer);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"0x%04x", adapter_info.DeviceId);
|
|
|
|
hr = add_bstr_property(display_adapter, L"szDeviceId", buffer);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2011-06-15 14:11:07 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"0x%08x", adapter_info.SubSysId);
|
|
|
|
hr = add_bstr_property(display_adapter, L"szSubSysId", buffer);
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"0x%04x", adapter_info.Revision);
|
|
|
|
hr = add_bstr_property(display_adapter, L"szRevisionId", buffer);
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
StringFromGUID2(&adapter_info.DeviceIdentifier, buffer, 39);
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDeviceIdentifier", buffer);
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szManufacturer",
|
|
|
|
vendor_id_to_manufacturer_string(adapter_info.VendorId));
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2011-06-15 14:10:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDirect3D9_GetAdapterDisplayMode(pDirect3D9, index, &adapter_mode);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwWidth", adapter_mode.Width);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwHeight", adapter_mode.Height);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwRefreshRate", adapter_mode.RefreshRate);
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwBpp", depth_for_pixelformat(adapter_mode.Format));
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2018-05-24 03:48:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"%d x %d (%d bit) (%dHz)", adapter_mode.Width,
|
|
|
|
adapter_mode.Height, depth_for_pixelformat(adapter_mode.Format),
|
|
|
|
adapter_mode.RefreshRate);
|
2018-05-24 03:48:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDisplayModeLocalized", buffer);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDisplayModeEnglish", buffer);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2011-06-15 14:10:52 +02:00
|
|
|
}
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szKeyDeviceKey", L"");
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szKeyDeviceID", L"");
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szChipType", L"");
|
2013-10-05 03:20:37 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDACType", L"");
|
2013-10-05 03:20:37 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szRevision", L"");
|
2013-10-05 03:20:37 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2011-06-15 14:10:52 +02:00
|
|
|
if (!get_texture_memory(&adapter_info.DeviceIdentifier, &available_mem))
|
|
|
|
WARN("get_texture_memory helper failed\n");
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"%.1f MB", available_mem / 1000000.0f);
|
2011-06-15 14:10:52 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDisplayMemoryLocalized", buffer);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDisplayMemoryEnglish", buffer);
|
2011-06-15 14:10:52 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2014-03-24 02:18:45 +01:00
|
|
|
|
|
|
|
hr = IDirect3D9_GetDeviceCaps(pDirect3D9, index, D3DDEVTYPE_HAL, &device_caps);
|
|
|
|
hardware_accel = SUCCEEDED(hr);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"b3DAccelerationEnabled", hardware_accel);
|
2014-03-24 02:18:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"b3DAccelerationExists", hardware_accel);
|
2014-03-24 02:18:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bDDAccelerationEnabled", hardware_accel);
|
2014-03-24 02:18:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2015-03-09 07:02:56 +01:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bNoHardware", FALSE);
|
2015-03-09 07:02:56 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2018-05-24 03:48:32 +02:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bCanRenderWindow", TRUE);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szMonitorName", L"Generic PnP Monitor");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szMonitorMaxRes", L"Failed to get parameter");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverAttributes", L"Final Retail");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverLanguageEnglish", L"English");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverLanguageLocalized", L"English");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverDateEnglish", L"1/1/2016 10:00:00");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverDateLocalized", L"1/1/2016 10:00:00 AM");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_i4_property(display_adapter, L"lDriverSize", 10 * 1024 * 1024);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szMiniVdd", L"n/a");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szMiniVddDateLocalized", L"n/a");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szMiniVddDateEnglish", L"n/a");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_i4_property(display_adapter, L"lMiniVddSize", 0);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szVdd", L"n/a");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bDriverBeta", FALSE);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bDriverDebug", FALSE);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bDriverSigned", TRUE);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(display_adapter, L"bDriverSignedValid", TRUE);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDriverSignDate", L"n/a");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwDDIVersion", 11);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDDIVersionEnglish", L"11");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDDIVersionLocalized", L"11");
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"iAdapter", index);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwWHQLLevel", 0);
|
2018-05-24 03:48:32 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2011-06-15 14:10:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
cleanup:
|
|
|
|
IDirect3D9_Release(pDirect3D9);
|
|
|
|
return hr;
|
|
|
|
}
|
2011-02-15 08:14:27 +01:00
|
|
|
|
2011-06-15 14:10:58 +02:00
|
|
|
static HRESULT fill_display_information_fallback(IDxDiagContainerImpl_Container *node)
|
2011-06-15 14:10:52 +02:00
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
static const WCHAR *empty_properties[] =
|
|
|
|
{
|
|
|
|
L"szDeviceIdentifier", L"szVendorId", L"szDeviceId", L"szKeyDeviceKey",
|
|
|
|
L"szKeyDeviceID", L"szDriverName", L"szDriverVersion", L"szSubSysId",
|
|
|
|
L"szRevisionId", L"szManufacturer", L"szChipType", L"szDACType", L"szRevision"
|
|
|
|
};
|
2011-02-15 08:14:27 +01:00
|
|
|
|
|
|
|
IDxDiagContainerImpl_Container *display_adapter;
|
|
|
|
HRESULT hr;
|
|
|
|
IDirectDraw7 *pDirectDraw;
|
|
|
|
DDSCAPS2 dd_caps;
|
|
|
|
DISPLAY_DEVICEW disp_dev;
|
|
|
|
DDSURFACEDESC2 surface_descr;
|
|
|
|
DWORD tmp;
|
|
|
|
WCHAR buffer[256];
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
display_adapter = allocate_information_node(L"0");
|
2011-02-15 08:14:27 +01:00
|
|
|
if (!display_adapter)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
add_subcontainer(node, display_adapter);
|
|
|
|
|
|
|
|
disp_dev.cb = sizeof(disp_dev);
|
|
|
|
if (EnumDisplayDevicesW( NULL, 0, &disp_dev, 0 ))
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDeviceName", disp_dev.DeviceName);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDescription", disp_dev.DeviceString);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-15 14:10:58 +02:00
|
|
|
/* Silently ignore a failure from DirectDrawCreateEx. */
|
|
|
|
hr = DirectDrawCreateEx(NULL, (void **)&pDirectDraw, &IID_IDirectDraw7, NULL);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
|
2015-02-28 09:22:59 +01:00
|
|
|
dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.u1.dwCaps4 = 0;
|
2011-02-15 08:14:27 +01:00
|
|
|
hr = IDirectDraw7_GetAvailableVidMem(pDirectDraw, &dd_caps, &tmp, NULL);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"%.1f MB", tmp / 1000000.0f);
|
2011-02-15 08:14:27 +01:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDisplayMemoryLocalized", buffer);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, L"szDisplayMemoryEnglish", buffer);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface_descr.dwSize = sizeof(surface_descr);
|
|
|
|
hr = IDirectDraw7_GetDisplayMode(pDirectDraw, &surface_descr);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if (surface_descr.dwFlags & DDSD_WIDTH)
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwWidth", surface_descr.dwWidth);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface_descr.dwFlags & DDSD_HEIGHT)
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwHeight", surface_descr.dwHeight);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface_descr.dwFlags & DDSD_PIXELFORMAT)
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwBpp",
|
|
|
|
surface_descr.u4.ddpfPixelFormat.u1.dwRGBBitCount);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(display_adapter, L"dwRefreshRate", 60);
|
2011-02-15 08:14:27 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2018-07-28 00:04:52 +02:00
|
|
|
for (tmp = 0; tmp < ARRAY_SIZE(empty_properties); tmp++)
|
2011-06-15 14:11:07 +02:00
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(display_adapter, empty_properties[tmp], L"");
|
2011-06-15 14:11:07 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2011-02-15 08:14:27 +01:00
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
cleanup:
|
|
|
|
IDirectDraw7_Release(pDirectDraw);
|
|
|
|
return hr;
|
2011-02-15 08:14:09 +01:00
|
|
|
}
|
|
|
|
|
2011-06-15 14:10:58 +02:00
|
|
|
static HRESULT build_displaydevices_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Try to use Direct3D to obtain the required information first. */
|
|
|
|
hr = fill_display_information_d3d(node);
|
|
|
|
if (hr != E_FAIL)
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
return fill_display_information_fallback(node);
|
|
|
|
}
|
|
|
|
|
2020-11-12 17:37:48 +01:00
|
|
|
struct enum_context
|
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Container *cont;
|
|
|
|
HRESULT hr;
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
|
|
|
|
static LPWSTR guid_to_string(LPWSTR lpwstr, REFGUID lpcguid)
|
|
|
|
{
|
|
|
|
wsprintfW(lpwstr, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", lpcguid->Data1, lpcguid->Data2,
|
|
|
|
lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1], lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4],
|
|
|
|
lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]);
|
|
|
|
|
|
|
|
return lpwstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CALLBACK dsound_enum(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID context)
|
|
|
|
{
|
|
|
|
struct enum_context *enum_ctx = context;
|
|
|
|
IDxDiagContainerImpl_Container *device;
|
|
|
|
WCHAR buffer[256];
|
|
|
|
const WCHAR *p, *name;
|
|
|
|
|
|
|
|
/* the default device is enumerated twice, one time without GUID */
|
|
|
|
if (!guid) return TRUE;
|
|
|
|
|
|
|
|
swprintf(buffer, ARRAY_SIZE(buffer), L"%u", enum_ctx->index);
|
|
|
|
device = allocate_information_node(buffer);
|
|
|
|
if (!device)
|
|
|
|
{
|
|
|
|
enum_ctx->hr = E_OUTOFMEMORY;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_subcontainer(enum_ctx->cont, device);
|
|
|
|
|
|
|
|
guid_to_string(buffer, guid);
|
|
|
|
enum_ctx->hr = add_bstr_property(device, L"szGuidDeviceID", buffer);
|
|
|
|
if (FAILED(enum_ctx->hr))
|
|
|
|
return FALSE;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
enum_ctx->hr = add_bstr_property(device, L"szDescription", desc);
|
2020-11-12 17:37:48 +01:00
|
|
|
if (FAILED(enum_ctx->hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
enum_ctx->hr = add_bstr_property(device, L"szDriverPath", module);
|
|
|
|
if (FAILED(enum_ctx->hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
name = module;
|
|
|
|
if ((p = wcsrchr(name, '\\'))) name = p + 1;
|
|
|
|
if ((p = wcsrchr(name, '/'))) name = p + 1;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
enum_ctx->hr = add_bstr_property(device, L"szDriverName", name);
|
2020-11-12 17:37:48 +01:00
|
|
|
if (FAILED(enum_ctx->hr))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
enum_ctx->index++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
static HRESULT build_directsound_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
2020-11-12 17:37:48 +01:00
|
|
|
struct enum_context enum_ctx;
|
2011-02-15 08:14:35 +01:00
|
|
|
IDxDiagContainerImpl_Container *cont;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
cont = allocate_information_node(L"DxDiag_SoundDevices");
|
2011-02-15 08:14:35 +01:00
|
|
|
if (!cont)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
add_subcontainer(node, cont);
|
|
|
|
|
2020-11-12 17:37:48 +01:00
|
|
|
enum_ctx.cont = cont;
|
|
|
|
enum_ctx.hr = S_OK;
|
|
|
|
enum_ctx.index = 0;
|
|
|
|
|
|
|
|
DirectSoundEnumerateW(dsound_enum, &enum_ctx);
|
|
|
|
if (FAILED(enum_ctx.hr))
|
|
|
|
return enum_ctx.hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
cont = allocate_information_node(L"DxDiag_SoundCaptureDevices");
|
2011-02-15 08:14:35 +01:00
|
|
|
if (!cont)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
add_subcontainer(node, cont);
|
|
|
|
|
2020-11-12 17:37:48 +01:00
|
|
|
enum_ctx.cont = cont;
|
|
|
|
enum_ctx.hr = S_OK;
|
|
|
|
enum_ctx.index = 0;
|
|
|
|
|
|
|
|
DirectSoundCaptureEnumerateW(dsound_enum, &enum_ctx);
|
|
|
|
if (FAILED(enum_ctx.hr))
|
|
|
|
return enum_ctx.hr;
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT build_directmusic_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT build_directinput_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT build_directplay_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT build_systemdevices_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:45 +01:00
|
|
|
static HRESULT fill_file_description(IDxDiagContainerImpl_Container *node, const WCHAR *szFilePath, const WCHAR *szFileName)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR *szFile;
|
|
|
|
WCHAR szVersion_v[1024];
|
|
|
|
DWORD retval, hdl;
|
|
|
|
void *pVersionInfo = NULL;
|
|
|
|
BOOL boolret = FALSE;
|
|
|
|
UINT uiLength;
|
|
|
|
VS_FIXEDFILEINFO *pFileInfo;
|
|
|
|
|
2011-02-15 08:17:44 +01:00
|
|
|
TRACE("Filling container %p for %s in %s\n", node,
|
|
|
|
debugstr_w(szFileName), debugstr_w(szFilePath));
|
|
|
|
|
2011-02-15 08:14:45 +01:00
|
|
|
szFile = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(szFilePath) +
|
|
|
|
lstrlenW(szFileName) + 2 /* slash + terminator */));
|
|
|
|
if (!szFile)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
lstrcpyW(szFile, szFilePath);
|
2020-11-18 00:06:41 +01:00
|
|
|
lstrcatW(szFile, L"\\");
|
2011-02-15 08:14:45 +01:00
|
|
|
lstrcatW(szFile, szFileName);
|
|
|
|
|
|
|
|
retval = GetFileVersionInfoSizeW(szFile, &hdl);
|
|
|
|
if (retval)
|
|
|
|
{
|
|
|
|
pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
|
|
|
|
if (!pVersionInfo)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetFileVersionInfoW(szFile, 0, retval, pVersionInfo) &&
|
2020-11-18 00:06:41 +01:00
|
|
|
VerQueryValueW(pVersionInfo, L"\\", (void **)&pFileInfo, &uiLength))
|
2011-02-15 08:14:45 +01:00
|
|
|
boolret = TRUE;
|
|
|
|
}
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szPath", szFile);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szName", szFileName);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(node, L"bExists", boolret);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (boolret)
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(szVersion_v, ARRAY_SIZE(szVersion_v), L"%u.%02u.%04u.%04u",
|
|
|
|
HIWORD(pFileInfo->dwFileVersionMS), LOWORD(pFileInfo->dwFileVersionMS),
|
|
|
|
HIWORD(pFileInfo->dwFileVersionLS), LOWORD(pFileInfo->dwFileVersionLS));
|
2011-02-15 08:14:45 +01:00
|
|
|
|
2011-02-15 08:17:44 +01:00
|
|
|
TRACE("Found version as (%s)\n", debugstr_w(szVersion_v));
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szVersion", szVersion_v);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szAttributes", L"Final Retail");
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(node, L"szLanguageEnglish", L"English");
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwFileTimeHigh", pFileInfo->dwFileDateMS);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(node, L"dwFileTimeLow", pFileInfo->dwFileDateLS);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(node, L"bBeta",
|
|
|
|
((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_PRERELEASE) != 0);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bool_property(node, L"bDebug",
|
|
|
|
((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_DEBUG) != 0);
|
2011-02-15 08:14:45 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
cleanup:
|
|
|
|
HeapFree(GetProcessHeap(), 0, pVersionInfo);
|
|
|
|
HeapFree(GetProcessHeap(), 0, szFile);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
2011-02-15 08:14:09 +01:00
|
|
|
static HRESULT build_directxfiles_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
2011-02-15 08:14:45 +01:00
|
|
|
static const WCHAR dlls[][15] =
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
L"d3d8.dll",
|
|
|
|
L"d3d9.dll",
|
|
|
|
L"ddraw.dll",
|
|
|
|
L"devenum.dll",
|
|
|
|
L"dinput8.dll",
|
|
|
|
L"dinput.dll",
|
|
|
|
L"dmband.dll",
|
|
|
|
L"dmcompos.dll",
|
|
|
|
L"dmime.dll",
|
|
|
|
L"dmloader.dll",
|
|
|
|
L"dmscript.dll",
|
|
|
|
L"dmstyle.dll",
|
|
|
|
L"dmsynth.dll",
|
|
|
|
L"dmusic.dll",
|
|
|
|
L"dplayx.dll",
|
|
|
|
L"dpnet.dll",
|
|
|
|
L"dsound.dll",
|
|
|
|
L"dswave.dll",
|
|
|
|
L"dxdiagn.dll",
|
|
|
|
L"quartz.dll"
|
2011-02-15 08:14:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR szFilePath[MAX_PATH];
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
GetSystemDirectoryW(szFilePath, MAX_PATH);
|
|
|
|
|
2018-07-28 00:04:52 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(dlls); i++)
|
2011-02-15 08:14:45 +01:00
|
|
|
{
|
|
|
|
WCHAR szFileID[5];
|
|
|
|
IDxDiagContainerImpl_Container *file_container;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(szFileID, ARRAY_SIZE(szFileID), L"%d", i);
|
2011-02-15 08:14:45 +01:00
|
|
|
|
|
|
|
file_container = allocate_information_node(szFileID);
|
|
|
|
if (!file_container)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
hr = fill_file_description(file_container, szFilePath, dlls[i]);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
free_information_tree(file_container);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_subcontainer(node, file_container);
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:53 +01:00
|
|
|
static HRESULT read_property_names(IPropertyBag *pPropBag, VARIANT *friendly_name, VARIANT *clsid_name)
|
2011-02-15 08:14:09 +01:00
|
|
|
{
|
2011-02-15 08:14:53 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(friendly_name);
|
|
|
|
VariantInit(clsid_name);
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = IPropertyBag_Read(pPropBag, L"FriendlyName", friendly_name, 0);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = IPropertyBag_Read(pPropBag, L"CLSID", clsid_name, 0);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
VariantClear(friendly_name);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:53 +01:00
|
|
|
static HRESULT fill_filter_data_information(IDxDiagContainerImpl_Container *subcont, BYTE *pData, ULONG cb)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IFilterMapper2 *pFileMapper = NULL;
|
|
|
|
IAMFilterData *pFilterData = NULL;
|
2012-02-06 18:02:43 +01:00
|
|
|
BYTE *ppRF = NULL;
|
2011-02-15 08:14:53 +01:00
|
|
|
REGFILTER2 *pRF = NULL;
|
|
|
|
WCHAR bufferW[10];
|
|
|
|
ULONG j;
|
|
|
|
DWORD dwNOutputs = 0;
|
|
|
|
DWORD dwNInputs = 0;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2,
|
|
|
|
(void **)&pFileMapper);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IFilterMapper2_QueryInterface(pFileMapper, &IID_IAMFilterData, (void **)&pFilterData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2019-04-05 21:03:59 +02:00
|
|
|
hr = IAMFilterData_ParseFilterData(pFilterData, pData, cb, &ppRF);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
2012-02-06 18:02:43 +01:00
|
|
|
pRF = ((REGFILTER2**)ppRF)[0];
|
2011-02-15 08:14:53 +01:00
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(bufferW, ARRAY_SIZE(bufferW), L"v%d", pRF->dwVersion);
|
|
|
|
hr = add_bstr_property(subcont, L"szVersion", bufferW);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (pRF->dwVersion == 1)
|
|
|
|
{
|
2021-03-30 20:09:34 +02:00
|
|
|
for (j = 0; j < pRF->cPins; j++)
|
|
|
|
if (pRF->rgPins[j].bOutput)
|
2011-02-15 08:14:53 +01:00
|
|
|
dwNOutputs++;
|
|
|
|
else
|
|
|
|
dwNInputs++;
|
|
|
|
}
|
|
|
|
else if (pRF->dwVersion == 2)
|
|
|
|
{
|
2021-03-30 20:09:34 +02:00
|
|
|
for (j = 0; j < pRF->cPins2; j++)
|
|
|
|
if (pRF->rgPins2[j].dwFlags & REG_PINFLAG_B_OUTPUT)
|
2011-02-15 08:14:53 +01:00
|
|
|
dwNOutputs++;
|
|
|
|
else
|
|
|
|
dwNInputs++;
|
|
|
|
}
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(subcont, L"dwInputs", dwNInputs);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(subcont, L"dwOutputs", dwNOutputs);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_ui4_property(subcont, L"dwMerit", pRF->dwMerit);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
cleanup:
|
|
|
|
CoTaskMemFree(pRF);
|
|
|
|
if (pFilterData) IAMFilterData_Release(pFilterData);
|
|
|
|
if (pFileMapper) IFilterMapper2_Release(pFileMapper);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT fill_filter_container(IDxDiagContainerImpl_Container *subcont, IMoniker *pMoniker)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
IPropertyBag *pPropFilterBag = NULL;
|
|
|
|
BYTE *pData;
|
|
|
|
VARIANT friendly_name;
|
|
|
|
VARIANT clsid_name;
|
|
|
|
VARIANT v;
|
|
|
|
|
|
|
|
VariantInit(&friendly_name);
|
|
|
|
VariantInit(&clsid_name);
|
|
|
|
VariantInit(&v);
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (void **)&pPropFilterBag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = read_property_names(pPropFilterBag, &friendly_name, &clsid_name);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2011-02-15 08:17:44 +01:00
|
|
|
TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name)));
|
|
|
|
TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name)));
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(subcont, L"szName", V_BSTR(&friendly_name));
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(subcont, L"ClsidFilter", V_BSTR(&clsid_name));
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = IPropertyBag_Read(pPropFilterBag, L"FilterData", &v, NULL);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hr = SafeArrayAccessData(V_ARRAY(&v), (void **)&pData);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hr = fill_filter_data_information(subcont, pData, V_ARRAY(&v)->rgsabound->cElements);
|
|
|
|
SafeArrayUnaccessData(V_ARRAY(&v));
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
cleanup:
|
|
|
|
VariantClear(&v);
|
|
|
|
VariantClear(&clsid_name);
|
|
|
|
VariantClear(&friendly_name);
|
|
|
|
if (pPropFilterBag) IPropertyBag_Release(pPropFilterBag);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT build_directshowfilters_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
int i = 0;
|
|
|
|
ICreateDevEnum *pCreateDevEnum;
|
|
|
|
IEnumMoniker *pEmCat = NULL;
|
|
|
|
IMoniker *pMCat = NULL;
|
|
|
|
IEnumMoniker *pEnum = NULL;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ICreateDevEnum, (void **)&pCreateDevEnum);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &CLSID_ActiveMovieCategories, &pEmCat, 0);
|
|
|
|
if (FAILED(hr))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
while (IEnumMoniker_Next(pEmCat, 1, &pMCat, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
VARIANT vCatName;
|
|
|
|
VARIANT vCatClsid;
|
|
|
|
IPropertyBag *pPropBag;
|
|
|
|
CLSID clsidCat;
|
|
|
|
IMoniker *pMoniker = NULL;
|
|
|
|
|
|
|
|
hr = IMoniker_BindToStorage(pMCat, NULL, NULL, &IID_IPropertyBag, (void **)&pPropBag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMoniker_Release(pMCat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = read_property_names(pPropBag, &vCatName, &vCatClsid);
|
|
|
|
IPropertyBag_Release(pPropBag);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMoniker_Release(pMCat);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = CLSIDFromString(V_BSTR(&vCatClsid), &clsidCat);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
IMoniker_Release(pMCat);
|
|
|
|
VariantClear(&vCatClsid);
|
|
|
|
VariantClear(&vCatName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &clsidCat, &pEnum, 0);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
IMoniker_Release(pMCat);
|
|
|
|
VariantClear(&vCatClsid);
|
|
|
|
VariantClear(&vCatName);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:17:44 +01:00
|
|
|
TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat));
|
|
|
|
|
2011-02-15 08:14:53 +01:00
|
|
|
while (IEnumMoniker_Next(pEnum, 1, &pMoniker, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
WCHAR bufferW[10];
|
|
|
|
IDxDiagContainerImpl_Container *subcont;
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
swprintf(bufferW, ARRAY_SIZE(bufferW), L"%d", i);
|
2011-02-15 08:14:53 +01:00
|
|
|
subcont = allocate_information_node(bufferW);
|
|
|
|
if (!subcont)
|
|
|
|
{
|
|
|
|
hr = E_OUTOFMEMORY;
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(subcont, L"szCatName", V_BSTR(&vCatName));
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
free_information_tree(subcont);
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-11-18 00:06:41 +01:00
|
|
|
hr = add_bstr_property(subcont, L"ClsidCat", V_BSTR(&vCatClsid));
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
free_information_tree(subcont);
|
|
|
|
IMoniker_Release(pMoniker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = fill_filter_container(subcont, pMoniker);
|
2014-01-09 11:11:25 +01:00
|
|
|
IMoniker_Release(pMoniker);
|
2011-02-15 08:14:53 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2014-01-09 11:11:25 +01:00
|
|
|
WARN("Skipping invalid filter\n");
|
2011-02-15 08:14:53 +01:00
|
|
|
free_information_tree(subcont);
|
2014-01-09 11:11:25 +01:00
|
|
|
hr = S_OK;
|
|
|
|
continue;
|
2011-02-15 08:14:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
add_subcontainer(node, subcont);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumMoniker_Release(pEnum);
|
|
|
|
IMoniker_Release(pMCat);
|
|
|
|
VariantClear(&vCatClsid);
|
|
|
|
VariantClear(&vCatName);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (pEmCat) IEnumMoniker_Release(pEmCat);
|
|
|
|
ICreateDevEnum_Release(pCreateDevEnum);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:09 +01:00
|
|
|
static HRESULT build_logicaldisks_tree(IDxDiagContainerImpl_Container *node)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT build_information_tree(IDxDiagContainerImpl_Container **pinfo_root)
|
|
|
|
{
|
|
|
|
static const struct
|
|
|
|
{
|
|
|
|
const WCHAR *name;
|
|
|
|
HRESULT (*initfunc)(IDxDiagContainerImpl_Container *);
|
|
|
|
} root_children[] =
|
|
|
|
{
|
2020-11-18 00:06:41 +01:00
|
|
|
{L"DxDiag_SystemInfo", build_systeminfo_tree},
|
|
|
|
{L"DxDiag_DisplayDevices", build_displaydevices_tree},
|
|
|
|
{L"DxDiag_DirectSound", build_directsound_tree},
|
|
|
|
{L"DxDiag_DirectMusic", build_directmusic_tree},
|
|
|
|
{L"DxDiag_DirectInput", build_directinput_tree},
|
|
|
|
{L"DxDiag_DirectPlay", build_directplay_tree},
|
|
|
|
{L"DxDiag_SystemDevices", build_systemdevices_tree},
|
|
|
|
{L"DxDiag_DirectXFiles", build_directxfiles_tree},
|
|
|
|
{L"DxDiag_DirectShowFilters", build_directshowfilters_tree},
|
|
|
|
{L"DxDiag_LogicalDisks", build_logicaldisks_tree},
|
2011-02-15 08:14:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
IDxDiagContainerImpl_Container *info_root;
|
|
|
|
size_t index;
|
|
|
|
|
|
|
|
info_root = allocate_information_node(NULL);
|
|
|
|
if (!info_root)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2018-07-28 00:04:52 +02:00
|
|
|
for (index = 0; index < ARRAY_SIZE(root_children); index++)
|
2011-02-15 08:14:09 +01:00
|
|
|
{
|
|
|
|
IDxDiagContainerImpl_Container *node;
|
2011-02-15 08:14:19 +01:00
|
|
|
HRESULT hr;
|
2011-02-15 08:14:09 +01:00
|
|
|
|
|
|
|
node = allocate_information_node(root_children[index].name);
|
|
|
|
if (!node)
|
|
|
|
{
|
|
|
|
free_information_tree(info_root);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-02-15 08:14:19 +01:00
|
|
|
hr = root_children[index].initfunc(node);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
free_information_tree(node);
|
|
|
|
free_information_tree(info_root);
|
|
|
|
return hr;
|
|
|
|
}
|
2011-02-15 08:14:09 +01:00
|
|
|
|
|
|
|
add_subcontainer(info_root, node);
|
|
|
|
}
|
|
|
|
|
|
|
|
*pinfo_root = info_root;
|
|
|
|
return S_OK;
|
|
|
|
}
|