wineboot: Remove unused declaration for __wine_make_process_system.
[wine.git] / dlls / dxdiagn / provider.c
blob2890c613459b952c5f257fc8059b316e6600d375
1 /*
2 * IDxDiagProvider Implementation
3 *
4 * Copyright 2004-2005 Raphael Junqueira
5 * Copyright 2010 Andrew Nguyen
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28 #include "dxdiag_private.h"
29 #include "wine/unicode.h"
30 #include "winver.h"
31 #include "objidl.h"
32 #include "uuids.h"
33 #include "vfw.h"
34 #include "mmddk.h"
35 #include "d3d9.h"
36 #include "strmif.h"
37 #include "initguid.h"
38 #include "fil_data.h"
39 #include "psapi.h"
40 #include "wbemcli.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
46 static const WCHAR szEmpty[] = {0};
48 static HRESULT build_information_tree(IDxDiagContainerImpl_Container **pinfo_root);
49 static void free_information_tree(IDxDiagContainerImpl_Container *node);
51 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
52 static const WCHAR szDeviceName[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
53 static const WCHAR szKeyDeviceID[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
54 static const WCHAR szKeyDeviceKey[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
55 static const WCHAR szVendorId[] = {'s','z','V','e','n','d','o','r','I','d',0};
56 static const WCHAR szDeviceId[] = {'s','z','D','e','v','i','c','e','I','d',0};
57 static const WCHAR szDeviceIdentifier[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
58 static const WCHAR dwWidth[] = {'d','w','W','i','d','t','h',0};
59 static const WCHAR dwHeight[] = {'d','w','H','e','i','g','h','t',0};
60 static const WCHAR dwBpp[] = {'d','w','B','p','p',0};
61 static const WCHAR szDisplayMemoryLocalized[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','L','o','c','a','l','i','z','e','d',0};
62 static const WCHAR szDisplayMemoryEnglish[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','E','n','g','l','i','s','h',0};
63 static const WCHAR szDriverName[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0};
64 static const WCHAR szDriverVersion[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0};
65 static const WCHAR szSubSysId[] = {'s','z','S','u','b','S','y','s','I','d',0};
66 static const WCHAR szRevisionId[] = {'s','z','R','e','v','i','s','i','o','n','I','d',0};
67 static const WCHAR dwRefreshRate[] = {'d','w','R','e','f','r','e','s','h','R','a','t','e',0};
68 static const WCHAR szManufacturer[] = {'s','z','M','a','n','u','f','a','c','t','u','r','e','r',0};
69 static const WCHAR szChipType[] = {'s','z','C','h','i','p','T','y','p','e',0};
70 static const WCHAR szDACType[] = {'s','z','D','A','C','T','y','p','e',0};
71 static const WCHAR szRevision[] = {'s','z','R','e','v','i','s','i','o','n',0};
73 struct IDxDiagProviderImpl
75 IDxDiagProvider IDxDiagProvider_iface;
76 LONG ref;
77 BOOL init;
78 DXDIAG_INIT_PARAMS params;
79 IDxDiagContainerImpl_Container *info_root;
82 static inline IDxDiagProviderImpl *impl_from_IDxDiagProvider(IDxDiagProvider *iface)
84 return CONTAINING_RECORD(iface, IDxDiagProviderImpl, IDxDiagProvider_iface);
87 /* IDxDiagProvider IUnknown parts follow: */
88 static HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(IDxDiagProvider *iface, REFIID riid,
89 void **ppobj)
91 IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
93 if (!ppobj) return E_INVALIDARG;
95 if (IsEqualGUID(riid, &IID_IUnknown)
96 || IsEqualGUID(riid, &IID_IDxDiagProvider)) {
97 IUnknown_AddRef(iface);
98 *ppobj = This;
99 return S_OK;
102 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
103 *ppobj = NULL;
104 return E_NOINTERFACE;
107 static ULONG WINAPI IDxDiagProviderImpl_AddRef(IDxDiagProvider *iface)
109 IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
110 ULONG refCount = InterlockedIncrement(&This->ref);
112 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
114 DXDIAGN_LockModule();
116 return refCount;
119 static ULONG WINAPI IDxDiagProviderImpl_Release(IDxDiagProvider *iface)
121 IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
122 ULONG refCount = InterlockedDecrement(&This->ref);
124 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
126 if (!refCount) {
127 free_information_tree(This->info_root);
128 HeapFree(GetProcessHeap(), 0, This);
131 DXDIAGN_UnlockModule();
133 return refCount;
136 /* IDxDiagProvider Interface follow: */
137 static HRESULT WINAPI IDxDiagProviderImpl_Initialize(IDxDiagProvider *iface,
138 DXDIAG_INIT_PARAMS *pParams)
140 IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
141 HRESULT hr;
143 TRACE("(%p,%p)\n", iface, pParams);
145 if (NULL == pParams) {
146 return E_POINTER;
148 if (pParams->dwSize != sizeof(DXDIAG_INIT_PARAMS) ||
149 pParams->dwDxDiagHeaderVersion != DXDIAG_DX9_SDK_VERSION) {
150 return E_INVALIDARG;
153 if (!This->info_root)
155 hr = build_information_tree(&This->info_root);
156 if (FAILED(hr))
157 return hr;
160 This->init = TRUE;
161 memcpy(&This->params, pParams, pParams->dwSize);
162 return S_OK;
165 static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(IDxDiagProvider *iface,
166 IDxDiagContainer **ppInstance)
168 IDxDiagProviderImpl *This = impl_from_IDxDiagProvider(iface);
170 TRACE("(%p,%p)\n", iface, ppInstance);
172 if (FALSE == This->init) {
173 return CO_E_NOTINITIALIZED;
176 return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, This->info_root,
177 &This->IDxDiagProvider_iface, (void **)ppInstance);
180 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
182 IDxDiagProviderImpl_QueryInterface,
183 IDxDiagProviderImpl_AddRef,
184 IDxDiagProviderImpl_Release,
185 IDxDiagProviderImpl_Initialize,
186 IDxDiagProviderImpl_GetRootContainer
189 HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
190 IDxDiagProviderImpl* provider;
192 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
194 *ppobj = NULL;
195 if (punkOuter) return CLASS_E_NOAGGREGATION;
197 provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
198 if (NULL == provider) return E_OUTOFMEMORY;
199 provider->IDxDiagProvider_iface.lpVtbl = &DxDiagProvider_Vtbl;
200 provider->ref = 0; /* will be inited with QueryInterface */
201 return IDxDiagProviderImpl_QueryInterface(&provider->IDxDiagProvider_iface, riid, ppobj);
204 static void free_property_information(IDxDiagContainerImpl_Property *prop)
206 VariantClear(&prop->vProp);
207 HeapFree(GetProcessHeap(), 0, prop->propName);
208 HeapFree(GetProcessHeap(), 0, prop);
211 static void free_information_tree(IDxDiagContainerImpl_Container *node)
213 IDxDiagContainerImpl_Container *ptr, *cursor2;
215 if (!node)
216 return;
218 HeapFree(GetProcessHeap(), 0, node->contName);
220 LIST_FOR_EACH_ENTRY_SAFE(ptr, cursor2, &node->subContainers, IDxDiagContainerImpl_Container, entry)
222 IDxDiagContainerImpl_Property *prop, *prop_cursor2;
224 LIST_FOR_EACH_ENTRY_SAFE(prop, prop_cursor2, &ptr->properties, IDxDiagContainerImpl_Property, entry)
226 list_remove(&prop->entry);
227 free_property_information(prop);
230 list_remove(&ptr->entry);
231 free_information_tree(ptr);
234 HeapFree(GetProcessHeap(), 0, node);
237 static IDxDiagContainerImpl_Container *allocate_information_node(const WCHAR *name)
239 IDxDiagContainerImpl_Container *ret;
241 ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
242 if (!ret)
243 return NULL;
245 if (name)
247 ret->contName = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(*name));
248 if (!ret->contName)
250 HeapFree(GetProcessHeap(), 0, ret);
251 return NULL;
253 strcpyW(ret->contName, name);
256 list_init(&ret->subContainers);
257 list_init(&ret->properties);
259 return ret;
262 static IDxDiagContainerImpl_Property *allocate_property_information(const WCHAR *name)
264 IDxDiagContainerImpl_Property *ret;
266 ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ret));
267 if (!ret)
268 return NULL;
270 ret->propName = HeapAlloc(GetProcessHeap(), 0, (strlenW(name) + 1) * sizeof(*name));
271 if (!ret->propName)
273 HeapFree(GetProcessHeap(), 0, ret);
274 return NULL;
276 strcpyW(ret->propName, name);
278 return ret;
281 static inline void add_subcontainer(IDxDiagContainerImpl_Container *node, IDxDiagContainerImpl_Container *subCont)
283 list_add_tail(&node->subContainers, &subCont->entry);
284 ++node->nSubContainers;
287 static inline HRESULT add_bstr_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, const WCHAR *str)
289 IDxDiagContainerImpl_Property *prop;
290 BSTR bstr;
292 prop = allocate_property_information(propName);
293 if (!prop)
294 return E_OUTOFMEMORY;
296 bstr = SysAllocString(str);
297 if (!bstr)
299 free_property_information(prop);
300 return E_OUTOFMEMORY;
303 V_VT(&prop->vProp) = VT_BSTR;
304 V_BSTR(&prop->vProp) = bstr;
306 list_add_tail(&node->properties, &prop->entry);
307 ++node->nProperties;
309 return S_OK;
312 static inline HRESULT add_ui4_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, DWORD data)
314 IDxDiagContainerImpl_Property *prop;
316 prop = allocate_property_information(propName);
317 if (!prop)
318 return E_OUTOFMEMORY;
320 V_VT(&prop->vProp) = VT_UI4;
321 V_UI4(&prop->vProp) = data;
323 list_add_tail(&node->properties, &prop->entry);
324 ++node->nProperties;
326 return S_OK;
329 static inline HRESULT add_bool_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, BOOL data)
331 IDxDiagContainerImpl_Property *prop;
333 prop = allocate_property_information(propName);
334 if (!prop)
335 return E_OUTOFMEMORY;
337 V_VT(&prop->vProp) = VT_BOOL;
338 V_BOOL(&prop->vProp) = data ? VARIANT_TRUE : VARIANT_FALSE;
340 list_add_tail(&node->properties, &prop->entry);
341 ++node->nProperties;
343 return S_OK;
346 static inline HRESULT add_ull_as_bstr_property(IDxDiagContainerImpl_Container *node, const WCHAR *propName, ULONGLONG data )
348 IDxDiagContainerImpl_Property *prop;
350 prop = allocate_property_information(propName);
351 if (!prop)
352 return E_OUTOFMEMORY;
354 V_VT(&prop->vProp) = VT_UI8;
355 V_UI8(&prop->vProp) = data;
357 VariantChangeType(&prop->vProp, &prop->vProp, 0, VT_BSTR);
359 list_add_tail(&node->properties, &prop->entry);
360 ++node->nProperties;
362 return S_OK;
365 /* Copied from programs/taskkill/taskkill.c. */
366 static DWORD *enumerate_processes(DWORD *list_count)
368 DWORD *pid_list, alloc_bytes = 1024 * sizeof(*pid_list), needed_bytes;
370 pid_list = HeapAlloc(GetProcessHeap(), 0, alloc_bytes);
371 if (!pid_list)
372 return NULL;
374 for (;;)
376 DWORD *realloc_list;
378 if (!EnumProcesses(pid_list, alloc_bytes, &needed_bytes))
380 HeapFree(GetProcessHeap(), 0, pid_list);
381 return NULL;
384 /* EnumProcesses can't signal an insufficient buffer condition, so the
385 * only way to possibly determine whether a larger buffer is required
386 * is to see whether the written number of bytes is the same as the
387 * buffer size. If so, the buffer will be reallocated to twice the
388 * size. */
389 if (alloc_bytes != needed_bytes)
390 break;
392 alloc_bytes *= 2;
393 realloc_list = HeapReAlloc(GetProcessHeap(), 0, pid_list, alloc_bytes);
394 if (!realloc_list)
396 HeapFree(GetProcessHeap(), 0, pid_list);
397 return NULL;
399 pid_list = realloc_list;
402 *list_count = needed_bytes / sizeof(*pid_list);
403 return pid_list;
406 /* Copied from programs/taskkill/taskkill.c. */
407 static BOOL get_process_name_from_pid(DWORD pid, WCHAR *buf, DWORD chars)
409 HANDLE process;
410 HMODULE module;
411 DWORD required_size;
413 process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
414 if (!process)
415 return FALSE;
417 if (!EnumProcessModules(process, &module, sizeof(module), &required_size))
419 CloseHandle(process);
420 return FALSE;
423 if (!GetModuleBaseNameW(process, module, buf, chars))
425 CloseHandle(process);
426 return FALSE;
429 CloseHandle(process);
430 return TRUE;
433 /* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
434 static BOOL is_netmeeting_running(void)
436 static const WCHAR conf_exe[] = {'c','o','n','f','.','e','x','e',0};
438 DWORD list_count;
439 DWORD *pid_list = enumerate_processes(&list_count);
441 if (pid_list)
443 DWORD i;
444 WCHAR process_name[MAX_PATH];
446 for (i = 0; i < list_count; i++)
448 if (get_process_name_from_pid(pid_list[i], process_name, sizeof(process_name)/sizeof(WCHAR)) &&
449 !lstrcmpW(conf_exe, process_name))
451 HeapFree(GetProcessHeap(), 0, pid_list);
452 return TRUE;
455 HeapFree(GetProcessHeap(), 0, pid_list);
458 return FALSE;
461 static HRESULT fill_language_information(IDxDiagContainerImpl_Container *node)
463 static const WCHAR regional_setting_engW[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
464 static const WCHAR languages_fmtW[] = {'%','s',' ','(','%','s',':',' ','%','s',')',0};
465 static const WCHAR szLanguagesLocalized[] = {'s','z','L','a','n','g','u','a','g','e','s','L','o','c','a','l','i','z','e','d',0};
466 static const WCHAR szLanguagesEnglish[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
468 WCHAR system_lang[80], regional_setting[100], user_lang[80], language_str[300];
469 HRESULT hr;
471 /* szLanguagesLocalized */
472 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SNATIVELANGNAME, system_lang, sizeof(system_lang)/sizeof(WCHAR));
473 LoadStringW(dxdiagn_instance, IDS_REGIONAL_SETTING, regional_setting, sizeof(regional_setting)/sizeof(WCHAR));
474 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SNATIVELANGNAME, user_lang, sizeof(user_lang)/sizeof(WCHAR));
476 snprintfW(language_str, sizeof(language_str)/sizeof(WCHAR), languages_fmtW, system_lang, regional_setting, user_lang);
478 hr = add_bstr_property(node, szLanguagesLocalized, language_str);
479 if (FAILED(hr))
480 return hr;
482 /* szLanguagesEnglish */
483 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, system_lang, sizeof(system_lang)/sizeof(WCHAR));
484 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, user_lang, sizeof(user_lang)/sizeof(WCHAR));
486 snprintfW(language_str, sizeof(language_str)/sizeof(WCHAR), languages_fmtW, system_lang, regional_setting_engW, user_lang);
488 hr = add_bstr_property(node, szLanguagesEnglish, language_str);
489 if (FAILED(hr))
490 return hr;
492 return S_OK;
495 static HRESULT fill_datetime_information(IDxDiagContainerImpl_Container *node)
497 static const WCHAR date_fmtW[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0};
498 static const WCHAR time_fmtW[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
499 static const WCHAR datetime_fmtW[] = {'%','s',',',' ','%','s',0};
500 static const WCHAR szTimeLocalized[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
501 static const WCHAR szTimeEnglish[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
503 SYSTEMTIME curtime;
504 WCHAR date_str[80], time_str[80], datetime_str[200];
505 HRESULT hr;
507 GetLocalTime(&curtime);
509 GetTimeFormatW(LOCALE_NEUTRAL, 0, &curtime, time_fmtW, time_str, sizeof(time_str)/sizeof(WCHAR));
511 /* szTimeLocalized */
512 GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &curtime, NULL, date_str, sizeof(date_str)/sizeof(WCHAR));
514 snprintfW(datetime_str, sizeof(datetime_str)/sizeof(WCHAR), datetime_fmtW, date_str, time_str);
516 hr = add_bstr_property(node, szTimeLocalized, datetime_str);
517 if (FAILED(hr))
518 return hr;
520 /* szTimeEnglish */
521 GetDateFormatW(LOCALE_NEUTRAL, 0, &curtime, date_fmtW, date_str, sizeof(date_str)/sizeof(WCHAR));
523 snprintfW(datetime_str, sizeof(datetime_str)/sizeof(WCHAR), datetime_fmtW, date_str, time_str);
525 hr = add_bstr_property(node, szTimeEnglish, datetime_str);
526 if (FAILED(hr))
527 return hr;
529 return S_OK;
532 static HRESULT fill_os_string_information(IDxDiagContainerImpl_Container *node, OSVERSIONINFOW *info)
534 static const WCHAR winxpW[] = {'W','i','n','d','o','w','s',' ','X','P',' ','P','r','o','f','e','s','s','i','o','n','a','l',0};
535 static const WCHAR szOSLocalized[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
536 static const WCHAR szOSExLocalized[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
537 static const WCHAR szOSExLongLocalized[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
538 static const WCHAR szOSEnglish[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
539 static const WCHAR szOSExEnglish[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
540 static const WCHAR szOSExLongEnglish[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
542 static const WCHAR *prop_list[] = {szOSLocalized, szOSExLocalized, szOSExLongLocalized,
543 szOSEnglish, szOSExEnglish, szOSExLongEnglish};
545 size_t i;
546 HRESULT hr;
548 /* FIXME: OS detection should be performed, and localized OS strings
549 * should contain translated versions of the "build" phrase. */
550 for (i = 0; i < sizeof(prop_list)/sizeof(prop_list[0]); i++)
552 hr = add_bstr_property(node, prop_list[i], winxpW);
553 if (FAILED(hr))
554 return hr;
557 return S_OK;
560 static HRESULT fill_processor_information(IDxDiagContainerImpl_Container *node)
562 static const WCHAR szProcessorEnglish[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
564 static const WCHAR cimv2W[] = {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
565 static const WCHAR proc_classW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
566 static const WCHAR nameW[] = {'N','a','m','e',0};
567 static const WCHAR max_clock_speedW[] = {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
568 static const WCHAR cpu_noW[] = {'N','u','m','b','e','r','O','f','L','o','g','i','c','a','l','P','r','o','c','e','s','s','o','r','s',0};
570 static const WCHAR processor_fmtW[] = {'%','s','(','%','d',' ','C','P','U','s',')',',',' ','~','%','d','M','H','z',0};
572 IWbemLocator *wbem_locator;
573 IWbemServices *wbem_service;
574 IWbemClassObject *wbem_class;
575 IEnumWbemClassObject *wbem_enum;
576 VARIANT cpu_name, cpu_no, clock_speed;
577 WCHAR print_buf[200];
578 BSTR bstr;
579 ULONG no;
580 HRESULT hr;
582 hr = CoCreateInstance(&CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void**)&wbem_locator);
583 if(FAILED(hr))
584 return hr;
586 bstr = SysAllocString(cimv2W);
587 if(!bstr) {
588 IWbemLocator_Release(wbem_locator);
589 return E_OUTOFMEMORY;
591 hr = IWbemLocator_ConnectServer(wbem_locator, bstr, NULL, NULL, NULL, 0, NULL, NULL, &wbem_service);
592 IWbemLocator_Release(wbem_locator);
593 SysFreeString(bstr);
594 if(FAILED(hr))
595 return hr;
597 bstr = SysAllocString(proc_classW);
598 if(!bstr) {
599 IWbemServices_Release(wbem_service);
600 return E_OUTOFMEMORY;
602 hr = IWbemServices_CreateInstanceEnum(wbem_service, bstr, WBEM_FLAG_SYSTEM_ONLY, NULL, &wbem_enum);
603 IWbemServices_Release(wbem_service);
604 SysFreeString(bstr);
605 if(FAILED(hr))
606 return hr;
608 hr = IEnumWbemClassObject_Next(wbem_enum, 1000, 1, &wbem_class, &no);
609 IEnumWbemClassObject_Release(wbem_enum);
610 if(FAILED(hr))
611 return hr;
613 hr = IWbemClassObject_Get(wbem_class, cpu_noW, 0, &cpu_no, NULL, NULL);
614 if(FAILED(hr)) {
615 IWbemClassObject_Release(wbem_class);
616 return hr;
618 hr = IWbemClassObject_Get(wbem_class, max_clock_speedW, 0, &clock_speed, NULL, NULL);
619 if(FAILED(hr)) {
620 IWbemClassObject_Release(wbem_class);
621 return hr;
623 hr = IWbemClassObject_Get(wbem_class, nameW, 0, &cpu_name, NULL, NULL);
624 IWbemClassObject_Release(wbem_class);
625 if(FAILED(hr))
626 return hr;
628 sprintfW(print_buf, processor_fmtW, V_BSTR(&cpu_name), V_I4(&cpu_no), V_I4(&clock_speed));
629 VariantClear(&cpu_name);
630 VariantClear(&cpu_no);
631 VariantClear(&clock_speed);
633 return add_bstr_property(node, szProcessorEnglish, print_buf);
636 static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node)
638 static const WCHAR dwDirectXVersionMajor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','a','j','o','r',0};
639 static const WCHAR dwDirectXVersionMinor[] = {'d','w','D','i','r','e','c','t','X','V','e','r','s','i','o','n','M','i','n','o','r',0};
640 static const WCHAR szDirectXVersionLetter[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','e','t','t','e','r',0};
641 static const WCHAR szDirectXVersionLetter_v[] = {'c',0};
642 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
643 static const WCHAR bNECPC98[] = {'b','N','E','C','P','C','9','8',0};
644 static const WCHAR szDirectXVersionEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','E','n','g','l','i','s','h',0};
645 static const WCHAR szDirectXVersionEnglish_v[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
646 static const WCHAR szDirectXVersionLongEnglish[] = {'s','z','D','i','r','e','c','t','X','V','e','r','s','i','o','n','L','o','n','g','E','n','g','l','i','s','h',0};
647 static const WCHAR szDirectXVersionLongEnglish_v[] = {'=',' ','"','D','i','r','e','c','t','X',' ','9','.','0','c',' ','(','4','.','0','9','.','0','0','0','0','.','0','9','0','4',')',0};
648 static const WCHAR ullPhysicalMemory[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
649 static const WCHAR ullUsedPageFile[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
650 static const WCHAR ullAvailPageFile[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
651 static const WCHAR bNetMeetingRunning[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
652 static const WCHAR szWindowsDir[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
653 static const WCHAR dwOSMajorVersion[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
654 static const WCHAR dwOSMinorVersion[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
655 static const WCHAR dwOSBuildNumber[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
656 static const WCHAR dwOSPlatformID[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
657 static const WCHAR szCSDVersion[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
658 static const WCHAR szPhysicalMemoryEnglish[] = {'s','z','P','h','y','s','i','c','a','l','M','e','m','o','r','y','E','n','g','l','i','s','h',0};
659 static const WCHAR szPageFileLocalized[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
660 static const WCHAR szPageFileEnglish[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
661 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};
662 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};
663 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};
664 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};
665 static const WCHAR szBIOSEnglish[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
666 static const WCHAR szSetupParamEnglish[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
667 static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
669 static const WCHAR notpresentW[] = {'N','o','t',' ','p','r','e','s','e','n','t',0};
671 static const WCHAR pagefile_fmtW[] = {'%','u','M','B',' ','u','s','e','d',',',' ','%','u','M','B',' ','a','v','a','i','l','a','b','l','e',0};
672 static const WCHAR physmem_fmtW[] = {'%','u','M','B',' ','R','A','M',0};
674 HRESULT hr;
675 MEMORYSTATUSEX msex;
676 OSVERSIONINFOW info;
677 DWORD count, usedpage_mb, availpage_mb;
678 WCHAR buffer[MAX_PATH], computer_name[MAX_COMPUTERNAME_LENGTH + 1], print_buf[200], localized_pagefile_fmt[200];
679 DWORD_PTR args[2];
681 hr = add_ui4_property(node, dwDirectXVersionMajor, 9);
682 if (FAILED(hr))
683 return hr;
685 hr = add_ui4_property(node, dwDirectXVersionMinor, 0);
686 if (FAILED(hr))
687 return hr;
689 hr = add_bstr_property(node, szDirectXVersionLetter, szDirectXVersionLetter_v);
690 if (FAILED(hr))
691 return hr;
693 hr = add_bstr_property(node, szDirectXVersionEnglish, szDirectXVersionEnglish_v);
694 if (FAILED(hr))
695 return hr;
697 hr = add_bstr_property(node, szDirectXVersionLongEnglish, szDirectXVersionLongEnglish_v);
698 if (FAILED(hr))
699 return hr;
701 hr = add_bool_property(node, bDebug, FALSE);
702 if (FAILED(hr))
703 return hr;
705 hr = add_bool_property(node, bNECPC98, FALSE);
706 if (FAILED(hr))
707 return hr;
709 msex.dwLength = sizeof(msex);
710 GlobalMemoryStatusEx(&msex);
712 hr = add_ull_as_bstr_property(node, ullPhysicalMemory, msex.ullTotalPhys);
713 if (FAILED(hr))
714 return hr;
716 hr = add_ull_as_bstr_property(node, ullUsedPageFile, msex.ullTotalPageFile - msex.ullAvailPageFile);
717 if (FAILED(hr))
718 return hr;
720 hr = add_ull_as_bstr_property(node, ullAvailPageFile, msex.ullAvailPageFile);
721 if (FAILED(hr))
722 return hr;
724 hr = add_bool_property(node, bNetMeetingRunning, is_netmeeting_running());
725 if (FAILED(hr))
726 return hr;
728 info.dwOSVersionInfoSize = sizeof(info);
729 GetVersionExW(&info);
731 hr = add_ui4_property(node, dwOSMajorVersion, info.dwMajorVersion);
732 if (FAILED(hr))
733 return hr;
735 hr = add_ui4_property(node, dwOSMinorVersion, info.dwMinorVersion);
736 if (FAILED(hr))
737 return hr;
739 hr = add_ui4_property(node, dwOSBuildNumber, info.dwBuildNumber);
740 if (FAILED(hr))
741 return hr;
743 hr = add_ui4_property(node, dwOSPlatformID, info.dwPlatformId);
744 if (FAILED(hr))
745 return hr;
747 hr = add_bstr_property(node, szCSDVersion, info.szCSDVersion);
748 if (FAILED(hr))
749 return hr;
751 /* FIXME: Roundoff should not be done with truncated division. */
752 snprintfW(print_buf, sizeof(print_buf)/sizeof(WCHAR), physmem_fmtW, (DWORD)(msex.ullTotalPhys / (1024 * 1024)));
753 hr = add_bstr_property(node, szPhysicalMemoryEnglish, print_buf);
754 if (FAILED(hr))
755 return hr;
757 usedpage_mb = (DWORD)((msex.ullTotalPageFile - msex.ullAvailPageFile) / (1024 * 1024));
758 availpage_mb = (DWORD)(msex.ullAvailPageFile / (1024 * 1024));
759 LoadStringW(dxdiagn_instance, IDS_PAGE_FILE_FORMAT, localized_pagefile_fmt, sizeof(localized_pagefile_fmt)/sizeof(WCHAR));
760 args[0] = usedpage_mb;
761 args[1] = availpage_mb;
762 FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
763 localized_pagefile_fmt, 0, 0, print_buf,
764 sizeof(print_buf)/sizeof(*print_buf), (__ms_va_list*)args);
766 hr = add_bstr_property(node, szPageFileLocalized, print_buf);
767 if (FAILED(hr))
768 return hr;
770 snprintfW(print_buf, sizeof(print_buf)/sizeof(WCHAR), pagefile_fmtW, usedpage_mb, availpage_mb);
772 hr = add_bstr_property(node, szPageFileEnglish, print_buf);
773 if (FAILED(hr))
774 return hr;
776 GetWindowsDirectoryW(buffer, MAX_PATH);
778 hr = add_bstr_property(node, szWindowsDir, buffer);
779 if (FAILED(hr))
780 return hr;
782 count = sizeof(computer_name)/sizeof(WCHAR);
783 if (!GetComputerNameW(computer_name, &count))
784 return E_FAIL;
786 hr = add_bstr_property(node, szMachineNameLocalized, computer_name);
787 if (FAILED(hr))
788 return hr;
790 hr = add_bstr_property(node, szMachineNameEnglish, computer_name);
791 if (FAILED(hr))
792 return hr;
794 hr = add_bstr_property(node, szSystemManufacturerEnglish, szEmpty);
795 if (FAILED(hr))
796 return hr;
798 hr = add_bstr_property(node, szSystemModelEnglish, szEmpty);
799 if (FAILED(hr))
800 return hr;
802 hr = add_bstr_property(node, szBIOSEnglish, szEmpty);
803 if (FAILED(hr))
804 return hr;
806 hr = fill_processor_information(node);
807 if (FAILED(hr))
808 return hr;
810 hr = add_bstr_property(node, szSetupParamEnglish, notpresentW);
811 if (FAILED(hr))
812 return hr;
814 hr = add_bstr_property(node, szDxDiagVersion, szEmpty);
815 if (FAILED(hr))
816 return hr;
818 hr = fill_language_information(node);
819 if (FAILED(hr))
820 return hr;
822 hr = fill_datetime_information(node);
823 if (FAILED(hr))
824 return hr;
826 hr = fill_os_string_information(node, &info);
827 if (FAILED(hr))
828 return hr;
830 return S_OK;
833 /* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
834 static DWORD depth_for_pixelformat(D3DFORMAT format)
836 switch (format)
838 case D3DFMT_P8: return 8;
839 case D3DFMT_X1R5G5B5: return 15;
840 case D3DFMT_R5G6B5: return 16;
841 /* This case will fail to distinguish an original bpp of 24. */
842 case D3DFMT_X8R8G8B8: return 32;
843 default:
844 FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format);
845 return 32;
849 static BOOL get_texture_memory(GUID *adapter, DWORD *available_mem)
851 IDirectDraw7 *pDirectDraw;
852 HRESULT hr;
853 DDSCAPS2 dd_caps;
855 hr = DirectDrawCreateEx(adapter, (void **)&pDirectDraw, &IID_IDirectDraw7, NULL);
856 if (SUCCEEDED(hr))
858 dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
859 dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.u1.dwCaps4 = 0;
860 hr = IDirectDraw7_GetAvailableVidMem(pDirectDraw, &dd_caps, available_mem, NULL);
861 IDirectDraw7_Release(pDirectDraw);
862 if (SUCCEEDED(hr))
863 return TRUE;
866 return FALSE;
869 static const WCHAR *vendor_id_to_manufacturer_string(DWORD vendor_id)
871 static const WCHAR atiW[] = {'A','T','I',' ','T','e','c','h','n','o','l','o','g','i','e','s',' ','I','n','c','.',0};
872 static const WCHAR nvidiaW[] = {'N','V','I','D','I','A',0};
873 static const WCHAR intelW[] = {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
874 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
876 /* Enumeration copied from dlls/wined3d/wined3d_private.h and slightly modified. */
877 enum pci_vendor
879 HW_VENDOR_AMD = 0x1002,
880 HW_VENDOR_NVIDIA = 0x10de,
881 HW_VENDOR_INTEL = 0x8086,
884 switch (vendor_id)
886 case HW_VENDOR_AMD:
887 return atiW;
888 case HW_VENDOR_NVIDIA:
889 return nvidiaW;
890 case HW_VENDOR_INTEL:
891 return intelW;
892 default:
893 FIXME("Unknown PCI vendor ID 0x%04x\n", vendor_id);
894 return unknownW;
898 static HRESULT fill_display_information_d3d(IDxDiagContainerImpl_Container *node)
900 IDxDiagContainerImpl_Container *display_adapter;
901 HRESULT hr;
902 IDirect3D9 *pDirect3D9;
903 WCHAR buffer[256];
904 UINT index, count;
906 pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION);
907 if (!pDirect3D9)
908 return E_FAIL;
910 count = IDirect3D9_GetAdapterCount(pDirect3D9);
911 for (index = 0; index < count; index++)
913 static const WCHAR adapterid_fmtW[] = {'%','u',0};
914 static const WCHAR driverversion_fmtW[] = {'%','u','.','%','u','.','%','0','4','u','.','%','0','4','u',0};
915 static const WCHAR id_fmtW[] = {'0','x','%','0','4','x',0};
916 static const WCHAR subsysid_fmtW[] = {'0','x','%','0','8','x',0};
917 static const WCHAR mem_fmt[] = {'%','.','1','f',' ','M','B',0};
918 static const WCHAR b3DAccelerationExists[] = {'b','3','D','A','c','c','e','l','e','r','a','t','i','o','n','E','x','i','s','t','s',0};
919 static const WCHAR b3DAccelerationEnabled[] = {'b','3','D','A','c','c','e','l','e','r','a','t','i','o','n','E','n','a','b','l','e','d',0};
920 static const WCHAR bDDAccelerationEnabled[] = {'b','D','D','A','c','c','e','l','e','r','a','t','i','o','n','E','n','a','b','l','e','d',0};
921 static const WCHAR bNoHardware[] = {'b','N','o','H','a','r','d','w','a','r','e',0};
923 D3DADAPTER_IDENTIFIER9 adapter_info;
924 D3DDISPLAYMODE adapter_mode;
925 D3DCAPS9 device_caps;
926 DWORD available_mem = 0;
927 BOOL hardware_accel;
929 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), adapterid_fmtW, index);
930 display_adapter = allocate_information_node(buffer);
931 if (!display_adapter)
933 hr = E_OUTOFMEMORY;
934 goto cleanup;
937 add_subcontainer(node, display_adapter);
939 hr = IDirect3D9_GetAdapterIdentifier(pDirect3D9, index, 0, &adapter_info);
940 if (SUCCEEDED(hr))
942 WCHAR driverW[sizeof(adapter_info.Driver)];
943 WCHAR descriptionW[sizeof(adapter_info.Description)];
944 WCHAR devicenameW[sizeof(adapter_info.DeviceName)];
946 MultiByteToWideChar(CP_ACP, 0, adapter_info.Driver, -1, driverW, sizeof(driverW)/sizeof(WCHAR));
947 MultiByteToWideChar(CP_ACP, 0, adapter_info.Description, -1, descriptionW, sizeof(descriptionW)/sizeof(WCHAR));
948 MultiByteToWideChar(CP_ACP, 0, adapter_info.DeviceName, -1, devicenameW, sizeof(devicenameW)/sizeof(WCHAR));
950 hr = add_bstr_property(display_adapter, szDriverName, driverW);
951 if (FAILED(hr))
952 goto cleanup;
954 hr = add_bstr_property(display_adapter, szDescription, descriptionW);
955 if (FAILED(hr))
956 goto cleanup;
958 hr = add_bstr_property(display_adapter, szDeviceName, devicenameW);
959 if (FAILED(hr))
960 goto cleanup;
962 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), driverversion_fmtW,
963 HIWORD(adapter_info.DriverVersion.u.HighPart), LOWORD(adapter_info.DriverVersion.u.HighPart),
964 HIWORD(adapter_info.DriverVersion.u.LowPart), LOWORD(adapter_info.DriverVersion.u.LowPart));
966 hr = add_bstr_property(display_adapter, szDriverVersion, buffer);
967 if (FAILED(hr))
968 goto cleanup;
970 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), id_fmtW, adapter_info.VendorId);
971 hr = add_bstr_property(display_adapter, szVendorId, buffer);
972 if (FAILED(hr))
973 goto cleanup;
975 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), id_fmtW, adapter_info.DeviceId);
976 hr = add_bstr_property(display_adapter, szDeviceId, buffer);
977 if (FAILED(hr))
978 goto cleanup;
980 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), subsysid_fmtW, adapter_info.SubSysId);
981 hr = add_bstr_property(display_adapter, szSubSysId, buffer);
982 if (FAILED(hr))
983 goto cleanup;
985 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), id_fmtW, adapter_info.Revision);
986 hr = add_bstr_property(display_adapter, szRevisionId, buffer);
987 if (FAILED(hr))
988 goto cleanup;
990 StringFromGUID2(&adapter_info.DeviceIdentifier, buffer, 39);
991 hr = add_bstr_property(display_adapter, szDeviceIdentifier, buffer);
992 if (FAILED(hr))
993 goto cleanup;
995 hr = add_bstr_property(display_adapter, szManufacturer, vendor_id_to_manufacturer_string(adapter_info.VendorId));
996 if (FAILED(hr))
997 goto cleanup;
1000 hr = IDirect3D9_GetAdapterDisplayMode(pDirect3D9, index, &adapter_mode);
1001 if (SUCCEEDED(hr))
1003 hr = add_ui4_property(display_adapter, dwWidth, adapter_mode.Width);
1004 if (FAILED(hr))
1005 goto cleanup;
1007 hr = add_ui4_property(display_adapter, dwHeight, adapter_mode.Height);
1008 if (FAILED(hr))
1009 goto cleanup;
1011 hr = add_ui4_property(display_adapter, dwRefreshRate, adapter_mode.RefreshRate);
1012 if (FAILED(hr))
1013 goto cleanup;
1015 hr = add_ui4_property(display_adapter, dwBpp, depth_for_pixelformat(adapter_mode.Format));
1016 if (FAILED(hr))
1017 goto cleanup;
1020 hr = add_bstr_property(display_adapter, szKeyDeviceKey, szEmpty);
1021 if (FAILED(hr))
1022 goto cleanup;
1024 hr = add_bstr_property(display_adapter, szKeyDeviceID, szEmpty);
1025 if (FAILED(hr))
1026 goto cleanup;
1028 hr = add_bstr_property(display_adapter, szChipType, szEmpty);
1029 if (FAILED(hr))
1030 goto cleanup;
1032 hr = add_bstr_property(display_adapter, szDACType, szEmpty);
1033 if (FAILED(hr))
1034 goto cleanup;
1036 hr = add_bstr_property(display_adapter, szRevision, szEmpty);
1037 if (FAILED(hr))
1038 goto cleanup;
1040 if (!get_texture_memory(&adapter_info.DeviceIdentifier, &available_mem))
1041 WARN("get_texture_memory helper failed\n");
1043 snprintfW(buffer, sizeof(buffer)/sizeof(buffer[0]), mem_fmt, available_mem / 1000000.0f);
1045 hr = add_bstr_property(display_adapter, szDisplayMemoryLocalized, buffer);
1046 if (FAILED(hr))
1047 goto cleanup;
1049 hr = add_bstr_property(display_adapter, szDisplayMemoryEnglish, buffer);
1050 if (FAILED(hr))
1051 goto cleanup;
1053 hr = IDirect3D9_GetDeviceCaps(pDirect3D9, index, D3DDEVTYPE_HAL, &device_caps);
1054 hardware_accel = SUCCEEDED(hr);
1056 hr = add_bool_property(display_adapter, b3DAccelerationEnabled, hardware_accel);
1057 if (FAILED(hr))
1058 goto cleanup;
1060 hr = add_bool_property(display_adapter, b3DAccelerationExists, hardware_accel);
1061 if (FAILED(hr))
1062 goto cleanup;
1064 hr = add_bool_property(display_adapter, bDDAccelerationEnabled, hardware_accel);
1065 if (FAILED(hr))
1066 goto cleanup;
1068 hr = add_bool_property(display_adapter, bNoHardware, FALSE);
1069 if (FAILED(hr))
1070 goto cleanup;
1073 hr = S_OK;
1074 cleanup:
1075 IDirect3D9_Release(pDirect3D9);
1076 return hr;
1079 static HRESULT fill_display_information_fallback(IDxDiagContainerImpl_Container *node)
1081 static const WCHAR szAdapterID[] = {'0',0};
1082 static const WCHAR *empty_properties[] = {szDeviceIdentifier, szVendorId, szDeviceId,
1083 szKeyDeviceKey, szKeyDeviceID, szDriverName,
1084 szDriverVersion, szSubSysId, szRevisionId,
1085 szManufacturer, szChipType, szDACType, szRevision};
1087 IDxDiagContainerImpl_Container *display_adapter;
1088 HRESULT hr;
1089 IDirectDraw7 *pDirectDraw;
1090 DDSCAPS2 dd_caps;
1091 DISPLAY_DEVICEW disp_dev;
1092 DDSURFACEDESC2 surface_descr;
1093 DWORD tmp;
1094 WCHAR buffer[256];
1096 display_adapter = allocate_information_node(szAdapterID);
1097 if (!display_adapter)
1098 return E_OUTOFMEMORY;
1100 add_subcontainer(node, display_adapter);
1102 disp_dev.cb = sizeof(disp_dev);
1103 if (EnumDisplayDevicesW( NULL, 0, &disp_dev, 0 ))
1105 hr = add_bstr_property(display_adapter, szDeviceName, disp_dev.DeviceName);
1106 if (FAILED(hr))
1107 return hr;
1109 hr = add_bstr_property(display_adapter, szDescription, disp_dev.DeviceString);
1110 if (FAILED(hr))
1111 return hr;
1114 /* Silently ignore a failure from DirectDrawCreateEx. */
1115 hr = DirectDrawCreateEx(NULL, (void **)&pDirectDraw, &IID_IDirectDraw7, NULL);
1116 if (FAILED(hr))
1117 return S_OK;
1119 dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
1120 dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.u1.dwCaps4 = 0;
1121 hr = IDirectDraw7_GetAvailableVidMem(pDirectDraw, &dd_caps, &tmp, NULL);
1122 if (SUCCEEDED(hr))
1124 static const WCHAR mem_fmt[] = {'%','.','1','f',' ','M','B',0};
1126 snprintfW(buffer, sizeof(buffer)/sizeof(buffer[0]), mem_fmt, tmp / 1000000.0f);
1128 hr = add_bstr_property(display_adapter, szDisplayMemoryLocalized, buffer);
1129 if (FAILED(hr))
1130 goto cleanup;
1132 hr = add_bstr_property(display_adapter, szDisplayMemoryEnglish, buffer);
1133 if (FAILED(hr))
1134 goto cleanup;
1137 surface_descr.dwSize = sizeof(surface_descr);
1138 hr = IDirectDraw7_GetDisplayMode(pDirectDraw, &surface_descr);
1139 if (SUCCEEDED(hr))
1141 if (surface_descr.dwFlags & DDSD_WIDTH)
1143 hr = add_ui4_property(display_adapter, dwWidth, surface_descr.dwWidth);
1144 if (FAILED(hr))
1145 goto cleanup;
1148 if (surface_descr.dwFlags & DDSD_HEIGHT)
1150 hr = add_ui4_property(display_adapter, dwHeight, surface_descr.dwHeight);
1151 if (FAILED(hr))
1152 goto cleanup;
1155 if (surface_descr.dwFlags & DDSD_PIXELFORMAT)
1157 hr = add_ui4_property(display_adapter, dwBpp, surface_descr.u4.ddpfPixelFormat.u1.dwRGBBitCount);
1158 if (FAILED(hr))
1159 goto cleanup;
1163 hr = add_ui4_property(display_adapter, dwRefreshRate, 60);
1164 if (FAILED(hr))
1165 goto cleanup;
1167 for (tmp = 0; tmp < sizeof(empty_properties)/sizeof(empty_properties[0]); tmp++)
1169 hr = add_bstr_property(display_adapter, empty_properties[tmp], szEmpty);
1170 if (FAILED(hr))
1171 goto cleanup;
1174 hr = S_OK;
1175 cleanup:
1176 IDirectDraw7_Release(pDirectDraw);
1177 return hr;
1180 static HRESULT build_displaydevices_tree(IDxDiagContainerImpl_Container *node)
1182 HRESULT hr;
1184 /* Try to use Direct3D to obtain the required information first. */
1185 hr = fill_display_information_d3d(node);
1186 if (hr != E_FAIL)
1187 return hr;
1189 return fill_display_information_fallback(node);
1192 static HRESULT build_directsound_tree(IDxDiagContainerImpl_Container *node)
1194 static const WCHAR DxDiag_SoundDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
1195 static const WCHAR DxDiag_SoundCaptureDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','C','a','p','t','u','r','e','D','e','v','i','c','e','s',0};
1197 IDxDiagContainerImpl_Container *cont;
1199 cont = allocate_information_node(DxDiag_SoundDevices);
1200 if (!cont)
1201 return E_OUTOFMEMORY;
1203 add_subcontainer(node, cont);
1205 cont = allocate_information_node(DxDiag_SoundCaptureDevices);
1206 if (!cont)
1207 return E_OUTOFMEMORY;
1209 add_subcontainer(node, cont);
1211 return S_OK;
1214 static HRESULT build_directmusic_tree(IDxDiagContainerImpl_Container *node)
1216 return S_OK;
1219 static HRESULT build_directinput_tree(IDxDiagContainerImpl_Container *node)
1221 return S_OK;
1224 static HRESULT build_directplay_tree(IDxDiagContainerImpl_Container *node)
1226 return S_OK;
1229 static HRESULT build_systemdevices_tree(IDxDiagContainerImpl_Container *node)
1231 return S_OK;
1234 static HRESULT fill_file_description(IDxDiagContainerImpl_Container *node, const WCHAR *szFilePath, const WCHAR *szFileName)
1236 static const WCHAR szSlashSep[] = {'\\',0};
1237 static const WCHAR szPath[] = {'s','z','P','a','t','h',0};
1238 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
1239 static const WCHAR szVersion[] = {'s','z','V','e','r','s','i','o','n',0};
1240 static const WCHAR szAttributes[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
1241 static const WCHAR szLanguageEnglish[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
1242 static const WCHAR dwFileTimeHigh[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
1243 static const WCHAR dwFileTimeLow[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
1244 static const WCHAR bBeta[] = {'b','B','e','t','a',0};
1245 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
1246 static const WCHAR bExists[] = {'b','E','x','i','s','t','s',0};
1248 /* Values */
1249 static const WCHAR szFinal_Retail_v[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
1250 static const WCHAR szEnglish_v[] = {'E','n','g','l','i','s','h',0};
1251 static const WCHAR szVersionFormat[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
1253 HRESULT hr;
1254 WCHAR *szFile;
1255 WCHAR szVersion_v[1024];
1256 DWORD retval, hdl;
1257 void *pVersionInfo = NULL;
1258 BOOL boolret = FALSE;
1259 UINT uiLength;
1260 VS_FIXEDFILEINFO *pFileInfo;
1262 TRACE("Filling container %p for %s in %s\n", node,
1263 debugstr_w(szFileName), debugstr_w(szFilePath));
1265 szFile = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(szFilePath) +
1266 lstrlenW(szFileName) + 2 /* slash + terminator */));
1267 if (!szFile)
1268 return E_OUTOFMEMORY;
1270 lstrcpyW(szFile, szFilePath);
1271 lstrcatW(szFile, szSlashSep);
1272 lstrcatW(szFile, szFileName);
1274 retval = GetFileVersionInfoSizeW(szFile, &hdl);
1275 if (retval)
1277 pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
1278 if (!pVersionInfo)
1280 hr = E_OUTOFMEMORY;
1281 goto cleanup;
1284 if (GetFileVersionInfoW(szFile, 0, retval, pVersionInfo) &&
1285 VerQueryValueW(pVersionInfo, szSlashSep, (void **)&pFileInfo, &uiLength))
1286 boolret = TRUE;
1289 hr = add_bstr_property(node, szPath, szFile);
1290 if (FAILED(hr))
1291 goto cleanup;
1293 hr = add_bstr_property(node, szName, szFileName);
1294 if (FAILED(hr))
1295 goto cleanup;
1297 hr = add_bool_property(node, bExists, boolret);
1298 if (FAILED(hr))
1299 goto cleanup;
1301 if (boolret)
1303 snprintfW(szVersion_v, sizeof(szVersion_v)/sizeof(szVersion_v[0]),
1304 szVersionFormat,
1305 HIWORD(pFileInfo->dwFileVersionMS),
1306 LOWORD(pFileInfo->dwFileVersionMS),
1307 HIWORD(pFileInfo->dwFileVersionLS),
1308 LOWORD(pFileInfo->dwFileVersionLS));
1310 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v));
1312 hr = add_bstr_property(node, szVersion, szVersion_v);
1313 if (FAILED(hr))
1314 goto cleanup;
1316 hr = add_bstr_property(node, szAttributes, szFinal_Retail_v);
1317 if (FAILED(hr))
1318 goto cleanup;
1320 hr = add_bstr_property(node, szLanguageEnglish, szEnglish_v);
1321 if (FAILED(hr))
1322 goto cleanup;
1324 hr = add_ui4_property(node, dwFileTimeHigh, pFileInfo->dwFileDateMS);
1325 if (FAILED(hr))
1326 goto cleanup;
1328 hr = add_ui4_property(node, dwFileTimeLow, pFileInfo->dwFileDateLS);
1329 if (FAILED(hr))
1330 goto cleanup;
1332 hr = add_bool_property(node, bBeta, ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_PRERELEASE) != 0);
1333 if (FAILED(hr))
1334 goto cleanup;
1336 hr = add_bool_property(node, bDebug, ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_DEBUG) != 0);
1337 if (FAILED(hr))
1338 goto cleanup;
1341 hr = S_OK;
1342 cleanup:
1343 HeapFree(GetProcessHeap(), 0, pVersionInfo);
1344 HeapFree(GetProcessHeap(), 0, szFile);
1346 return hr;
1348 static HRESULT build_directxfiles_tree(IDxDiagContainerImpl_Container *node)
1350 static const WCHAR dlls[][15] =
1352 {'d','3','d','8','.','d','l','l',0},
1353 {'d','3','d','9','.','d','l','l',0},
1354 {'d','d','r','a','w','.','d','l','l',0},
1355 {'d','e','v','e','n','u','m','.','d','l','l',0},
1356 {'d','i','n','p','u','t','8','.','d','l','l',0},
1357 {'d','i','n','p','u','t','.','d','l','l',0},
1358 {'d','m','b','a','n','d','.','d','l','l',0},
1359 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
1360 {'d','m','i','m','e','.','d','l','l',0},
1361 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
1362 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
1363 {'d','m','s','t','y','l','e','.','d','l','l',0},
1364 {'d','m','s','y','n','t','h','.','d','l','l',0},
1365 {'d','m','u','s','i','c','.','d','l','l',0},
1366 {'d','p','l','a','y','x','.','d','l','l',0},
1367 {'d','p','n','e','t','.','d','l','l',0},
1368 {'d','s','o','u','n','d','.','d','l','l',0},
1369 {'d','s','w','a','v','e','.','d','l','l',0},
1370 {'d','x','d','i','a','g','n','.','d','l','l',0},
1371 {'q','u','a','r','t','z','.','d','l','l',0}
1374 HRESULT hr;
1375 WCHAR szFilePath[MAX_PATH];
1376 INT i;
1378 GetSystemDirectoryW(szFilePath, MAX_PATH);
1380 for (i = 0; i < sizeof(dlls) / sizeof(dlls[0]); i++)
1382 static const WCHAR szFormat[] = {'%','d',0};
1384 WCHAR szFileID[5];
1385 IDxDiagContainerImpl_Container *file_container;
1387 snprintfW(szFileID, sizeof(szFileID)/sizeof(szFileID[0]), szFormat, i);
1389 file_container = allocate_information_node(szFileID);
1390 if (!file_container)
1391 return E_OUTOFMEMORY;
1393 hr = fill_file_description(file_container, szFilePath, dlls[i]);
1394 if (FAILED(hr))
1396 free_information_tree(file_container);
1397 continue;
1400 add_subcontainer(node, file_container);
1403 return S_OK;
1406 static HRESULT read_property_names(IPropertyBag *pPropBag, VARIANT *friendly_name, VARIANT *clsid_name)
1408 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
1409 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
1411 HRESULT hr;
1413 VariantInit(friendly_name);
1414 VariantInit(clsid_name);
1416 hr = IPropertyBag_Read(pPropBag, wszFriendlyName, friendly_name, 0);
1417 if (FAILED(hr))
1418 return hr;
1420 hr = IPropertyBag_Read(pPropBag, wszClsidName, clsid_name, 0);
1421 if (FAILED(hr))
1423 VariantClear(friendly_name);
1424 return hr;
1427 return S_OK;
1430 static HRESULT fill_filter_data_information(IDxDiagContainerImpl_Container *subcont, BYTE *pData, ULONG cb)
1432 static const WCHAR szVersionW[] = {'s','z','V','e','r','s','i','o','n',0};
1433 static const WCHAR dwInputs[] = {'d','w','I','n','p','u','t','s',0};
1434 static const WCHAR dwOutputs[] = {'d','w','O','u','t','p','u','t','s',0};
1435 static const WCHAR dwMeritW[] = {'d','w','M','e','r','i','t',0};
1436 static const WCHAR szVersionFormat[] = {'v','%','d',0};
1438 HRESULT hr;
1439 IFilterMapper2 *pFileMapper = NULL;
1440 IAMFilterData *pFilterData = NULL;
1441 BYTE *ppRF = NULL;
1442 REGFILTER2 *pRF = NULL;
1443 WCHAR bufferW[10];
1444 ULONG j;
1445 DWORD dwNOutputs = 0;
1446 DWORD dwNInputs = 0;
1448 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2,
1449 (void **)&pFileMapper);
1450 if (FAILED(hr))
1451 return hr;
1453 hr = IFilterMapper2_QueryInterface(pFileMapper, &IID_IAMFilterData, (void **)&pFilterData);
1454 if (FAILED(hr))
1455 goto cleanup;
1457 hr = IAMFilterData_ParseFilterData(pFilterData, pData, cb, (BYTE **)&ppRF);
1458 if (FAILED(hr))
1459 goto cleanup;
1460 pRF = ((REGFILTER2**)ppRF)[0];
1462 snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szVersionFormat, pRF->dwVersion);
1463 hr = add_bstr_property(subcont, szVersionW, bufferW);
1464 if (FAILED(hr))
1465 goto cleanup;
1467 if (pRF->dwVersion == 1)
1469 for (j = 0; j < pRF->u.s1.cPins; j++)
1470 if (pRF->u.s1.rgPins[j].bOutput)
1471 dwNOutputs++;
1472 else
1473 dwNInputs++;
1475 else if (pRF->dwVersion == 2)
1477 for (j = 0; j < pRF->u.s2.cPins2; j++)
1478 if (pRF->u.s2.rgPins2[j].dwFlags & REG_PINFLAG_B_OUTPUT)
1479 dwNOutputs++;
1480 else
1481 dwNInputs++;
1484 hr = add_ui4_property(subcont, dwInputs, dwNInputs);
1485 if (FAILED(hr))
1486 goto cleanup;
1488 hr = add_ui4_property(subcont, dwOutputs, dwNOutputs);
1489 if (FAILED(hr))
1490 goto cleanup;
1492 hr = add_ui4_property(subcont, dwMeritW, pRF->dwMerit);
1493 if (FAILED(hr))
1494 goto cleanup;
1496 hr = S_OK;
1497 cleanup:
1498 CoTaskMemFree(pRF);
1499 if (pFilterData) IAMFilterData_Release(pFilterData);
1500 if (pFileMapper) IFilterMapper2_Release(pFileMapper);
1502 return hr;
1505 static HRESULT fill_filter_container(IDxDiagContainerImpl_Container *subcont, IMoniker *pMoniker)
1507 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
1508 static const WCHAR ClsidFilterW[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
1509 static const WCHAR wszFilterDataName[] = {'F','i','l','t','e','r','D','a','t','a',0};
1511 HRESULT hr;
1512 IPropertyBag *pPropFilterBag = NULL;
1513 BYTE *pData;
1514 VARIANT friendly_name;
1515 VARIANT clsid_name;
1516 VARIANT v;
1518 VariantInit(&friendly_name);
1519 VariantInit(&clsid_name);
1520 VariantInit(&v);
1522 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (void **)&pPropFilterBag);
1523 if (FAILED(hr))
1524 return hr;
1526 hr = read_property_names(pPropFilterBag, &friendly_name, &clsid_name);
1527 if (FAILED(hr))
1528 goto cleanup;
1530 TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name)));
1531 TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name)));
1533 hr = add_bstr_property(subcont, szName, V_BSTR(&friendly_name));
1534 if (FAILED(hr))
1535 goto cleanup;
1537 hr = add_bstr_property(subcont, ClsidFilterW, V_BSTR(&clsid_name));
1538 if (FAILED(hr))
1539 goto cleanup;
1541 hr = IPropertyBag_Read(pPropFilterBag, wszFilterDataName, &v, NULL);
1542 if (FAILED(hr))
1543 goto cleanup;
1545 hr = SafeArrayAccessData(V_ARRAY(&v), (void **)&pData);
1546 if (FAILED(hr))
1547 goto cleanup;
1549 hr = fill_filter_data_information(subcont, pData, V_ARRAY(&v)->rgsabound->cElements);
1550 SafeArrayUnaccessData(V_ARRAY(&v));
1551 if (FAILED(hr))
1552 goto cleanup;
1554 hr = S_OK;
1555 cleanup:
1556 VariantClear(&v);
1557 VariantClear(&clsid_name);
1558 VariantClear(&friendly_name);
1559 if (pPropFilterBag) IPropertyBag_Release(pPropFilterBag);
1561 return hr;
1564 static HRESULT build_directshowfilters_tree(IDxDiagContainerImpl_Container *node)
1566 static const WCHAR szCatName[] = {'s','z','C','a','t','N','a','m','e',0};
1567 static const WCHAR ClsidCatW[] = {'C','l','s','i','d','C','a','t',0};
1568 static const WCHAR szIdFormat[] = {'%','d',0};
1570 HRESULT hr;
1571 int i = 0;
1572 ICreateDevEnum *pCreateDevEnum;
1573 IEnumMoniker *pEmCat = NULL;
1574 IMoniker *pMCat = NULL;
1575 IEnumMoniker *pEnum = NULL;
1577 hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
1578 &IID_ICreateDevEnum, (void **)&pCreateDevEnum);
1579 if (FAILED(hr))
1580 return hr;
1582 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &CLSID_ActiveMovieCategories, &pEmCat, 0);
1583 if (FAILED(hr))
1584 goto cleanup;
1586 while (IEnumMoniker_Next(pEmCat, 1, &pMCat, NULL) == S_OK)
1588 VARIANT vCatName;
1589 VARIANT vCatClsid;
1590 IPropertyBag *pPropBag;
1591 CLSID clsidCat;
1592 IMoniker *pMoniker = NULL;
1594 hr = IMoniker_BindToStorage(pMCat, NULL, NULL, &IID_IPropertyBag, (void **)&pPropBag);
1595 if (FAILED(hr))
1597 IMoniker_Release(pMCat);
1598 break;
1601 hr = read_property_names(pPropBag, &vCatName, &vCatClsid);
1602 IPropertyBag_Release(pPropBag);
1603 if (FAILED(hr))
1605 IMoniker_Release(pMCat);
1606 break;
1609 hr = CLSIDFromString(V_BSTR(&vCatClsid), &clsidCat);
1610 if (FAILED(hr))
1612 IMoniker_Release(pMCat);
1613 VariantClear(&vCatClsid);
1614 VariantClear(&vCatName);
1615 break;
1618 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &clsidCat, &pEnum, 0);
1619 if (hr != S_OK)
1621 IMoniker_Release(pMCat);
1622 VariantClear(&vCatClsid);
1623 VariantClear(&vCatName);
1624 continue;
1627 TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat));
1629 while (IEnumMoniker_Next(pEnum, 1, &pMoniker, NULL) == S_OK)
1631 WCHAR bufferW[10];
1632 IDxDiagContainerImpl_Container *subcont;
1634 snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szIdFormat, i);
1635 subcont = allocate_information_node(bufferW);
1636 if (!subcont)
1638 hr = E_OUTOFMEMORY;
1639 IMoniker_Release(pMoniker);
1640 break;
1643 hr = add_bstr_property(subcont, szCatName, V_BSTR(&vCatName));
1644 if (FAILED(hr))
1646 free_information_tree(subcont);
1647 IMoniker_Release(pMoniker);
1648 break;
1651 hr = add_bstr_property(subcont, ClsidCatW, V_BSTR(&vCatClsid));
1652 if (FAILED(hr))
1654 free_information_tree(subcont);
1655 IMoniker_Release(pMoniker);
1656 break;
1659 hr = fill_filter_container(subcont, pMoniker);
1660 IMoniker_Release(pMoniker);
1661 if (FAILED(hr))
1663 WARN("Skipping invalid filter\n");
1664 free_information_tree(subcont);
1665 hr = S_OK;
1666 continue;
1669 add_subcontainer(node, subcont);
1670 i++;
1673 IEnumMoniker_Release(pEnum);
1674 IMoniker_Release(pMCat);
1675 VariantClear(&vCatClsid);
1676 VariantClear(&vCatName);
1678 if (FAILED(hr))
1679 break;
1682 cleanup:
1683 if (pEmCat) IEnumMoniker_Release(pEmCat);
1684 ICreateDevEnum_Release(pCreateDevEnum);
1685 return hr;
1688 static HRESULT build_logicaldisks_tree(IDxDiagContainerImpl_Container *node)
1690 return S_OK;
1693 static HRESULT build_information_tree(IDxDiagContainerImpl_Container **pinfo_root)
1695 static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
1696 static const WCHAR DxDiag_DisplayDevices[] = {'D','x','D','i','a','g','_','D','i','s','p','l','a','y','D','e','v','i','c','e','s',0};
1697 static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
1698 static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
1699 static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
1700 static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
1701 static const WCHAR DxDiag_SystemDevices[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','D','e','v','i','c','e','s',0};
1702 static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
1703 static const WCHAR DxDiag_DirectShowFilters[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','h','o','w','F','i','l','t','e','r','s',0};
1704 static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
1706 static const struct
1708 const WCHAR *name;
1709 HRESULT (*initfunc)(IDxDiagContainerImpl_Container *);
1710 } root_children[] =
1712 {DxDiag_SystemInfo, build_systeminfo_tree},
1713 {DxDiag_DisplayDevices, build_displaydevices_tree},
1714 {DxDiag_DirectSound, build_directsound_tree},
1715 {DxDiag_DirectMusic, build_directmusic_tree},
1716 {DxDiag_DirectInput, build_directinput_tree},
1717 {DxDiag_DirectPlay, build_directplay_tree},
1718 {DxDiag_SystemDevices, build_systemdevices_tree},
1719 {DxDiag_DirectXFiles, build_directxfiles_tree},
1720 {DxDiag_DirectShowFilters, build_directshowfilters_tree},
1721 {DxDiag_LogicalDisks, build_logicaldisks_tree},
1724 IDxDiagContainerImpl_Container *info_root;
1725 size_t index;
1727 info_root = allocate_information_node(NULL);
1728 if (!info_root)
1729 return E_OUTOFMEMORY;
1731 for (index = 0; index < sizeof(root_children)/sizeof(root_children[0]); index++)
1733 IDxDiagContainerImpl_Container *node;
1734 HRESULT hr;
1736 node = allocate_information_node(root_children[index].name);
1737 if (!node)
1739 free_information_tree(info_root);
1740 return E_OUTOFMEMORY;
1743 hr = root_children[index].initfunc(node);
1744 if (FAILED(hr))
1746 free_information_tree(node);
1747 free_information_tree(info_root);
1748 return hr;
1751 add_subcontainer(info_root, node);
1754 *pinfo_root = info_root;
1755 return S_OK;