gdiplus/metafile: Added support for EmfPlusFont objects.
[wine.git] / dlls / dxdiagn / provider.c
blob5665d01d5b8f37ed0030f9318975e6cd02c2228c
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;
349 HRESULT hr;
351 prop = allocate_property_information(propName);
352 if (!prop)
353 return E_OUTOFMEMORY;
355 V_VT(&prop->vProp) = VT_UI8;
356 V_UI8(&prop->vProp) = data;
358 hr = VariantChangeType(&prop->vProp, &prop->vProp, 0, VT_BSTR);
359 if (FAILED(hr))
361 free_property_information(prop);
362 return hr;
365 list_add_tail(&node->properties, &prop->entry);
366 ++node->nProperties;
368 return S_OK;
371 /* Copied from programs/taskkill/taskkill.c. */
372 static DWORD *enumerate_processes(DWORD *list_count)
374 DWORD *pid_list, alloc_bytes = 1024 * sizeof(*pid_list), needed_bytes;
376 pid_list = HeapAlloc(GetProcessHeap(), 0, alloc_bytes);
377 if (!pid_list)
378 return NULL;
380 for (;;)
382 DWORD *realloc_list;
384 if (!EnumProcesses(pid_list, alloc_bytes, &needed_bytes))
386 HeapFree(GetProcessHeap(), 0, pid_list);
387 return NULL;
390 /* EnumProcesses can't signal an insufficient buffer condition, so the
391 * only way to possibly determine whether a larger buffer is required
392 * is to see whether the written number of bytes is the same as the
393 * buffer size. If so, the buffer will be reallocated to twice the
394 * size. */
395 if (alloc_bytes != needed_bytes)
396 break;
398 alloc_bytes *= 2;
399 realloc_list = HeapReAlloc(GetProcessHeap(), 0, pid_list, alloc_bytes);
400 if (!realloc_list)
402 HeapFree(GetProcessHeap(), 0, pid_list);
403 return NULL;
405 pid_list = realloc_list;
408 *list_count = needed_bytes / sizeof(*pid_list);
409 return pid_list;
412 /* Copied from programs/taskkill/taskkill.c. */
413 static BOOL get_process_name_from_pid(DWORD pid, WCHAR *buf, DWORD chars)
415 HANDLE process;
416 HMODULE module;
417 DWORD required_size;
419 process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
420 if (!process)
421 return FALSE;
423 if (!EnumProcessModules(process, &module, sizeof(module), &required_size))
425 CloseHandle(process);
426 return FALSE;
429 if (!GetModuleBaseNameW(process, module, buf, chars))
431 CloseHandle(process);
432 return FALSE;
435 CloseHandle(process);
436 return TRUE;
439 /* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
440 static BOOL is_netmeeting_running(void)
442 static const WCHAR conf_exe[] = {'c','o','n','f','.','e','x','e',0};
444 DWORD list_count;
445 DWORD *pid_list = enumerate_processes(&list_count);
447 if (pid_list)
449 DWORD i;
450 WCHAR process_name[MAX_PATH];
452 for (i = 0; i < list_count; i++)
454 if (get_process_name_from_pid(pid_list[i], process_name, sizeof(process_name)/sizeof(WCHAR)) &&
455 !lstrcmpW(conf_exe, process_name))
457 HeapFree(GetProcessHeap(), 0, pid_list);
458 return TRUE;
461 HeapFree(GetProcessHeap(), 0, pid_list);
464 return FALSE;
467 static HRESULT fill_language_information(IDxDiagContainerImpl_Container *node)
469 static const WCHAR regional_setting_engW[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
470 static const WCHAR languages_fmtW[] = {'%','s',' ','(','%','s',':',' ','%','s',')',0};
471 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};
472 static const WCHAR szLanguagesEnglish[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
474 WCHAR system_lang[80], regional_setting[100], user_lang[80], language_str[300];
475 HRESULT hr;
477 /* szLanguagesLocalized */
478 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SNATIVELANGNAME, system_lang, sizeof(system_lang)/sizeof(WCHAR));
479 LoadStringW(dxdiagn_instance, IDS_REGIONAL_SETTING, regional_setting, sizeof(regional_setting)/sizeof(WCHAR));
480 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SNATIVELANGNAME, user_lang, sizeof(user_lang)/sizeof(WCHAR));
482 snprintfW(language_str, sizeof(language_str)/sizeof(WCHAR), languages_fmtW, system_lang, regional_setting, user_lang);
484 hr = add_bstr_property(node, szLanguagesLocalized, language_str);
485 if (FAILED(hr))
486 return hr;
488 /* szLanguagesEnglish */
489 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGLANGUAGE, system_lang, sizeof(system_lang)/sizeof(WCHAR));
490 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, user_lang, sizeof(user_lang)/sizeof(WCHAR));
492 snprintfW(language_str, sizeof(language_str)/sizeof(WCHAR), languages_fmtW, system_lang, regional_setting_engW, user_lang);
494 hr = add_bstr_property(node, szLanguagesEnglish, language_str);
495 if (FAILED(hr))
496 return hr;
498 return S_OK;
501 static HRESULT fill_datetime_information(IDxDiagContainerImpl_Container *node)
503 static const WCHAR date_fmtW[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0};
504 static const WCHAR time_fmtW[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
505 static const WCHAR datetime_fmtW[] = {'%','s',',',' ','%','s',0};
506 static const WCHAR szTimeLocalized[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
507 static const WCHAR szTimeEnglish[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
509 SYSTEMTIME curtime;
510 WCHAR date_str[80], time_str[80], datetime_str[200];
511 HRESULT hr;
513 GetLocalTime(&curtime);
515 GetTimeFormatW(LOCALE_NEUTRAL, 0, &curtime, time_fmtW, time_str, sizeof(time_str)/sizeof(WCHAR));
517 /* szTimeLocalized */
518 GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &curtime, NULL, date_str, sizeof(date_str)/sizeof(WCHAR));
520 snprintfW(datetime_str, sizeof(datetime_str)/sizeof(WCHAR), datetime_fmtW, date_str, time_str);
522 hr = add_bstr_property(node, szTimeLocalized, datetime_str);
523 if (FAILED(hr))
524 return hr;
526 /* szTimeEnglish */
527 GetDateFormatW(LOCALE_NEUTRAL, 0, &curtime, date_fmtW, date_str, sizeof(date_str)/sizeof(WCHAR));
529 snprintfW(datetime_str, sizeof(datetime_str)/sizeof(WCHAR), datetime_fmtW, date_str, time_str);
531 hr = add_bstr_property(node, szTimeEnglish, datetime_str);
532 if (FAILED(hr))
533 return hr;
535 return S_OK;
538 static HRESULT fill_os_string_information(IDxDiagContainerImpl_Container *node, OSVERSIONINFOW *info)
540 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};
541 static const WCHAR szOSLocalized[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
542 static const WCHAR szOSExLocalized[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
543 static const WCHAR szOSExLongLocalized[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
544 static const WCHAR szOSEnglish[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
545 static const WCHAR szOSExEnglish[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
546 static const WCHAR szOSExLongEnglish[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
548 static const WCHAR *prop_list[] = {szOSLocalized, szOSExLocalized, szOSExLongLocalized,
549 szOSEnglish, szOSExEnglish, szOSExLongEnglish};
551 size_t i;
552 HRESULT hr;
554 /* FIXME: OS detection should be performed, and localized OS strings
555 * should contain translated versions of the "build" phrase. */
556 for (i = 0; i < sizeof(prop_list)/sizeof(prop_list[0]); i++)
558 hr = add_bstr_property(node, prop_list[i], winxpW);
559 if (FAILED(hr))
560 return hr;
563 return S_OK;
566 static HRESULT fill_processor_information(IDxDiagContainerImpl_Container *node)
568 static const WCHAR szProcessorEnglish[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
570 static const WCHAR cimv2W[] = {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
571 static const WCHAR proc_classW[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
572 static const WCHAR nameW[] = {'N','a','m','e',0};
573 static const WCHAR max_clock_speedW[] = {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
574 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};
576 static const WCHAR processor_fmtW[] = {'%','s','(','%','d',' ','C','P','U','s',')',',',' ','~','%','d','M','H','z',0};
578 IWbemLocator *wbem_locator;
579 IWbemServices *wbem_service;
580 IWbemClassObject *wbem_class;
581 IEnumWbemClassObject *wbem_enum;
582 VARIANT cpu_name, cpu_no, clock_speed;
583 WCHAR print_buf[200];
584 BSTR bstr;
585 ULONG no;
586 HRESULT hr;
588 hr = CoCreateInstance(&CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void**)&wbem_locator);
589 if(FAILED(hr))
590 return hr;
592 bstr = SysAllocString(cimv2W);
593 if(!bstr) {
594 IWbemLocator_Release(wbem_locator);
595 return E_OUTOFMEMORY;
597 hr = IWbemLocator_ConnectServer(wbem_locator, bstr, NULL, NULL, NULL, 0, NULL, NULL, &wbem_service);
598 IWbemLocator_Release(wbem_locator);
599 SysFreeString(bstr);
600 if(FAILED(hr))
601 return hr;
603 bstr = SysAllocString(proc_classW);
604 if(!bstr) {
605 IWbemServices_Release(wbem_service);
606 return E_OUTOFMEMORY;
608 hr = IWbemServices_CreateInstanceEnum(wbem_service, bstr, WBEM_FLAG_SYSTEM_ONLY, NULL, &wbem_enum);
609 IWbemServices_Release(wbem_service);
610 SysFreeString(bstr);
611 if(FAILED(hr))
612 return hr;
614 hr = IEnumWbemClassObject_Next(wbem_enum, 1000, 1, &wbem_class, &no);
615 IEnumWbemClassObject_Release(wbem_enum);
616 if(FAILED(hr))
617 return hr;
619 hr = IWbemClassObject_Get(wbem_class, cpu_noW, 0, &cpu_no, NULL, NULL);
620 if(FAILED(hr)) {
621 IWbemClassObject_Release(wbem_class);
622 return hr;
624 hr = IWbemClassObject_Get(wbem_class, max_clock_speedW, 0, &clock_speed, NULL, NULL);
625 if(FAILED(hr)) {
626 IWbemClassObject_Release(wbem_class);
627 return hr;
629 hr = IWbemClassObject_Get(wbem_class, nameW, 0, &cpu_name, NULL, NULL);
630 IWbemClassObject_Release(wbem_class);
631 if(FAILED(hr))
632 return hr;
634 sprintfW(print_buf, processor_fmtW, V_BSTR(&cpu_name), V_I4(&cpu_no), V_I4(&clock_speed));
635 VariantClear(&cpu_name);
636 VariantClear(&cpu_no);
637 VariantClear(&clock_speed);
639 return add_bstr_property(node, szProcessorEnglish, print_buf);
642 static HRESULT build_systeminfo_tree(IDxDiagContainerImpl_Container *node)
644 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};
645 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};
646 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};
647 static const WCHAR szDirectXVersionLetter_v[] = {'c',0};
648 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
649 static const WCHAR bNECPC98[] = {'b','N','E','C','P','C','9','8',0};
650 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};
651 static const WCHAR szDirectXVersionEnglish_v[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
652 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};
653 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};
654 static const WCHAR ullPhysicalMemory[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
655 static const WCHAR ullUsedPageFile[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
656 static const WCHAR ullAvailPageFile[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
657 static const WCHAR bNetMeetingRunning[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
658 static const WCHAR szWindowsDir[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
659 static const WCHAR dwOSMajorVersion[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
660 static const WCHAR dwOSMinorVersion[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
661 static const WCHAR dwOSBuildNumber[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
662 static const WCHAR dwOSPlatformID[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
663 static const WCHAR szCSDVersion[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
664 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};
665 static const WCHAR szPageFileLocalized[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
666 static const WCHAR szPageFileEnglish[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
667 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};
668 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};
669 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};
670 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};
671 static const WCHAR szBIOSEnglish[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
672 static const WCHAR szSetupParamEnglish[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
673 static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
675 static const WCHAR notpresentW[] = {'N','o','t',' ','p','r','e','s','e','n','t',0};
677 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};
678 static const WCHAR physmem_fmtW[] = {'%','u','M','B',' ','R','A','M',0};
680 HRESULT hr;
681 MEMORYSTATUSEX msex;
682 OSVERSIONINFOW info;
683 DWORD count, usedpage_mb, availpage_mb;
684 WCHAR buffer[MAX_PATH], computer_name[MAX_COMPUTERNAME_LENGTH + 1], print_buf[200], localized_pagefile_fmt[200];
685 DWORD_PTR args[2];
687 hr = add_ui4_property(node, dwDirectXVersionMajor, 9);
688 if (FAILED(hr))
689 return hr;
691 hr = add_ui4_property(node, dwDirectXVersionMinor, 0);
692 if (FAILED(hr))
693 return hr;
695 hr = add_bstr_property(node, szDirectXVersionLetter, szDirectXVersionLetter_v);
696 if (FAILED(hr))
697 return hr;
699 hr = add_bstr_property(node, szDirectXVersionEnglish, szDirectXVersionEnglish_v);
700 if (FAILED(hr))
701 return hr;
703 hr = add_bstr_property(node, szDirectXVersionLongEnglish, szDirectXVersionLongEnglish_v);
704 if (FAILED(hr))
705 return hr;
707 hr = add_bool_property(node, bDebug, FALSE);
708 if (FAILED(hr))
709 return hr;
711 hr = add_bool_property(node, bNECPC98, FALSE);
712 if (FAILED(hr))
713 return hr;
715 msex.dwLength = sizeof(msex);
716 GlobalMemoryStatusEx(&msex);
718 hr = add_ull_as_bstr_property(node, ullPhysicalMemory, msex.ullTotalPhys);
719 if (FAILED(hr))
720 return hr;
722 hr = add_ull_as_bstr_property(node, ullUsedPageFile, msex.ullTotalPageFile - msex.ullAvailPageFile);
723 if (FAILED(hr))
724 return hr;
726 hr = add_ull_as_bstr_property(node, ullAvailPageFile, msex.ullAvailPageFile);
727 if (FAILED(hr))
728 return hr;
730 hr = add_bool_property(node, bNetMeetingRunning, is_netmeeting_running());
731 if (FAILED(hr))
732 return hr;
734 info.dwOSVersionInfoSize = sizeof(info);
735 GetVersionExW(&info);
737 hr = add_ui4_property(node, dwOSMajorVersion, info.dwMajorVersion);
738 if (FAILED(hr))
739 return hr;
741 hr = add_ui4_property(node, dwOSMinorVersion, info.dwMinorVersion);
742 if (FAILED(hr))
743 return hr;
745 hr = add_ui4_property(node, dwOSBuildNumber, info.dwBuildNumber);
746 if (FAILED(hr))
747 return hr;
749 hr = add_ui4_property(node, dwOSPlatformID, info.dwPlatformId);
750 if (FAILED(hr))
751 return hr;
753 hr = add_bstr_property(node, szCSDVersion, info.szCSDVersion);
754 if (FAILED(hr))
755 return hr;
757 /* FIXME: Roundoff should not be done with truncated division. */
758 snprintfW(print_buf, sizeof(print_buf)/sizeof(WCHAR), physmem_fmtW, (DWORD)(msex.ullTotalPhys / (1024 * 1024)));
759 hr = add_bstr_property(node, szPhysicalMemoryEnglish, print_buf);
760 if (FAILED(hr))
761 return hr;
763 usedpage_mb = (DWORD)((msex.ullTotalPageFile - msex.ullAvailPageFile) / (1024 * 1024));
764 availpage_mb = (DWORD)(msex.ullAvailPageFile / (1024 * 1024));
765 LoadStringW(dxdiagn_instance, IDS_PAGE_FILE_FORMAT, localized_pagefile_fmt, sizeof(localized_pagefile_fmt)/sizeof(WCHAR));
766 args[0] = usedpage_mb;
767 args[1] = availpage_mb;
768 FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
769 localized_pagefile_fmt, 0, 0, print_buf,
770 sizeof(print_buf)/sizeof(*print_buf), (__ms_va_list*)args);
772 hr = add_bstr_property(node, szPageFileLocalized, print_buf);
773 if (FAILED(hr))
774 return hr;
776 snprintfW(print_buf, sizeof(print_buf)/sizeof(WCHAR), pagefile_fmtW, usedpage_mb, availpage_mb);
778 hr = add_bstr_property(node, szPageFileEnglish, print_buf);
779 if (FAILED(hr))
780 return hr;
782 GetWindowsDirectoryW(buffer, MAX_PATH);
784 hr = add_bstr_property(node, szWindowsDir, buffer);
785 if (FAILED(hr))
786 return hr;
788 count = sizeof(computer_name)/sizeof(WCHAR);
789 if (!GetComputerNameW(computer_name, &count))
790 return E_FAIL;
792 hr = add_bstr_property(node, szMachineNameLocalized, computer_name);
793 if (FAILED(hr))
794 return hr;
796 hr = add_bstr_property(node, szMachineNameEnglish, computer_name);
797 if (FAILED(hr))
798 return hr;
800 hr = add_bstr_property(node, szSystemManufacturerEnglish, szEmpty);
801 if (FAILED(hr))
802 return hr;
804 hr = add_bstr_property(node, szSystemModelEnglish, szEmpty);
805 if (FAILED(hr))
806 return hr;
808 hr = add_bstr_property(node, szBIOSEnglish, szEmpty);
809 if (FAILED(hr))
810 return hr;
812 hr = fill_processor_information(node);
813 if (FAILED(hr))
814 return hr;
816 hr = add_bstr_property(node, szSetupParamEnglish, notpresentW);
817 if (FAILED(hr))
818 return hr;
820 hr = add_bstr_property(node, szDxDiagVersion, szEmpty);
821 if (FAILED(hr))
822 return hr;
824 hr = fill_language_information(node);
825 if (FAILED(hr))
826 return hr;
828 hr = fill_datetime_information(node);
829 if (FAILED(hr))
830 return hr;
832 hr = fill_os_string_information(node, &info);
833 if (FAILED(hr))
834 return hr;
836 return S_OK;
839 /* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
840 static DWORD depth_for_pixelformat(D3DFORMAT format)
842 switch (format)
844 case D3DFMT_P8: return 8;
845 case D3DFMT_X1R5G5B5: return 15;
846 case D3DFMT_R5G6B5: return 16;
847 /* This case will fail to distinguish an original bpp of 24. */
848 case D3DFMT_X8R8G8B8: return 32;
849 default:
850 FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format);
851 return 32;
855 static BOOL get_texture_memory(GUID *adapter, DWORD *available_mem)
857 IDirectDraw7 *pDirectDraw;
858 HRESULT hr;
859 DDSCAPS2 dd_caps;
861 hr = DirectDrawCreateEx(adapter, (void **)&pDirectDraw, &IID_IDirectDraw7, NULL);
862 if (SUCCEEDED(hr))
864 dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
865 dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.u1.dwCaps4 = 0;
866 hr = IDirectDraw7_GetAvailableVidMem(pDirectDraw, &dd_caps, available_mem, NULL);
867 IDirectDraw7_Release(pDirectDraw);
868 if (SUCCEEDED(hr))
869 return TRUE;
872 return FALSE;
875 static const WCHAR *vendor_id_to_manufacturer_string(DWORD vendor_id)
877 static const WCHAR atiW[] = {'A','T','I',' ','T','e','c','h','n','o','l','o','g','i','e','s',' ','I','n','c','.',0};
878 static const WCHAR nvidiaW[] = {'N','V','I','D','I','A',0};
879 static const WCHAR intelW[] = {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
880 static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
882 /* Enumeration copied from dlls/wined3d/wined3d_private.h and slightly modified. */
883 enum pci_vendor
885 HW_VENDOR_AMD = 0x1002,
886 HW_VENDOR_NVIDIA = 0x10de,
887 HW_VENDOR_INTEL = 0x8086,
890 switch (vendor_id)
892 case HW_VENDOR_AMD:
893 return atiW;
894 case HW_VENDOR_NVIDIA:
895 return nvidiaW;
896 case HW_VENDOR_INTEL:
897 return intelW;
898 default:
899 FIXME("Unknown PCI vendor ID 0x%04x\n", vendor_id);
900 return unknownW;
904 static HRESULT fill_display_information_d3d(IDxDiagContainerImpl_Container *node)
906 IDxDiagContainerImpl_Container *display_adapter;
907 HRESULT hr;
908 IDirect3D9 *pDirect3D9;
909 WCHAR buffer[256];
910 UINT index, count;
912 pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION);
913 if (!pDirect3D9)
914 return E_FAIL;
916 count = IDirect3D9_GetAdapterCount(pDirect3D9);
917 for (index = 0; index < count; index++)
919 static const WCHAR adapterid_fmtW[] = {'%','u',0};
920 static const WCHAR driverversion_fmtW[] = {'%','u','.','%','u','.','%','0','4','u','.','%','0','4','u',0};
921 static const WCHAR id_fmtW[] = {'0','x','%','0','4','x',0};
922 static const WCHAR subsysid_fmtW[] = {'0','x','%','0','8','x',0};
923 static const WCHAR mem_fmt[] = {'%','.','1','f',' ','M','B',0};
924 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};
925 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};
926 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};
927 static const WCHAR bNoHardware[] = {'b','N','o','H','a','r','d','w','a','r','e',0};
929 D3DADAPTER_IDENTIFIER9 adapter_info;
930 D3DDISPLAYMODE adapter_mode;
931 D3DCAPS9 device_caps;
932 DWORD available_mem = 0;
933 BOOL hardware_accel;
935 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), adapterid_fmtW, index);
936 display_adapter = allocate_information_node(buffer);
937 if (!display_adapter)
939 hr = E_OUTOFMEMORY;
940 goto cleanup;
943 add_subcontainer(node, display_adapter);
945 hr = IDirect3D9_GetAdapterIdentifier(pDirect3D9, index, 0, &adapter_info);
946 if (SUCCEEDED(hr))
948 WCHAR driverW[sizeof(adapter_info.Driver)];
949 WCHAR descriptionW[sizeof(adapter_info.Description)];
950 WCHAR devicenameW[sizeof(adapter_info.DeviceName)];
952 MultiByteToWideChar(CP_ACP, 0, adapter_info.Driver, -1, driverW, sizeof(driverW)/sizeof(WCHAR));
953 MultiByteToWideChar(CP_ACP, 0, adapter_info.Description, -1, descriptionW, sizeof(descriptionW)/sizeof(WCHAR));
954 MultiByteToWideChar(CP_ACP, 0, adapter_info.DeviceName, -1, devicenameW, sizeof(devicenameW)/sizeof(WCHAR));
956 hr = add_bstr_property(display_adapter, szDriverName, driverW);
957 if (FAILED(hr))
958 goto cleanup;
960 hr = add_bstr_property(display_adapter, szDescription, descriptionW);
961 if (FAILED(hr))
962 goto cleanup;
964 hr = add_bstr_property(display_adapter, szDeviceName, devicenameW);
965 if (FAILED(hr))
966 goto cleanup;
968 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), driverversion_fmtW,
969 HIWORD(adapter_info.DriverVersion.u.HighPart), LOWORD(adapter_info.DriverVersion.u.HighPart),
970 HIWORD(adapter_info.DriverVersion.u.LowPart), LOWORD(adapter_info.DriverVersion.u.LowPart));
972 hr = add_bstr_property(display_adapter, szDriverVersion, buffer);
973 if (FAILED(hr))
974 goto cleanup;
976 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), id_fmtW, adapter_info.VendorId);
977 hr = add_bstr_property(display_adapter, szVendorId, buffer);
978 if (FAILED(hr))
979 goto cleanup;
981 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), id_fmtW, adapter_info.DeviceId);
982 hr = add_bstr_property(display_adapter, szDeviceId, buffer);
983 if (FAILED(hr))
984 goto cleanup;
986 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), subsysid_fmtW, adapter_info.SubSysId);
987 hr = add_bstr_property(display_adapter, szSubSysId, buffer);
988 if (FAILED(hr))
989 goto cleanup;
991 snprintfW(buffer, sizeof(buffer)/sizeof(WCHAR), id_fmtW, adapter_info.Revision);
992 hr = add_bstr_property(display_adapter, szRevisionId, buffer);
993 if (FAILED(hr))
994 goto cleanup;
996 StringFromGUID2(&adapter_info.DeviceIdentifier, buffer, 39);
997 hr = add_bstr_property(display_adapter, szDeviceIdentifier, buffer);
998 if (FAILED(hr))
999 goto cleanup;
1001 hr = add_bstr_property(display_adapter, szManufacturer, vendor_id_to_manufacturer_string(adapter_info.VendorId));
1002 if (FAILED(hr))
1003 goto cleanup;
1006 hr = IDirect3D9_GetAdapterDisplayMode(pDirect3D9, index, &adapter_mode);
1007 if (SUCCEEDED(hr))
1009 hr = add_ui4_property(display_adapter, dwWidth, adapter_mode.Width);
1010 if (FAILED(hr))
1011 goto cleanup;
1013 hr = add_ui4_property(display_adapter, dwHeight, adapter_mode.Height);
1014 if (FAILED(hr))
1015 goto cleanup;
1017 hr = add_ui4_property(display_adapter, dwRefreshRate, adapter_mode.RefreshRate);
1018 if (FAILED(hr))
1019 goto cleanup;
1021 hr = add_ui4_property(display_adapter, dwBpp, depth_for_pixelformat(adapter_mode.Format));
1022 if (FAILED(hr))
1023 goto cleanup;
1026 hr = add_bstr_property(display_adapter, szKeyDeviceKey, szEmpty);
1027 if (FAILED(hr))
1028 goto cleanup;
1030 hr = add_bstr_property(display_adapter, szKeyDeviceID, szEmpty);
1031 if (FAILED(hr))
1032 goto cleanup;
1034 hr = add_bstr_property(display_adapter, szChipType, szEmpty);
1035 if (FAILED(hr))
1036 goto cleanup;
1038 hr = add_bstr_property(display_adapter, szDACType, szEmpty);
1039 if (FAILED(hr))
1040 goto cleanup;
1042 hr = add_bstr_property(display_adapter, szRevision, szEmpty);
1043 if (FAILED(hr))
1044 goto cleanup;
1046 if (!get_texture_memory(&adapter_info.DeviceIdentifier, &available_mem))
1047 WARN("get_texture_memory helper failed\n");
1049 snprintfW(buffer, sizeof(buffer)/sizeof(buffer[0]), mem_fmt, available_mem / 1000000.0f);
1051 hr = add_bstr_property(display_adapter, szDisplayMemoryLocalized, buffer);
1052 if (FAILED(hr))
1053 goto cleanup;
1055 hr = add_bstr_property(display_adapter, szDisplayMemoryEnglish, buffer);
1056 if (FAILED(hr))
1057 goto cleanup;
1059 hr = IDirect3D9_GetDeviceCaps(pDirect3D9, index, D3DDEVTYPE_HAL, &device_caps);
1060 hardware_accel = SUCCEEDED(hr);
1062 hr = add_bool_property(display_adapter, b3DAccelerationEnabled, hardware_accel);
1063 if (FAILED(hr))
1064 goto cleanup;
1066 hr = add_bool_property(display_adapter, b3DAccelerationExists, hardware_accel);
1067 if (FAILED(hr))
1068 goto cleanup;
1070 hr = add_bool_property(display_adapter, bDDAccelerationEnabled, hardware_accel);
1071 if (FAILED(hr))
1072 goto cleanup;
1074 hr = add_bool_property(display_adapter, bNoHardware, FALSE);
1075 if (FAILED(hr))
1076 goto cleanup;
1079 hr = S_OK;
1080 cleanup:
1081 IDirect3D9_Release(pDirect3D9);
1082 return hr;
1085 static HRESULT fill_display_information_fallback(IDxDiagContainerImpl_Container *node)
1087 static const WCHAR szAdapterID[] = {'0',0};
1088 static const WCHAR *empty_properties[] = {szDeviceIdentifier, szVendorId, szDeviceId,
1089 szKeyDeviceKey, szKeyDeviceID, szDriverName,
1090 szDriverVersion, szSubSysId, szRevisionId,
1091 szManufacturer, szChipType, szDACType, szRevision};
1093 IDxDiagContainerImpl_Container *display_adapter;
1094 HRESULT hr;
1095 IDirectDraw7 *pDirectDraw;
1096 DDSCAPS2 dd_caps;
1097 DISPLAY_DEVICEW disp_dev;
1098 DDSURFACEDESC2 surface_descr;
1099 DWORD tmp;
1100 WCHAR buffer[256];
1102 display_adapter = allocate_information_node(szAdapterID);
1103 if (!display_adapter)
1104 return E_OUTOFMEMORY;
1106 add_subcontainer(node, display_adapter);
1108 disp_dev.cb = sizeof(disp_dev);
1109 if (EnumDisplayDevicesW( NULL, 0, &disp_dev, 0 ))
1111 hr = add_bstr_property(display_adapter, szDeviceName, disp_dev.DeviceName);
1112 if (FAILED(hr))
1113 return hr;
1115 hr = add_bstr_property(display_adapter, szDescription, disp_dev.DeviceString);
1116 if (FAILED(hr))
1117 return hr;
1120 /* Silently ignore a failure from DirectDrawCreateEx. */
1121 hr = DirectDrawCreateEx(NULL, (void **)&pDirectDraw, &IID_IDirectDraw7, NULL);
1122 if (FAILED(hr))
1123 return S_OK;
1125 dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
1126 dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.u1.dwCaps4 = 0;
1127 hr = IDirectDraw7_GetAvailableVidMem(pDirectDraw, &dd_caps, &tmp, NULL);
1128 if (SUCCEEDED(hr))
1130 static const WCHAR mem_fmt[] = {'%','.','1','f',' ','M','B',0};
1132 snprintfW(buffer, sizeof(buffer)/sizeof(buffer[0]), mem_fmt, tmp / 1000000.0f);
1134 hr = add_bstr_property(display_adapter, szDisplayMemoryLocalized, buffer);
1135 if (FAILED(hr))
1136 goto cleanup;
1138 hr = add_bstr_property(display_adapter, szDisplayMemoryEnglish, buffer);
1139 if (FAILED(hr))
1140 goto cleanup;
1143 surface_descr.dwSize = sizeof(surface_descr);
1144 hr = IDirectDraw7_GetDisplayMode(pDirectDraw, &surface_descr);
1145 if (SUCCEEDED(hr))
1147 if (surface_descr.dwFlags & DDSD_WIDTH)
1149 hr = add_ui4_property(display_adapter, dwWidth, surface_descr.dwWidth);
1150 if (FAILED(hr))
1151 goto cleanup;
1154 if (surface_descr.dwFlags & DDSD_HEIGHT)
1156 hr = add_ui4_property(display_adapter, dwHeight, surface_descr.dwHeight);
1157 if (FAILED(hr))
1158 goto cleanup;
1161 if (surface_descr.dwFlags & DDSD_PIXELFORMAT)
1163 hr = add_ui4_property(display_adapter, dwBpp, surface_descr.u4.ddpfPixelFormat.u1.dwRGBBitCount);
1164 if (FAILED(hr))
1165 goto cleanup;
1169 hr = add_ui4_property(display_adapter, dwRefreshRate, 60);
1170 if (FAILED(hr))
1171 goto cleanup;
1173 for (tmp = 0; tmp < sizeof(empty_properties)/sizeof(empty_properties[0]); tmp++)
1175 hr = add_bstr_property(display_adapter, empty_properties[tmp], szEmpty);
1176 if (FAILED(hr))
1177 goto cleanup;
1180 hr = S_OK;
1181 cleanup:
1182 IDirectDraw7_Release(pDirectDraw);
1183 return hr;
1186 static HRESULT build_displaydevices_tree(IDxDiagContainerImpl_Container *node)
1188 HRESULT hr;
1190 /* Try to use Direct3D to obtain the required information first. */
1191 hr = fill_display_information_d3d(node);
1192 if (hr != E_FAIL)
1193 return hr;
1195 return fill_display_information_fallback(node);
1198 static HRESULT build_directsound_tree(IDxDiagContainerImpl_Container *node)
1200 static const WCHAR DxDiag_SoundDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
1201 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};
1203 IDxDiagContainerImpl_Container *cont;
1205 cont = allocate_information_node(DxDiag_SoundDevices);
1206 if (!cont)
1207 return E_OUTOFMEMORY;
1209 add_subcontainer(node, cont);
1211 cont = allocate_information_node(DxDiag_SoundCaptureDevices);
1212 if (!cont)
1213 return E_OUTOFMEMORY;
1215 add_subcontainer(node, cont);
1217 return S_OK;
1220 static HRESULT build_directmusic_tree(IDxDiagContainerImpl_Container *node)
1222 return S_OK;
1225 static HRESULT build_directinput_tree(IDxDiagContainerImpl_Container *node)
1227 return S_OK;
1230 static HRESULT build_directplay_tree(IDxDiagContainerImpl_Container *node)
1232 return S_OK;
1235 static HRESULT build_systemdevices_tree(IDxDiagContainerImpl_Container *node)
1237 return S_OK;
1240 static HRESULT fill_file_description(IDxDiagContainerImpl_Container *node, const WCHAR *szFilePath, const WCHAR *szFileName)
1242 static const WCHAR szSlashSep[] = {'\\',0};
1243 static const WCHAR szPath[] = {'s','z','P','a','t','h',0};
1244 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
1245 static const WCHAR szVersion[] = {'s','z','V','e','r','s','i','o','n',0};
1246 static const WCHAR szAttributes[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
1247 static const WCHAR szLanguageEnglish[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
1248 static const WCHAR dwFileTimeHigh[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
1249 static const WCHAR dwFileTimeLow[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
1250 static const WCHAR bBeta[] = {'b','B','e','t','a',0};
1251 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
1252 static const WCHAR bExists[] = {'b','E','x','i','s','t','s',0};
1254 /* Values */
1255 static const WCHAR szFinal_Retail_v[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
1256 static const WCHAR szEnglish_v[] = {'E','n','g','l','i','s','h',0};
1257 static const WCHAR szVersionFormat[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
1259 HRESULT hr;
1260 WCHAR *szFile;
1261 WCHAR szVersion_v[1024];
1262 DWORD retval, hdl;
1263 void *pVersionInfo = NULL;
1264 BOOL boolret = FALSE;
1265 UINT uiLength;
1266 VS_FIXEDFILEINFO *pFileInfo;
1268 TRACE("Filling container %p for %s in %s\n", node,
1269 debugstr_w(szFileName), debugstr_w(szFilePath));
1271 szFile = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * (lstrlenW(szFilePath) +
1272 lstrlenW(szFileName) + 2 /* slash + terminator */));
1273 if (!szFile)
1274 return E_OUTOFMEMORY;
1276 lstrcpyW(szFile, szFilePath);
1277 lstrcatW(szFile, szSlashSep);
1278 lstrcatW(szFile, szFileName);
1280 retval = GetFileVersionInfoSizeW(szFile, &hdl);
1281 if (retval)
1283 pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
1284 if (!pVersionInfo)
1286 hr = E_OUTOFMEMORY;
1287 goto cleanup;
1290 if (GetFileVersionInfoW(szFile, 0, retval, pVersionInfo) &&
1291 VerQueryValueW(pVersionInfo, szSlashSep, (void **)&pFileInfo, &uiLength))
1292 boolret = TRUE;
1295 hr = add_bstr_property(node, szPath, szFile);
1296 if (FAILED(hr))
1297 goto cleanup;
1299 hr = add_bstr_property(node, szName, szFileName);
1300 if (FAILED(hr))
1301 goto cleanup;
1303 hr = add_bool_property(node, bExists, boolret);
1304 if (FAILED(hr))
1305 goto cleanup;
1307 if (boolret)
1309 snprintfW(szVersion_v, sizeof(szVersion_v)/sizeof(szVersion_v[0]),
1310 szVersionFormat,
1311 HIWORD(pFileInfo->dwFileVersionMS),
1312 LOWORD(pFileInfo->dwFileVersionMS),
1313 HIWORD(pFileInfo->dwFileVersionLS),
1314 LOWORD(pFileInfo->dwFileVersionLS));
1316 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v));
1318 hr = add_bstr_property(node, szVersion, szVersion_v);
1319 if (FAILED(hr))
1320 goto cleanup;
1322 hr = add_bstr_property(node, szAttributes, szFinal_Retail_v);
1323 if (FAILED(hr))
1324 goto cleanup;
1326 hr = add_bstr_property(node, szLanguageEnglish, szEnglish_v);
1327 if (FAILED(hr))
1328 goto cleanup;
1330 hr = add_ui4_property(node, dwFileTimeHigh, pFileInfo->dwFileDateMS);
1331 if (FAILED(hr))
1332 goto cleanup;
1334 hr = add_ui4_property(node, dwFileTimeLow, pFileInfo->dwFileDateLS);
1335 if (FAILED(hr))
1336 goto cleanup;
1338 hr = add_bool_property(node, bBeta, ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_PRERELEASE) != 0);
1339 if (FAILED(hr))
1340 goto cleanup;
1342 hr = add_bool_property(node, bDebug, ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_DEBUG) != 0);
1343 if (FAILED(hr))
1344 goto cleanup;
1347 hr = S_OK;
1348 cleanup:
1349 HeapFree(GetProcessHeap(), 0, pVersionInfo);
1350 HeapFree(GetProcessHeap(), 0, szFile);
1352 return hr;
1354 static HRESULT build_directxfiles_tree(IDxDiagContainerImpl_Container *node)
1356 static const WCHAR dlls[][15] =
1358 {'d','3','d','8','.','d','l','l',0},
1359 {'d','3','d','9','.','d','l','l',0},
1360 {'d','d','r','a','w','.','d','l','l',0},
1361 {'d','e','v','e','n','u','m','.','d','l','l',0},
1362 {'d','i','n','p','u','t','8','.','d','l','l',0},
1363 {'d','i','n','p','u','t','.','d','l','l',0},
1364 {'d','m','b','a','n','d','.','d','l','l',0},
1365 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
1366 {'d','m','i','m','e','.','d','l','l',0},
1367 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
1368 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
1369 {'d','m','s','t','y','l','e','.','d','l','l',0},
1370 {'d','m','s','y','n','t','h','.','d','l','l',0},
1371 {'d','m','u','s','i','c','.','d','l','l',0},
1372 {'d','p','l','a','y','x','.','d','l','l',0},
1373 {'d','p','n','e','t','.','d','l','l',0},
1374 {'d','s','o','u','n','d','.','d','l','l',0},
1375 {'d','s','w','a','v','e','.','d','l','l',0},
1376 {'d','x','d','i','a','g','n','.','d','l','l',0},
1377 {'q','u','a','r','t','z','.','d','l','l',0}
1380 HRESULT hr;
1381 WCHAR szFilePath[MAX_PATH];
1382 INT i;
1384 GetSystemDirectoryW(szFilePath, MAX_PATH);
1386 for (i = 0; i < sizeof(dlls) / sizeof(dlls[0]); i++)
1388 static const WCHAR szFormat[] = {'%','d',0};
1390 WCHAR szFileID[5];
1391 IDxDiagContainerImpl_Container *file_container;
1393 snprintfW(szFileID, sizeof(szFileID)/sizeof(szFileID[0]), szFormat, i);
1395 file_container = allocate_information_node(szFileID);
1396 if (!file_container)
1397 return E_OUTOFMEMORY;
1399 hr = fill_file_description(file_container, szFilePath, dlls[i]);
1400 if (FAILED(hr))
1402 free_information_tree(file_container);
1403 continue;
1406 add_subcontainer(node, file_container);
1409 return S_OK;
1412 static HRESULT read_property_names(IPropertyBag *pPropBag, VARIANT *friendly_name, VARIANT *clsid_name)
1414 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
1415 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
1417 HRESULT hr;
1419 VariantInit(friendly_name);
1420 VariantInit(clsid_name);
1422 hr = IPropertyBag_Read(pPropBag, wszFriendlyName, friendly_name, 0);
1423 if (FAILED(hr))
1424 return hr;
1426 hr = IPropertyBag_Read(pPropBag, wszClsidName, clsid_name, 0);
1427 if (FAILED(hr))
1429 VariantClear(friendly_name);
1430 return hr;
1433 return S_OK;
1436 static HRESULT fill_filter_data_information(IDxDiagContainerImpl_Container *subcont, BYTE *pData, ULONG cb)
1438 static const WCHAR szVersionW[] = {'s','z','V','e','r','s','i','o','n',0};
1439 static const WCHAR dwInputs[] = {'d','w','I','n','p','u','t','s',0};
1440 static const WCHAR dwOutputs[] = {'d','w','O','u','t','p','u','t','s',0};
1441 static const WCHAR dwMeritW[] = {'d','w','M','e','r','i','t',0};
1442 static const WCHAR szVersionFormat[] = {'v','%','d',0};
1444 HRESULT hr;
1445 IFilterMapper2 *pFileMapper = NULL;
1446 IAMFilterData *pFilterData = NULL;
1447 BYTE *ppRF = NULL;
1448 REGFILTER2 *pRF = NULL;
1449 WCHAR bufferW[10];
1450 ULONG j;
1451 DWORD dwNOutputs = 0;
1452 DWORD dwNInputs = 0;
1454 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2,
1455 (void **)&pFileMapper);
1456 if (FAILED(hr))
1457 return hr;
1459 hr = IFilterMapper2_QueryInterface(pFileMapper, &IID_IAMFilterData, (void **)&pFilterData);
1460 if (FAILED(hr))
1461 goto cleanup;
1463 hr = IAMFilterData_ParseFilterData(pFilterData, pData, cb, (BYTE **)&ppRF);
1464 if (FAILED(hr))
1465 goto cleanup;
1466 pRF = ((REGFILTER2**)ppRF)[0];
1468 snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szVersionFormat, pRF->dwVersion);
1469 hr = add_bstr_property(subcont, szVersionW, bufferW);
1470 if (FAILED(hr))
1471 goto cleanup;
1473 if (pRF->dwVersion == 1)
1475 for (j = 0; j < pRF->u.s1.cPins; j++)
1476 if (pRF->u.s1.rgPins[j].bOutput)
1477 dwNOutputs++;
1478 else
1479 dwNInputs++;
1481 else if (pRF->dwVersion == 2)
1483 for (j = 0; j < pRF->u.s2.cPins2; j++)
1484 if (pRF->u.s2.rgPins2[j].dwFlags & REG_PINFLAG_B_OUTPUT)
1485 dwNOutputs++;
1486 else
1487 dwNInputs++;
1490 hr = add_ui4_property(subcont, dwInputs, dwNInputs);
1491 if (FAILED(hr))
1492 goto cleanup;
1494 hr = add_ui4_property(subcont, dwOutputs, dwNOutputs);
1495 if (FAILED(hr))
1496 goto cleanup;
1498 hr = add_ui4_property(subcont, dwMeritW, pRF->dwMerit);
1499 if (FAILED(hr))
1500 goto cleanup;
1502 hr = S_OK;
1503 cleanup:
1504 CoTaskMemFree(pRF);
1505 if (pFilterData) IAMFilterData_Release(pFilterData);
1506 if (pFileMapper) IFilterMapper2_Release(pFileMapper);
1508 return hr;
1511 static HRESULT fill_filter_container(IDxDiagContainerImpl_Container *subcont, IMoniker *pMoniker)
1513 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
1514 static const WCHAR ClsidFilterW[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
1515 static const WCHAR wszFilterDataName[] = {'F','i','l','t','e','r','D','a','t','a',0};
1517 HRESULT hr;
1518 IPropertyBag *pPropFilterBag = NULL;
1519 BYTE *pData;
1520 VARIANT friendly_name;
1521 VARIANT clsid_name;
1522 VARIANT v;
1524 VariantInit(&friendly_name);
1525 VariantInit(&clsid_name);
1526 VariantInit(&v);
1528 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (void **)&pPropFilterBag);
1529 if (FAILED(hr))
1530 return hr;
1532 hr = read_property_names(pPropFilterBag, &friendly_name, &clsid_name);
1533 if (FAILED(hr))
1534 goto cleanup;
1536 TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name)));
1537 TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name)));
1539 hr = add_bstr_property(subcont, szName, V_BSTR(&friendly_name));
1540 if (FAILED(hr))
1541 goto cleanup;
1543 hr = add_bstr_property(subcont, ClsidFilterW, V_BSTR(&clsid_name));
1544 if (FAILED(hr))
1545 goto cleanup;
1547 hr = IPropertyBag_Read(pPropFilterBag, wszFilterDataName, &v, NULL);
1548 if (FAILED(hr))
1549 goto cleanup;
1551 hr = SafeArrayAccessData(V_ARRAY(&v), (void **)&pData);
1552 if (FAILED(hr))
1553 goto cleanup;
1555 hr = fill_filter_data_information(subcont, pData, V_ARRAY(&v)->rgsabound->cElements);
1556 SafeArrayUnaccessData(V_ARRAY(&v));
1557 if (FAILED(hr))
1558 goto cleanup;
1560 hr = S_OK;
1561 cleanup:
1562 VariantClear(&v);
1563 VariantClear(&clsid_name);
1564 VariantClear(&friendly_name);
1565 if (pPropFilterBag) IPropertyBag_Release(pPropFilterBag);
1567 return hr;
1570 static HRESULT build_directshowfilters_tree(IDxDiagContainerImpl_Container *node)
1572 static const WCHAR szCatName[] = {'s','z','C','a','t','N','a','m','e',0};
1573 static const WCHAR ClsidCatW[] = {'C','l','s','i','d','C','a','t',0};
1574 static const WCHAR szIdFormat[] = {'%','d',0};
1576 HRESULT hr;
1577 int i = 0;
1578 ICreateDevEnum *pCreateDevEnum;
1579 IEnumMoniker *pEmCat = NULL;
1580 IMoniker *pMCat = NULL;
1581 IEnumMoniker *pEnum = NULL;
1583 hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER,
1584 &IID_ICreateDevEnum, (void **)&pCreateDevEnum);
1585 if (FAILED(hr))
1586 return hr;
1588 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &CLSID_ActiveMovieCategories, &pEmCat, 0);
1589 if (FAILED(hr))
1590 goto cleanup;
1592 while (IEnumMoniker_Next(pEmCat, 1, &pMCat, NULL) == S_OK)
1594 VARIANT vCatName;
1595 VARIANT vCatClsid;
1596 IPropertyBag *pPropBag;
1597 CLSID clsidCat;
1598 IMoniker *pMoniker = NULL;
1600 hr = IMoniker_BindToStorage(pMCat, NULL, NULL, &IID_IPropertyBag, (void **)&pPropBag);
1601 if (FAILED(hr))
1603 IMoniker_Release(pMCat);
1604 break;
1607 hr = read_property_names(pPropBag, &vCatName, &vCatClsid);
1608 IPropertyBag_Release(pPropBag);
1609 if (FAILED(hr))
1611 IMoniker_Release(pMCat);
1612 break;
1615 hr = CLSIDFromString(V_BSTR(&vCatClsid), &clsidCat);
1616 if (FAILED(hr))
1618 IMoniker_Release(pMCat);
1619 VariantClear(&vCatClsid);
1620 VariantClear(&vCatName);
1621 break;
1624 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &clsidCat, &pEnum, 0);
1625 if (hr != S_OK)
1627 IMoniker_Release(pMCat);
1628 VariantClear(&vCatClsid);
1629 VariantClear(&vCatName);
1630 continue;
1633 TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat));
1635 while (IEnumMoniker_Next(pEnum, 1, &pMoniker, NULL) == S_OK)
1637 WCHAR bufferW[10];
1638 IDxDiagContainerImpl_Container *subcont;
1640 snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szIdFormat, i);
1641 subcont = allocate_information_node(bufferW);
1642 if (!subcont)
1644 hr = E_OUTOFMEMORY;
1645 IMoniker_Release(pMoniker);
1646 break;
1649 hr = add_bstr_property(subcont, szCatName, V_BSTR(&vCatName));
1650 if (FAILED(hr))
1652 free_information_tree(subcont);
1653 IMoniker_Release(pMoniker);
1654 break;
1657 hr = add_bstr_property(subcont, ClsidCatW, V_BSTR(&vCatClsid));
1658 if (FAILED(hr))
1660 free_information_tree(subcont);
1661 IMoniker_Release(pMoniker);
1662 break;
1665 hr = fill_filter_container(subcont, pMoniker);
1666 IMoniker_Release(pMoniker);
1667 if (FAILED(hr))
1669 WARN("Skipping invalid filter\n");
1670 free_information_tree(subcont);
1671 hr = S_OK;
1672 continue;
1675 add_subcontainer(node, subcont);
1676 i++;
1679 IEnumMoniker_Release(pEnum);
1680 IMoniker_Release(pMCat);
1681 VariantClear(&vCatClsid);
1682 VariantClear(&vCatName);
1684 if (FAILED(hr))
1685 break;
1688 cleanup:
1689 if (pEmCat) IEnumMoniker_Release(pEmCat);
1690 ICreateDevEnum_Release(pCreateDevEnum);
1691 return hr;
1694 static HRESULT build_logicaldisks_tree(IDxDiagContainerImpl_Container *node)
1696 return S_OK;
1699 static HRESULT build_information_tree(IDxDiagContainerImpl_Container **pinfo_root)
1701 static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
1702 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};
1703 static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
1704 static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
1705 static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
1706 static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
1707 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};
1708 static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
1709 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};
1710 static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
1712 static const struct
1714 const WCHAR *name;
1715 HRESULT (*initfunc)(IDxDiagContainerImpl_Container *);
1716 } root_children[] =
1718 {DxDiag_SystemInfo, build_systeminfo_tree},
1719 {DxDiag_DisplayDevices, build_displaydevices_tree},
1720 {DxDiag_DirectSound, build_directsound_tree},
1721 {DxDiag_DirectMusic, build_directmusic_tree},
1722 {DxDiag_DirectInput, build_directinput_tree},
1723 {DxDiag_DirectPlay, build_directplay_tree},
1724 {DxDiag_SystemDevices, build_systemdevices_tree},
1725 {DxDiag_DirectXFiles, build_directxfiles_tree},
1726 {DxDiag_DirectShowFilters, build_directshowfilters_tree},
1727 {DxDiag_LogicalDisks, build_logicaldisks_tree},
1730 IDxDiagContainerImpl_Container *info_root;
1731 size_t index;
1733 info_root = allocate_information_node(NULL);
1734 if (!info_root)
1735 return E_OUTOFMEMORY;
1737 for (index = 0; index < sizeof(root_children)/sizeof(root_children[0]); index++)
1739 IDxDiagContainerImpl_Container *node;
1740 HRESULT hr;
1742 node = allocate_information_node(root_children[index].name);
1743 if (!node)
1745 free_information_tree(info_root);
1746 return E_OUTOFMEMORY;
1749 hr = root_children[index].initfunc(node);
1750 if (FAILED(hr))
1752 free_information_tree(node);
1753 free_information_tree(info_root);
1754 return hr;
1757 add_subcontainer(info_root, node);
1760 *pinfo_root = info_root;
1761 return S_OK;