2 * IDxDiagProvider Implementation
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 "dxdiag_private.h"
34 static const WCHAR szEmpty
[] = {0};
36 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
);
37 static void free_information_tree(IDxDiagContainerImpl_Container
*node
);
39 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
40 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
41 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
42 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
43 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
44 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
45 static const WCHAR szDeviceIdentifier
[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
46 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
47 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
48 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
49 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};
50 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};
51 static const WCHAR szDriverName
[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0};
52 static const WCHAR szDriverVersion
[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0};
53 static const WCHAR szSubSysId
[] = {'s','z','S','u','b','S','y','s','I','d',0};
54 static const WCHAR szRevisionId
[] = {'s','z','R','e','v','i','s','i','o','n','I','d',0};
55 static const WCHAR dwRefreshRate
[] = {'d','w','R','e','f','r','e','s','h','R','a','t','e',0};
56 static const WCHAR szManufacturer
[] = {'s','z','M','a','n','u','f','a','c','t','u','r','e','r',0};
57 static const WCHAR szChipType
[] = {'s','z','C','h','i','p','T','y','p','e',0};
58 static const WCHAR szDACType
[] = {'s','z','D','A','C','T','y','p','e',0};
59 static const WCHAR szRevision
[] = {'s','z','R','e','v','i','s','i','o','n',0};
61 struct IDxDiagProviderImpl
63 IDxDiagProvider IDxDiagProvider_iface
;
66 DXDIAG_INIT_PARAMS params
;
67 IDxDiagContainerImpl_Container
*info_root
;
70 static inline IDxDiagProviderImpl
*impl_from_IDxDiagProvider(IDxDiagProvider
*iface
)
72 return CONTAINING_RECORD(iface
, IDxDiagProviderImpl
, IDxDiagProvider_iface
);
75 /* IDxDiagProvider IUnknown parts follow: */
76 static HRESULT WINAPI
IDxDiagProviderImpl_QueryInterface(IDxDiagProvider
*iface
, REFIID riid
,
79 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
81 if (!ppobj
) return E_INVALIDARG
;
83 if (IsEqualGUID(riid
, &IID_IUnknown
)
84 || IsEqualGUID(riid
, &IID_IDxDiagProvider
)) {
85 IUnknown_AddRef(iface
);
90 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
95 static ULONG WINAPI
IDxDiagProviderImpl_AddRef(IDxDiagProvider
*iface
)
97 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
98 ULONG refCount
= InterlockedIncrement(&This
->ref
);
100 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
102 DXDIAGN_LockModule();
107 static ULONG WINAPI
IDxDiagProviderImpl_Release(IDxDiagProvider
*iface
)
109 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
110 ULONG refCount
= InterlockedDecrement(&This
->ref
);
112 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
115 free_information_tree(This
->info_root
);
116 HeapFree(GetProcessHeap(), 0, This
);
119 DXDIAGN_UnlockModule();
124 /* IDxDiagProvider Interface follow: */
125 static HRESULT WINAPI
IDxDiagProviderImpl_Initialize(IDxDiagProvider
*iface
,
126 DXDIAG_INIT_PARAMS
*pParams
)
128 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
131 TRACE("(%p,%p)\n", iface
, pParams
);
133 if (NULL
== pParams
) {
136 if (pParams
->dwSize
!= sizeof(DXDIAG_INIT_PARAMS
) ||
137 pParams
->dwDxDiagHeaderVersion
!= DXDIAG_DX9_SDK_VERSION
) {
141 if (!This
->info_root
)
143 hr
= build_information_tree(&This
->info_root
);
149 memcpy(&This
->params
, pParams
, pParams
->dwSize
);
153 static HRESULT WINAPI
IDxDiagProviderImpl_GetRootContainer(IDxDiagProvider
*iface
,
154 IDxDiagContainer
**ppInstance
)
156 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
158 TRACE("(%p,%p)\n", iface
, ppInstance
);
160 if (FALSE
== This
->init
) {
161 return CO_E_NOTINITIALIZED
;
164 return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, This
->info_root
,
165 &This
->IDxDiagProvider_iface
, (void **)ppInstance
);
168 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl
=
170 IDxDiagProviderImpl_QueryInterface
,
171 IDxDiagProviderImpl_AddRef
,
172 IDxDiagProviderImpl_Release
,
173 IDxDiagProviderImpl_Initialize
,
174 IDxDiagProviderImpl_GetRootContainer
177 HRESULT
DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
) {
178 IDxDiagProviderImpl
* provider
;
180 TRACE("(%p, %s, %p)\n", punkOuter
, debugstr_guid(riid
), ppobj
);
183 if (punkOuter
) return CLASS_E_NOAGGREGATION
;
185 provider
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagProviderImpl
));
186 if (NULL
== provider
) return E_OUTOFMEMORY
;
187 provider
->IDxDiagProvider_iface
.lpVtbl
= &DxDiagProvider_Vtbl
;
188 provider
->ref
= 0; /* will be inited with QueryInterface */
189 return IDxDiagProviderImpl_QueryInterface(&provider
->IDxDiagProvider_iface
, riid
, ppobj
);
192 static void free_property_information(IDxDiagContainerImpl_Property
*prop
)
194 VariantClear(&prop
->vProp
);
195 HeapFree(GetProcessHeap(), 0, prop
->propName
);
196 HeapFree(GetProcessHeap(), 0, prop
);
199 static void free_information_tree(IDxDiagContainerImpl_Container
*node
)
201 IDxDiagContainerImpl_Container
*ptr
, *cursor2
;
206 HeapFree(GetProcessHeap(), 0, node
->contName
);
208 LIST_FOR_EACH_ENTRY_SAFE(ptr
, cursor2
, &node
->subContainers
, IDxDiagContainerImpl_Container
, entry
)
210 IDxDiagContainerImpl_Property
*prop
, *prop_cursor2
;
212 LIST_FOR_EACH_ENTRY_SAFE(prop
, prop_cursor2
, &ptr
->properties
, IDxDiagContainerImpl_Property
, entry
)
214 list_remove(&prop
->entry
);
215 free_property_information(prop
);
218 list_remove(&ptr
->entry
);
219 free_information_tree(ptr
);
222 HeapFree(GetProcessHeap(), 0, node
);
225 static IDxDiagContainerImpl_Container
*allocate_information_node(const WCHAR
*name
)
227 IDxDiagContainerImpl_Container
*ret
;
229 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
235 ret
->contName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
238 HeapFree(GetProcessHeap(), 0, ret
);
241 strcpyW(ret
->contName
, name
);
244 list_init(&ret
->subContainers
);
245 list_init(&ret
->properties
);
250 static IDxDiagContainerImpl_Property
*allocate_property_information(const WCHAR
*name
)
252 IDxDiagContainerImpl_Property
*ret
;
254 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
258 ret
->propName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
261 HeapFree(GetProcessHeap(), 0, ret
);
264 strcpyW(ret
->propName
, name
);
269 static inline void add_subcontainer(IDxDiagContainerImpl_Container
*node
, IDxDiagContainerImpl_Container
*subCont
)
271 list_add_tail(&node
->subContainers
, &subCont
->entry
);
272 ++node
->nSubContainers
;
275 static inline HRESULT
add_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, const WCHAR
*str
)
277 IDxDiagContainerImpl_Property
*prop
;
280 prop
= allocate_property_information(propName
);
282 return E_OUTOFMEMORY
;
284 bstr
= SysAllocString(str
);
287 free_property_information(prop
);
288 return E_OUTOFMEMORY
;
291 V_VT(&prop
->vProp
) = VT_BSTR
;
292 V_BSTR(&prop
->vProp
) = bstr
;
294 list_add_tail(&node
->properties
, &prop
->entry
);
300 static inline HRESULT
add_ui4_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, DWORD data
)
302 IDxDiagContainerImpl_Property
*prop
;
304 prop
= allocate_property_information(propName
);
306 return E_OUTOFMEMORY
;
308 V_VT(&prop
->vProp
) = VT_UI4
;
309 V_UI4(&prop
->vProp
) = data
;
311 list_add_tail(&node
->properties
, &prop
->entry
);
317 static inline HRESULT
add_bool_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, BOOL data
)
319 IDxDiagContainerImpl_Property
*prop
;
321 prop
= allocate_property_information(propName
);
323 return E_OUTOFMEMORY
;
325 V_VT(&prop
->vProp
) = VT_BOOL
;
326 V_BOOL(&prop
->vProp
) = data
? VARIANT_TRUE
: VARIANT_FALSE
;
328 list_add_tail(&node
->properties
, &prop
->entry
);
334 static inline HRESULT
add_ull_as_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, ULONGLONG data
)
336 IDxDiagContainerImpl_Property
*prop
;
338 prop
= allocate_property_information(propName
);
340 return E_OUTOFMEMORY
;
342 V_VT(&prop
->vProp
) = VT_UI8
;
343 V_UI8(&prop
->vProp
) = data
;
345 VariantChangeType(&prop
->vProp
, &prop
->vProp
, 0, VT_BSTR
);
347 list_add_tail(&node
->properties
, &prop
->entry
);
353 /* Copied from programs/taskkill/taskkill.c. */
354 static DWORD
*enumerate_processes(DWORD
*list_count
)
356 DWORD
*pid_list
, alloc_bytes
= 1024 * sizeof(*pid_list
), needed_bytes
;
358 pid_list
= HeapAlloc(GetProcessHeap(), 0, alloc_bytes
);
366 if (!EnumProcesses(pid_list
, alloc_bytes
, &needed_bytes
))
368 HeapFree(GetProcessHeap(), 0, pid_list
);
372 /* EnumProcesses can't signal an insufficient buffer condition, so the
373 * only way to possibly determine whether a larger buffer is required
374 * is to see whether the written number of bytes is the same as the
375 * buffer size. If so, the buffer will be reallocated to twice the
377 if (alloc_bytes
!= needed_bytes
)
381 realloc_list
= HeapReAlloc(GetProcessHeap(), 0, pid_list
, alloc_bytes
);
384 HeapFree(GetProcessHeap(), 0, pid_list
);
387 pid_list
= realloc_list
;
390 *list_count
= needed_bytes
/ sizeof(*pid_list
);
394 /* Copied from programs/taskkill/taskkill.c. */
395 static BOOL
get_process_name_from_pid(DWORD pid
, WCHAR
*buf
, DWORD chars
)
401 process
= OpenProcess(PROCESS_QUERY_INFORMATION
| PROCESS_VM_READ
, FALSE
, pid
);
405 if (!EnumProcessModules(process
, &module
, sizeof(module
), &required_size
))
407 CloseHandle(process
);
411 if (!GetModuleBaseNameW(process
, module
, buf
, chars
))
413 CloseHandle(process
);
417 CloseHandle(process
);
421 /* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
422 static BOOL
is_netmeeting_running(void)
424 static const WCHAR conf_exe
[] = {'c','o','n','f','.','e','x','e',0};
427 DWORD
*pid_list
= enumerate_processes(&list_count
);
432 WCHAR process_name
[MAX_PATH
];
434 for (i
= 0; i
< list_count
; i
++)
436 if (get_process_name_from_pid(pid_list
[i
], process_name
, sizeof(process_name
)/sizeof(WCHAR
)) &&
437 !lstrcmpW(conf_exe
, process_name
))
439 HeapFree(GetProcessHeap(), 0, pid_list
);
443 HeapFree(GetProcessHeap(), 0, pid_list
);
449 static HRESULT
fill_language_information(IDxDiagContainerImpl_Container
*node
)
451 static const WCHAR regional_setting_engW
[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
452 static const WCHAR languages_fmtW
[] = {'%','s',' ','(','%','s',':',' ','%','s',')',0};
453 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};
454 static const WCHAR szLanguagesEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
456 WCHAR system_lang
[80], regional_setting
[100], user_lang
[80], language_str
[300];
459 /* szLanguagesLocalized */
460 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SNATIVELANGNAME
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
461 LoadStringW(dxdiagn_instance
, IDS_REGIONAL_SETTING
, regional_setting
, sizeof(regional_setting
)/sizeof(WCHAR
));
462 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SNATIVELANGNAME
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
464 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting
, user_lang
);
466 hr
= add_bstr_property(node
, szLanguagesLocalized
, language_str
);
470 /* szLanguagesEnglish */
471 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SENGLANGUAGE
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
472 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SENGLANGUAGE
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
474 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting_engW
, user_lang
);
476 hr
= add_bstr_property(node
, szLanguagesEnglish
, language_str
);
483 static HRESULT
fill_datetime_information(IDxDiagContainerImpl_Container
*node
)
485 static const WCHAR date_fmtW
[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0};
486 static const WCHAR time_fmtW
[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
487 static const WCHAR datetime_fmtW
[] = {'%','s',',',' ','%','s',0};
488 static const WCHAR szTimeLocalized
[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
489 static const WCHAR szTimeEnglish
[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
492 WCHAR date_str
[80], time_str
[80], datetime_str
[200];
495 GetLocalTime(&curtime
);
497 GetTimeFormatW(LOCALE_NEUTRAL
, 0, &curtime
, time_fmtW
, time_str
, sizeof(time_str
)/sizeof(WCHAR
));
499 /* szTimeLocalized */
500 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_LONGDATE
, &curtime
, NULL
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
502 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
504 hr
= add_bstr_property(node
, szTimeLocalized
, datetime_str
);
509 GetDateFormatW(LOCALE_NEUTRAL
, 0, &curtime
, date_fmtW
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
511 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
513 hr
= add_bstr_property(node
, szTimeEnglish
, datetime_str
);
520 static HRESULT
fill_os_string_information(IDxDiagContainerImpl_Container
*node
, OSVERSIONINFOW
*info
)
522 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};
523 static const WCHAR szOSLocalized
[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
524 static const WCHAR szOSExLocalized
[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
525 static const WCHAR szOSExLongLocalized
[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
526 static const WCHAR szOSEnglish
[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
527 static const WCHAR szOSExEnglish
[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
528 static const WCHAR szOSExLongEnglish
[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
530 static const WCHAR
*prop_list
[] = {szOSLocalized
, szOSExLocalized
, szOSExLongLocalized
,
531 szOSEnglish
, szOSExEnglish
, szOSExLongEnglish
};
536 /* FIXME: OS detection should be performed, and localized OS strings
537 * should contain translated versions of the "build" phrase. */
538 for (i
= 0; i
< sizeof(prop_list
)/sizeof(prop_list
[0]); i
++)
540 hr
= add_bstr_property(node
, prop_list
[i
], winxpW
);
548 static HRESULT
fill_processor_information(IDxDiagContainerImpl_Container
*node
)
550 static const WCHAR szProcessorEnglish
[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
552 static const WCHAR cimv2W
[] = {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
553 static const WCHAR proc_classW
[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
554 static const WCHAR nameW
[] = {'N','a','m','e',0};
555 static const WCHAR max_clock_speedW
[] = {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
556 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};
558 static const WCHAR processor_fmtW
[] = {'%','s','(','%','d',' ','C','P','U','s',')',',',' ','~','%','d','M','H','z',0};
560 IWbemLocator
*wbem_locator
;
561 IWbemServices
*wbem_service
;
562 IWbemClassObject
*wbem_class
;
563 IEnumWbemClassObject
*wbem_enum
;
564 VARIANT cpu_name
, cpu_no
, clock_speed
;
565 WCHAR print_buf
[200];
570 hr
= CoCreateInstance(&CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
, (void**)&wbem_locator
);
574 bstr
= SysAllocString(cimv2W
);
576 IWbemLocator_Release(wbem_locator
);
577 return E_OUTOFMEMORY
;
579 hr
= IWbemLocator_ConnectServer(wbem_locator
, bstr
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, &wbem_service
);
580 IWbemLocator_Release(wbem_locator
);
585 bstr
= SysAllocString(proc_classW
);
587 IWbemServices_Release(wbem_service
);
588 return E_OUTOFMEMORY
;
590 hr
= IWbemServices_CreateInstanceEnum(wbem_service
, bstr
, WBEM_FLAG_SYSTEM_ONLY
, NULL
, &wbem_enum
);
591 IWbemServices_Release(wbem_service
);
596 hr
= IEnumWbemClassObject_Next(wbem_enum
, 1000, 1, &wbem_class
, &no
);
597 IEnumWbemClassObject_Release(wbem_enum
);
601 hr
= IWbemClassObject_Get(wbem_class
, cpu_noW
, 0, &cpu_no
, NULL
, NULL
);
603 IWbemClassObject_Release(wbem_class
);
606 hr
= IWbemClassObject_Get(wbem_class
, max_clock_speedW
, 0, &clock_speed
, NULL
, NULL
);
608 IWbemClassObject_Release(wbem_class
);
611 hr
= IWbemClassObject_Get(wbem_class
, nameW
, 0, &cpu_name
, NULL
, NULL
);
612 IWbemClassObject_Release(wbem_class
);
616 sprintfW(print_buf
, processor_fmtW
, V_BSTR(&cpu_name
), V_I4(&cpu_no
), V_I4(&clock_speed
));
617 VariantClear(&cpu_name
);
618 VariantClear(&cpu_no
);
619 VariantClear(&clock_speed
);
621 return add_bstr_property(node
, szProcessorEnglish
, print_buf
);
624 static HRESULT
build_systeminfo_tree(IDxDiagContainerImpl_Container
*node
)
626 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};
627 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};
628 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};
629 static const WCHAR szDirectXVersionLetter_v
[] = {'c',0};
630 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
631 static const WCHAR bNECPC98
[] = {'b','N','E','C','P','C','9','8',0};
632 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};
633 static const WCHAR szDirectXVersionEnglish_v
[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
634 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};
635 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};
636 static const WCHAR ullPhysicalMemory
[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
637 static const WCHAR ullUsedPageFile
[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
638 static const WCHAR ullAvailPageFile
[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
639 static const WCHAR bNetMeetingRunning
[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
640 static const WCHAR szWindowsDir
[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
641 static const WCHAR dwOSMajorVersion
[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
642 static const WCHAR dwOSMinorVersion
[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
643 static const WCHAR dwOSBuildNumber
[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
644 static const WCHAR dwOSPlatformID
[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
645 static const WCHAR szCSDVersion
[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
646 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};
647 static const WCHAR szPageFileLocalized
[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
648 static const WCHAR szPageFileEnglish
[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
649 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};
650 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};
651 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};
652 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};
653 static const WCHAR szBIOSEnglish
[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
654 static const WCHAR szSetupParamEnglish
[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
655 static const WCHAR szDxDiagVersion
[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
657 static const WCHAR notpresentW
[] = {'N','o','t',' ','p','r','e','s','e','n','t',0};
659 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};
660 static const WCHAR physmem_fmtW
[] = {'%','u','M','B',' ','R','A','M',0};
665 DWORD count
, usedpage_mb
, availpage_mb
;
666 WCHAR buffer
[MAX_PATH
], computer_name
[MAX_COMPUTERNAME_LENGTH
+ 1], print_buf
[200], localized_pagefile_fmt
[200];
669 hr
= add_ui4_property(node
, dwDirectXVersionMajor
, 9);
673 hr
= add_ui4_property(node
, dwDirectXVersionMinor
, 0);
677 hr
= add_bstr_property(node
, szDirectXVersionLetter
, szDirectXVersionLetter_v
);
681 hr
= add_bstr_property(node
, szDirectXVersionEnglish
, szDirectXVersionEnglish_v
);
685 hr
= add_bstr_property(node
, szDirectXVersionLongEnglish
, szDirectXVersionLongEnglish_v
);
689 hr
= add_bool_property(node
, bDebug
, FALSE
);
693 hr
= add_bool_property(node
, bNECPC98
, FALSE
);
697 msex
.dwLength
= sizeof(msex
);
698 GlobalMemoryStatusEx(&msex
);
700 hr
= add_ull_as_bstr_property(node
, ullPhysicalMemory
, msex
.ullTotalPhys
);
704 hr
= add_ull_as_bstr_property(node
, ullUsedPageFile
, msex
.ullTotalPageFile
- msex
.ullAvailPageFile
);
708 hr
= add_ull_as_bstr_property(node
, ullAvailPageFile
, msex
.ullAvailPageFile
);
712 hr
= add_bool_property(node
, bNetMeetingRunning
, is_netmeeting_running());
716 info
.dwOSVersionInfoSize
= sizeof(info
);
717 GetVersionExW(&info
);
719 hr
= add_ui4_property(node
, dwOSMajorVersion
, info
.dwMajorVersion
);
723 hr
= add_ui4_property(node
, dwOSMinorVersion
, info
.dwMinorVersion
);
727 hr
= add_ui4_property(node
, dwOSBuildNumber
, info
.dwBuildNumber
);
731 hr
= add_ui4_property(node
, dwOSPlatformID
, info
.dwPlatformId
);
735 hr
= add_bstr_property(node
, szCSDVersion
, info
.szCSDVersion
);
739 /* FIXME: Roundoff should not be done with truncated division. */
740 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), physmem_fmtW
, (DWORD
)(msex
.ullTotalPhys
/ (1024 * 1024)));
741 hr
= add_bstr_property(node
, szPhysicalMemoryEnglish
, print_buf
);
745 usedpage_mb
= (DWORD
)((msex
.ullTotalPageFile
- msex
.ullAvailPageFile
) / (1024 * 1024));
746 availpage_mb
= (DWORD
)(msex
.ullAvailPageFile
/ (1024 * 1024));
747 LoadStringW(dxdiagn_instance
, IDS_PAGE_FILE_FORMAT
, localized_pagefile_fmt
, sizeof(localized_pagefile_fmt
)/sizeof(WCHAR
));
748 args
[0] = usedpage_mb
;
749 args
[1] = availpage_mb
;
750 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
751 localized_pagefile_fmt
, 0, 0, print_buf
,
752 sizeof(print_buf
)/sizeof(*print_buf
), (__ms_va_list
*)args
);
754 hr
= add_bstr_property(node
, szPageFileLocalized
, print_buf
);
758 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), pagefile_fmtW
, usedpage_mb
, availpage_mb
);
760 hr
= add_bstr_property(node
, szPageFileEnglish
, print_buf
);
764 GetWindowsDirectoryW(buffer
, MAX_PATH
);
766 hr
= add_bstr_property(node
, szWindowsDir
, buffer
);
770 count
= sizeof(computer_name
)/sizeof(WCHAR
);
771 if (!GetComputerNameW(computer_name
, &count
))
774 hr
= add_bstr_property(node
, szMachineNameLocalized
, computer_name
);
778 hr
= add_bstr_property(node
, szMachineNameEnglish
, computer_name
);
782 hr
= add_bstr_property(node
, szSystemManufacturerEnglish
, szEmpty
);
786 hr
= add_bstr_property(node
, szSystemModelEnglish
, szEmpty
);
790 hr
= add_bstr_property(node
, szBIOSEnglish
, szEmpty
);
794 hr
= fill_processor_information(node
);
798 hr
= add_bstr_property(node
, szSetupParamEnglish
, notpresentW
);
802 hr
= add_bstr_property(node
, szDxDiagVersion
, szEmpty
);
806 hr
= fill_language_information(node
);
810 hr
= fill_datetime_information(node
);
814 hr
= fill_os_string_information(node
, &info
);
821 /* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
822 static DWORD
depth_for_pixelformat(D3DFORMAT format
)
826 case D3DFMT_P8
: return 8;
827 case D3DFMT_X1R5G5B5
: return 15;
828 case D3DFMT_R5G6B5
: return 16;
829 /* This case will fail to distinguish an original bpp of 24. */
830 case D3DFMT_X8R8G8B8
: return 32;
832 FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format
);
837 static BOOL
get_texture_memory(GUID
*adapter
, DWORD
*available_mem
)
839 IDirectDraw7
*pDirectDraw
;
843 hr
= DirectDrawCreateEx(adapter
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
846 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
847 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.u1
.dwCaps4
= 0;
848 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, available_mem
, NULL
);
849 IDirectDraw7_Release(pDirectDraw
);
857 static const WCHAR
*vendor_id_to_manufacturer_string(DWORD vendor_id
)
859 static const WCHAR atiW
[] = {'A','T','I',' ','T','e','c','h','n','o','l','o','g','i','e','s',' ','I','n','c','.',0};
860 static const WCHAR nvidiaW
[] = {'N','V','I','D','I','A',0};
861 static const WCHAR intelW
[] = {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
862 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
864 /* Enumeration copied from dlls/wined3d/wined3d_private.h and slightly modified. */
867 HW_VENDOR_AMD
= 0x1002,
868 HW_VENDOR_NVIDIA
= 0x10de,
869 HW_VENDOR_INTEL
= 0x8086,
876 case HW_VENDOR_NVIDIA
:
878 case HW_VENDOR_INTEL
:
881 FIXME("Unknown PCI vendor ID 0x%04x\n", vendor_id
);
886 static HRESULT
fill_display_information_d3d(IDxDiagContainerImpl_Container
*node
)
888 IDxDiagContainerImpl_Container
*display_adapter
;
890 IDirect3D9
*pDirect3D9
;
894 pDirect3D9
= Direct3DCreate9(D3D_SDK_VERSION
);
898 count
= IDirect3D9_GetAdapterCount(pDirect3D9
);
899 for (index
= 0; index
< count
; index
++)
901 static const WCHAR adapterid_fmtW
[] = {'%','u',0};
902 static const WCHAR driverversion_fmtW
[] = {'%','u','.','%','u','.','%','0','4','u','.','%','0','4','u',0};
903 static const WCHAR id_fmtW
[] = {'0','x','%','0','4','x',0};
904 static const WCHAR subsysid_fmtW
[] = {'0','x','%','0','8','x',0};
905 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
906 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};
907 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};
908 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};
909 static const WCHAR bNoHardware
[] = {'b','N','o','H','a','r','d','w','a','r','e',0};
911 D3DADAPTER_IDENTIFIER9 adapter_info
;
912 D3DDISPLAYMODE adapter_mode
;
913 D3DCAPS9 device_caps
;
914 DWORD available_mem
= 0;
917 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), adapterid_fmtW
, index
);
918 display_adapter
= allocate_information_node(buffer
);
919 if (!display_adapter
)
925 add_subcontainer(node
, display_adapter
);
927 hr
= IDirect3D9_GetAdapterIdentifier(pDirect3D9
, index
, 0, &adapter_info
);
930 WCHAR driverW
[sizeof(adapter_info
.Driver
)];
931 WCHAR descriptionW
[sizeof(adapter_info
.Description
)];
932 WCHAR devicenameW
[sizeof(adapter_info
.DeviceName
)];
934 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Driver
, -1, driverW
, sizeof(driverW
)/sizeof(WCHAR
));
935 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Description
, -1, descriptionW
, sizeof(descriptionW
)/sizeof(WCHAR
));
936 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.DeviceName
, -1, devicenameW
, sizeof(devicenameW
)/sizeof(WCHAR
));
938 hr
= add_bstr_property(display_adapter
, szDriverName
, driverW
);
942 hr
= add_bstr_property(display_adapter
, szDescription
, descriptionW
);
946 hr
= add_bstr_property(display_adapter
, szDeviceName
, devicenameW
);
950 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), driverversion_fmtW
,
951 HIWORD(adapter_info
.DriverVersion
.u
.HighPart
), LOWORD(adapter_info
.DriverVersion
.u
.HighPart
),
952 HIWORD(adapter_info
.DriverVersion
.u
.LowPart
), LOWORD(adapter_info
.DriverVersion
.u
.LowPart
));
954 hr
= add_bstr_property(display_adapter
, szDriverVersion
, buffer
);
958 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.VendorId
);
959 hr
= add_bstr_property(display_adapter
, szVendorId
, buffer
);
963 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.DeviceId
);
964 hr
= add_bstr_property(display_adapter
, szDeviceId
, buffer
);
968 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), subsysid_fmtW
, adapter_info
.SubSysId
);
969 hr
= add_bstr_property(display_adapter
, szSubSysId
, buffer
);
973 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.Revision
);
974 hr
= add_bstr_property(display_adapter
, szRevisionId
, buffer
);
978 StringFromGUID2(&adapter_info
.DeviceIdentifier
, buffer
, 39);
979 hr
= add_bstr_property(display_adapter
, szDeviceIdentifier
, buffer
);
983 hr
= add_bstr_property(display_adapter
, szManufacturer
, vendor_id_to_manufacturer_string(adapter_info
.VendorId
));
988 hr
= IDirect3D9_GetAdapterDisplayMode(pDirect3D9
, index
, &adapter_mode
);
991 hr
= add_ui4_property(display_adapter
, dwWidth
, adapter_mode
.Width
);
995 hr
= add_ui4_property(display_adapter
, dwHeight
, adapter_mode
.Height
);
999 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, adapter_mode
.RefreshRate
);
1003 hr
= add_ui4_property(display_adapter
, dwBpp
, depth_for_pixelformat(adapter_mode
.Format
));
1008 hr
= add_bstr_property(display_adapter
, szKeyDeviceKey
, szEmpty
);
1012 hr
= add_bstr_property(display_adapter
, szKeyDeviceID
, szEmpty
);
1016 hr
= add_bstr_property(display_adapter
, szChipType
, szEmpty
);
1020 hr
= add_bstr_property(display_adapter
, szDACType
, szEmpty
);
1024 hr
= add_bstr_property(display_adapter
, szRevision
, szEmpty
);
1028 if (!get_texture_memory(&adapter_info
.DeviceIdentifier
, &available_mem
))
1029 WARN("get_texture_memory helper failed\n");
1031 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, available_mem
/ 1000000.0f
);
1033 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
1037 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
1041 hr
= IDirect3D9_GetDeviceCaps(pDirect3D9
, index
, D3DDEVTYPE_HAL
, &device_caps
);
1042 hardware_accel
= SUCCEEDED(hr
);
1044 hr
= add_bool_property(display_adapter
, b3DAccelerationEnabled
, hardware_accel
);
1048 hr
= add_bool_property(display_adapter
, b3DAccelerationExists
, hardware_accel
);
1052 hr
= add_bool_property(display_adapter
, bDDAccelerationEnabled
, hardware_accel
);
1056 hr
= add_bool_property(display_adapter
, bNoHardware
, FALSE
);
1063 IDirect3D9_Release(pDirect3D9
);
1067 static HRESULT
fill_display_information_fallback(IDxDiagContainerImpl_Container
*node
)
1069 static const WCHAR szAdapterID
[] = {'0',0};
1070 static const WCHAR
*empty_properties
[] = {szDeviceIdentifier
, szVendorId
, szDeviceId
,
1071 szKeyDeviceKey
, szKeyDeviceID
, szDriverName
,
1072 szDriverVersion
, szSubSysId
, szRevisionId
,
1073 szManufacturer
, szChipType
, szDACType
, szRevision
};
1075 IDxDiagContainerImpl_Container
*display_adapter
;
1077 IDirectDraw7
*pDirectDraw
;
1079 DISPLAY_DEVICEW disp_dev
;
1080 DDSURFACEDESC2 surface_descr
;
1084 display_adapter
= allocate_information_node(szAdapterID
);
1085 if (!display_adapter
)
1086 return E_OUTOFMEMORY
;
1088 add_subcontainer(node
, display_adapter
);
1090 disp_dev
.cb
= sizeof(disp_dev
);
1091 if (EnumDisplayDevicesW( NULL
, 0, &disp_dev
, 0 ))
1093 hr
= add_bstr_property(display_adapter
, szDeviceName
, disp_dev
.DeviceName
);
1097 hr
= add_bstr_property(display_adapter
, szDescription
, disp_dev
.DeviceString
);
1102 /* Silently ignore a failure from DirectDrawCreateEx. */
1103 hr
= DirectDrawCreateEx(NULL
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
1107 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
1108 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.u1
.dwCaps4
= 0;
1109 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, &tmp
, NULL
);
1112 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
1114 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, tmp
/ 1000000.0f
);
1116 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
1120 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
1125 surface_descr
.dwSize
= sizeof(surface_descr
);
1126 hr
= IDirectDraw7_GetDisplayMode(pDirectDraw
, &surface_descr
);
1129 if (surface_descr
.dwFlags
& DDSD_WIDTH
)
1131 hr
= add_ui4_property(display_adapter
, dwWidth
, surface_descr
.dwWidth
);
1136 if (surface_descr
.dwFlags
& DDSD_HEIGHT
)
1138 hr
= add_ui4_property(display_adapter
, dwHeight
, surface_descr
.dwHeight
);
1143 if (surface_descr
.dwFlags
& DDSD_PIXELFORMAT
)
1145 hr
= add_ui4_property(display_adapter
, dwBpp
, surface_descr
.u4
.ddpfPixelFormat
.u1
.dwRGBBitCount
);
1151 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, 60);
1155 for (tmp
= 0; tmp
< sizeof(empty_properties
)/sizeof(empty_properties
[0]); tmp
++)
1157 hr
= add_bstr_property(display_adapter
, empty_properties
[tmp
], szEmpty
);
1164 IDirectDraw7_Release(pDirectDraw
);
1168 static HRESULT
build_displaydevices_tree(IDxDiagContainerImpl_Container
*node
)
1172 /* Try to use Direct3D to obtain the required information first. */
1173 hr
= fill_display_information_d3d(node
);
1177 return fill_display_information_fallback(node
);
1182 IDxDiagContainerImpl_Container
*cont
;
1187 static const WCHAR szGUIDFmt
[] =
1189 '%','0','8','x','-','%','0','4','x','-','%','0','4','x','-','%','0',
1190 '2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2',
1191 'x','%','0','2','x','%','0','2','x','%','0','2','x',0
1194 static LPWSTR
guid_to_string(LPWSTR lpwstr
, REFGUID lpcguid
)
1196 wsprintfW(lpwstr
, szGUIDFmt
, lpcguid
->Data1
, lpcguid
->Data2
,
1197 lpcguid
->Data3
, lpcguid
->Data4
[0], lpcguid
->Data4
[1],
1198 lpcguid
->Data4
[2], lpcguid
->Data4
[3], lpcguid
->Data4
[4],
1199 lpcguid
->Data4
[5], lpcguid
->Data4
[6], lpcguid
->Data4
[7]);
1204 BOOL CALLBACK
dsound_enum(LPGUID guid
, LPCWSTR desc
, LPCWSTR module
, LPVOID context
)
1206 static const WCHAR deviceid_fmtW
[] = {'%','u',0};
1207 static const WCHAR szGuidDeviceID
[] = {'s','z','G','u','i','d','D','e','v','i','c','e','I','D',0};
1208 static const WCHAR szDriverPath
[] = {'s','z','D','r','i','v','e','r','P','a','t','h',0};
1210 struct enum_context
*enum_ctx
= context
;
1211 IDxDiagContainerImpl_Container
*device
;
1213 const WCHAR
*p
, *name
;
1215 /* the default device is enumerated twice, one time without GUID */
1216 if (!guid
) return TRUE
;
1218 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), deviceid_fmtW
, enum_ctx
->index
);
1219 device
= allocate_information_node(buffer
);
1222 enum_ctx
->hr
= E_OUTOFMEMORY
;
1226 add_subcontainer(enum_ctx
->cont
, device
);
1228 guid_to_string(buffer
, guid
);
1229 enum_ctx
->hr
= add_bstr_property(device
, szGuidDeviceID
, buffer
);
1230 if (FAILED(enum_ctx
->hr
))
1233 enum_ctx
->hr
= add_bstr_property(device
, szDescription
, desc
);
1234 if (FAILED(enum_ctx
->hr
))
1237 enum_ctx
->hr
= add_bstr_property(device
, szDriverPath
, module
);
1238 if (FAILED(enum_ctx
->hr
))
1242 if ((p
= strrchrW(name
, '\\'))) name
= p
+ 1;
1243 if ((p
= strrchrW(name
, '/'))) name
= p
+ 1;
1245 enum_ctx
->hr
= add_bstr_property(device
, szDriverName
, name
);
1246 if (FAILED(enum_ctx
->hr
))
1253 static HRESULT
build_directsound_tree(IDxDiagContainerImpl_Container
*node
)
1255 static const WCHAR DxDiag_SoundDevices
[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
1256 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};
1258 struct enum_context enum_ctx
;
1259 IDxDiagContainerImpl_Container
*cont
;
1261 cont
= allocate_information_node(DxDiag_SoundDevices
);
1263 return E_OUTOFMEMORY
;
1265 add_subcontainer(node
, cont
);
1267 enum_ctx
.cont
= cont
;
1271 DirectSoundEnumerateW(dsound_enum
, &enum_ctx
);
1272 if (FAILED(enum_ctx
.hr
))
1275 cont
= allocate_information_node(DxDiag_SoundCaptureDevices
);
1277 return E_OUTOFMEMORY
;
1279 add_subcontainer(node
, cont
);
1281 enum_ctx
.cont
= cont
;
1285 DirectSoundCaptureEnumerateW(dsound_enum
, &enum_ctx
);
1286 if (FAILED(enum_ctx
.hr
))
1292 static HRESULT
build_directmusic_tree(IDxDiagContainerImpl_Container
*node
)
1297 static HRESULT
build_directinput_tree(IDxDiagContainerImpl_Container
*node
)
1302 static HRESULT
build_directplay_tree(IDxDiagContainerImpl_Container
*node
)
1307 static HRESULT
build_systemdevices_tree(IDxDiagContainerImpl_Container
*node
)
1312 static HRESULT
fill_file_description(IDxDiagContainerImpl_Container
*node
, const WCHAR
*szFilePath
, const WCHAR
*szFileName
)
1314 static const WCHAR szSlashSep
[] = {'\\',0};
1315 static const WCHAR szPath
[] = {'s','z','P','a','t','h',0};
1316 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1317 static const WCHAR szVersion
[] = {'s','z','V','e','r','s','i','o','n',0};
1318 static const WCHAR szAttributes
[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
1319 static const WCHAR szLanguageEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
1320 static const WCHAR dwFileTimeHigh
[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
1321 static const WCHAR dwFileTimeLow
[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
1322 static const WCHAR bBeta
[] = {'b','B','e','t','a',0};
1323 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
1324 static const WCHAR bExists
[] = {'b','E','x','i','s','t','s',0};
1327 static const WCHAR szFinal_Retail_v
[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
1328 static const WCHAR szEnglish_v
[] = {'E','n','g','l','i','s','h',0};
1329 static const WCHAR szVersionFormat
[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
1333 WCHAR szVersion_v
[1024];
1335 void *pVersionInfo
= NULL
;
1336 BOOL boolret
= FALSE
;
1338 VS_FIXEDFILEINFO
*pFileInfo
;
1340 TRACE("Filling container %p for %s in %s\n", node
,
1341 debugstr_w(szFileName
), debugstr_w(szFilePath
));
1343 szFile
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * (lstrlenW(szFilePath
) +
1344 lstrlenW(szFileName
) + 2 /* slash + terminator */));
1346 return E_OUTOFMEMORY
;
1348 lstrcpyW(szFile
, szFilePath
);
1349 lstrcatW(szFile
, szSlashSep
);
1350 lstrcatW(szFile
, szFileName
);
1352 retval
= GetFileVersionInfoSizeW(szFile
, &hdl
);
1355 pVersionInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
1362 if (GetFileVersionInfoW(szFile
, 0, retval
, pVersionInfo
) &&
1363 VerQueryValueW(pVersionInfo
, szSlashSep
, (void **)&pFileInfo
, &uiLength
))
1367 hr
= add_bstr_property(node
, szPath
, szFile
);
1371 hr
= add_bstr_property(node
, szName
, szFileName
);
1375 hr
= add_bool_property(node
, bExists
, boolret
);
1381 snprintfW(szVersion_v
, sizeof(szVersion_v
)/sizeof(szVersion_v
[0]),
1383 HIWORD(pFileInfo
->dwFileVersionMS
),
1384 LOWORD(pFileInfo
->dwFileVersionMS
),
1385 HIWORD(pFileInfo
->dwFileVersionLS
),
1386 LOWORD(pFileInfo
->dwFileVersionLS
));
1388 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v
));
1390 hr
= add_bstr_property(node
, szVersion
, szVersion_v
);
1394 hr
= add_bstr_property(node
, szAttributes
, szFinal_Retail_v
);
1398 hr
= add_bstr_property(node
, szLanguageEnglish
, szEnglish_v
);
1402 hr
= add_ui4_property(node
, dwFileTimeHigh
, pFileInfo
->dwFileDateMS
);
1406 hr
= add_ui4_property(node
, dwFileTimeLow
, pFileInfo
->dwFileDateLS
);
1410 hr
= add_bool_property(node
, bBeta
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_PRERELEASE
) != 0);
1414 hr
= add_bool_property(node
, bDebug
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_DEBUG
) != 0);
1421 HeapFree(GetProcessHeap(), 0, pVersionInfo
);
1422 HeapFree(GetProcessHeap(), 0, szFile
);
1426 static HRESULT
build_directxfiles_tree(IDxDiagContainerImpl_Container
*node
)
1428 static const WCHAR dlls
[][15] =
1430 {'d','3','d','8','.','d','l','l',0},
1431 {'d','3','d','9','.','d','l','l',0},
1432 {'d','d','r','a','w','.','d','l','l',0},
1433 {'d','e','v','e','n','u','m','.','d','l','l',0},
1434 {'d','i','n','p','u','t','8','.','d','l','l',0},
1435 {'d','i','n','p','u','t','.','d','l','l',0},
1436 {'d','m','b','a','n','d','.','d','l','l',0},
1437 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
1438 {'d','m','i','m','e','.','d','l','l',0},
1439 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
1440 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
1441 {'d','m','s','t','y','l','e','.','d','l','l',0},
1442 {'d','m','s','y','n','t','h','.','d','l','l',0},
1443 {'d','m','u','s','i','c','.','d','l','l',0},
1444 {'d','p','l','a','y','x','.','d','l','l',0},
1445 {'d','p','n','e','t','.','d','l','l',0},
1446 {'d','s','o','u','n','d','.','d','l','l',0},
1447 {'d','s','w','a','v','e','.','d','l','l',0},
1448 {'d','x','d','i','a','g','n','.','d','l','l',0},
1449 {'q','u','a','r','t','z','.','d','l','l',0}
1453 WCHAR szFilePath
[MAX_PATH
];
1456 GetSystemDirectoryW(szFilePath
, MAX_PATH
);
1458 for (i
= 0; i
< sizeof(dlls
) / sizeof(dlls
[0]); i
++)
1460 static const WCHAR szFormat
[] = {'%','d',0};
1463 IDxDiagContainerImpl_Container
*file_container
;
1465 snprintfW(szFileID
, sizeof(szFileID
)/sizeof(szFileID
[0]), szFormat
, i
);
1467 file_container
= allocate_information_node(szFileID
);
1468 if (!file_container
)
1469 return E_OUTOFMEMORY
;
1471 hr
= fill_file_description(file_container
, szFilePath
, dlls
[i
]);
1474 free_information_tree(file_container
);
1478 add_subcontainer(node
, file_container
);
1484 static HRESULT
read_property_names(IPropertyBag
*pPropBag
, VARIANT
*friendly_name
, VARIANT
*clsid_name
)
1486 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
1487 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
1491 VariantInit(friendly_name
);
1492 VariantInit(clsid_name
);
1494 hr
= IPropertyBag_Read(pPropBag
, wszFriendlyName
, friendly_name
, 0);
1498 hr
= IPropertyBag_Read(pPropBag
, wszClsidName
, clsid_name
, 0);
1501 VariantClear(friendly_name
);
1508 static HRESULT
fill_filter_data_information(IDxDiagContainerImpl_Container
*subcont
, BYTE
*pData
, ULONG cb
)
1510 static const WCHAR szVersionW
[] = {'s','z','V','e','r','s','i','o','n',0};
1511 static const WCHAR dwInputs
[] = {'d','w','I','n','p','u','t','s',0};
1512 static const WCHAR dwOutputs
[] = {'d','w','O','u','t','p','u','t','s',0};
1513 static const WCHAR dwMeritW
[] = {'d','w','M','e','r','i','t',0};
1514 static const WCHAR szVersionFormat
[] = {'v','%','d',0};
1517 IFilterMapper2
*pFileMapper
= NULL
;
1518 IAMFilterData
*pFilterData
= NULL
;
1520 REGFILTER2
*pRF
= NULL
;
1523 DWORD dwNOutputs
= 0;
1524 DWORD dwNInputs
= 0;
1526 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC
, &IID_IFilterMapper2
,
1527 (void **)&pFileMapper
);
1531 hr
= IFilterMapper2_QueryInterface(pFileMapper
, &IID_IAMFilterData
, (void **)&pFilterData
);
1535 hr
= IAMFilterData_ParseFilterData(pFilterData
, pData
, cb
, (BYTE
**)&ppRF
);
1538 pRF
= ((REGFILTER2
**)ppRF
)[0];
1540 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szVersionFormat
, pRF
->dwVersion
);
1541 hr
= add_bstr_property(subcont
, szVersionW
, bufferW
);
1545 if (pRF
->dwVersion
== 1)
1547 for (j
= 0; j
< pRF
->u
.s1
.cPins
; j
++)
1548 if (pRF
->u
.s1
.rgPins
[j
].bOutput
)
1553 else if (pRF
->dwVersion
== 2)
1555 for (j
= 0; j
< pRF
->u
.s2
.cPins2
; j
++)
1556 if (pRF
->u
.s2
.rgPins2
[j
].dwFlags
& REG_PINFLAG_B_OUTPUT
)
1562 hr
= add_ui4_property(subcont
, dwInputs
, dwNInputs
);
1566 hr
= add_ui4_property(subcont
, dwOutputs
, dwNOutputs
);
1570 hr
= add_ui4_property(subcont
, dwMeritW
, pRF
->dwMerit
);
1577 if (pFilterData
) IAMFilterData_Release(pFilterData
);
1578 if (pFileMapper
) IFilterMapper2_Release(pFileMapper
);
1583 static HRESULT
fill_filter_container(IDxDiagContainerImpl_Container
*subcont
, IMoniker
*pMoniker
)
1585 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1586 static const WCHAR ClsidFilterW
[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
1587 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
1590 IPropertyBag
*pPropFilterBag
= NULL
;
1592 VARIANT friendly_name
;
1596 VariantInit(&friendly_name
);
1597 VariantInit(&clsid_name
);
1600 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropFilterBag
);
1604 hr
= read_property_names(pPropFilterBag
, &friendly_name
, &clsid_name
);
1608 TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name
)));
1609 TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name
)));
1611 hr
= add_bstr_property(subcont
, szName
, V_BSTR(&friendly_name
));
1615 hr
= add_bstr_property(subcont
, ClsidFilterW
, V_BSTR(&clsid_name
));
1619 hr
= IPropertyBag_Read(pPropFilterBag
, wszFilterDataName
, &v
, NULL
);
1623 hr
= SafeArrayAccessData(V_ARRAY(&v
), (void **)&pData
);
1627 hr
= fill_filter_data_information(subcont
, pData
, V_ARRAY(&v
)->rgsabound
->cElements
);
1628 SafeArrayUnaccessData(V_ARRAY(&v
));
1635 VariantClear(&clsid_name
);
1636 VariantClear(&friendly_name
);
1637 if (pPropFilterBag
) IPropertyBag_Release(pPropFilterBag
);
1642 static HRESULT
build_directshowfilters_tree(IDxDiagContainerImpl_Container
*node
)
1644 static const WCHAR szCatName
[] = {'s','z','C','a','t','N','a','m','e',0};
1645 static const WCHAR ClsidCatW
[] = {'C','l','s','i','d','C','a','t',0};
1646 static const WCHAR szIdFormat
[] = {'%','d',0};
1650 ICreateDevEnum
*pCreateDevEnum
;
1651 IEnumMoniker
*pEmCat
= NULL
;
1652 IMoniker
*pMCat
= NULL
;
1653 IEnumMoniker
*pEnum
= NULL
;
1655 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC_SERVER
,
1656 &IID_ICreateDevEnum
, (void **)&pCreateDevEnum
);
1660 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEmCat
, 0);
1664 while (IEnumMoniker_Next(pEmCat
, 1, &pMCat
, NULL
) == S_OK
)
1668 IPropertyBag
*pPropBag
;
1670 IMoniker
*pMoniker
= NULL
;
1672 hr
= IMoniker_BindToStorage(pMCat
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropBag
);
1675 IMoniker_Release(pMCat
);
1679 hr
= read_property_names(pPropBag
, &vCatName
, &vCatClsid
);
1680 IPropertyBag_Release(pPropBag
);
1683 IMoniker_Release(pMCat
);
1687 hr
= CLSIDFromString(V_BSTR(&vCatClsid
), &clsidCat
);
1690 IMoniker_Release(pMCat
);
1691 VariantClear(&vCatClsid
);
1692 VariantClear(&vCatName
);
1696 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
1699 IMoniker_Release(pMCat
);
1700 VariantClear(&vCatClsid
);
1701 VariantClear(&vCatName
);
1705 TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat
));
1707 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
1710 IDxDiagContainerImpl_Container
*subcont
;
1712 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szIdFormat
, i
);
1713 subcont
= allocate_information_node(bufferW
);
1717 IMoniker_Release(pMoniker
);
1721 hr
= add_bstr_property(subcont
, szCatName
, V_BSTR(&vCatName
));
1724 free_information_tree(subcont
);
1725 IMoniker_Release(pMoniker
);
1729 hr
= add_bstr_property(subcont
, ClsidCatW
, V_BSTR(&vCatClsid
));
1732 free_information_tree(subcont
);
1733 IMoniker_Release(pMoniker
);
1737 hr
= fill_filter_container(subcont
, pMoniker
);
1738 IMoniker_Release(pMoniker
);
1741 WARN("Skipping invalid filter\n");
1742 free_information_tree(subcont
);
1747 add_subcontainer(node
, subcont
);
1751 IEnumMoniker_Release(pEnum
);
1752 IMoniker_Release(pMCat
);
1753 VariantClear(&vCatClsid
);
1754 VariantClear(&vCatName
);
1761 if (pEmCat
) IEnumMoniker_Release(pEmCat
);
1762 ICreateDevEnum_Release(pCreateDevEnum
);
1766 static HRESULT
build_logicaldisks_tree(IDxDiagContainerImpl_Container
*node
)
1771 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
)
1773 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
1774 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};
1775 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
1776 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
1777 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
1778 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
1779 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};
1780 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
1781 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};
1782 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
1787 HRESULT (*initfunc
)(IDxDiagContainerImpl_Container
*);
1790 {DxDiag_SystemInfo
, build_systeminfo_tree
},
1791 {DxDiag_DisplayDevices
, build_displaydevices_tree
},
1792 {DxDiag_DirectSound
, build_directsound_tree
},
1793 {DxDiag_DirectMusic
, build_directmusic_tree
},
1794 {DxDiag_DirectInput
, build_directinput_tree
},
1795 {DxDiag_DirectPlay
, build_directplay_tree
},
1796 {DxDiag_SystemDevices
, build_systemdevices_tree
},
1797 {DxDiag_DirectXFiles
, build_directxfiles_tree
},
1798 {DxDiag_DirectShowFilters
, build_directshowfilters_tree
},
1799 {DxDiag_LogicalDisks
, build_logicaldisks_tree
},
1802 IDxDiagContainerImpl_Container
*info_root
;
1805 info_root
= allocate_information_node(NULL
);
1807 return E_OUTOFMEMORY
;
1809 for (index
= 0; index
< sizeof(root_children
)/sizeof(root_children
[0]); index
++)
1811 IDxDiagContainerImpl_Container
*node
;
1814 node
= allocate_information_node(root_children
[index
].name
);
1817 free_information_tree(info_root
);
1818 return E_OUTOFMEMORY
;
1821 hr
= root_children
[index
].initfunc(node
);
1824 free_information_tree(node
);
1825 free_information_tree(info_root
);
1829 add_subcontainer(info_root
, node
);
1832 *pinfo_root
= info_root
;