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"
32 static const WCHAR szEmpty
[] = {0};
34 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
);
35 static void free_information_tree(IDxDiagContainerImpl_Container
*node
);
37 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
38 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
39 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
40 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
41 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
42 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
43 static const WCHAR szDeviceIdentifier
[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
44 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
45 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
46 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
47 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};
48 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};
49 static const WCHAR szDriverName
[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0};
50 static const WCHAR szDriverVersion
[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0};
51 static const WCHAR szSubSysId
[] = {'s','z','S','u','b','S','y','s','I','d',0};
52 static const WCHAR szRevisionId
[] = {'s','z','R','e','v','i','s','i','o','n','I','d',0};
53 static const WCHAR dwRefreshRate
[] = {'d','w','R','e','f','r','e','s','h','R','a','t','e',0};
54 static const WCHAR szManufacturer
[] = {'s','z','M','a','n','u','f','a','c','t','u','r','e','r',0};
55 static const WCHAR szChipType
[] = {'s','z','C','h','i','p','T','y','p','e',0};
56 static const WCHAR szDACType
[] = {'s','z','D','A','C','T','y','p','e',0};
57 static const WCHAR szRevision
[] = {'s','z','R','e','v','i','s','i','o','n',0};
59 struct IDxDiagProviderImpl
61 IDxDiagProvider IDxDiagProvider_iface
;
64 DXDIAG_INIT_PARAMS params
;
65 IDxDiagContainerImpl_Container
*info_root
;
68 static inline IDxDiagProviderImpl
*impl_from_IDxDiagProvider(IDxDiagProvider
*iface
)
70 return CONTAINING_RECORD(iface
, IDxDiagProviderImpl
, IDxDiagProvider_iface
);
73 /* IDxDiagProvider IUnknown parts follow: */
74 static HRESULT WINAPI
IDxDiagProviderImpl_QueryInterface(IDxDiagProvider
*iface
, REFIID riid
,
77 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
79 if (!ppobj
) return E_INVALIDARG
;
81 if (IsEqualGUID(riid
, &IID_IUnknown
)
82 || IsEqualGUID(riid
, &IID_IDxDiagProvider
)) {
83 IUnknown_AddRef(iface
);
88 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
93 static ULONG WINAPI
IDxDiagProviderImpl_AddRef(IDxDiagProvider
*iface
)
95 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
96 ULONG refCount
= InterlockedIncrement(&This
->ref
);
98 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
100 DXDIAGN_LockModule();
105 static ULONG WINAPI
IDxDiagProviderImpl_Release(IDxDiagProvider
*iface
)
107 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
108 ULONG refCount
= InterlockedDecrement(&This
->ref
);
110 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
113 free_information_tree(This
->info_root
);
114 HeapFree(GetProcessHeap(), 0, This
);
117 DXDIAGN_UnlockModule();
122 /* IDxDiagProvider Interface follow: */
123 static HRESULT WINAPI
IDxDiagProviderImpl_Initialize(IDxDiagProvider
*iface
,
124 DXDIAG_INIT_PARAMS
*pParams
)
126 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
129 TRACE("(%p,%p)\n", iface
, pParams
);
131 if (NULL
== pParams
) {
134 if (pParams
->dwSize
!= sizeof(DXDIAG_INIT_PARAMS
) ||
135 pParams
->dwDxDiagHeaderVersion
!= DXDIAG_DX9_SDK_VERSION
) {
139 if (!This
->info_root
)
141 hr
= build_information_tree(&This
->info_root
);
147 memcpy(&This
->params
, pParams
, pParams
->dwSize
);
151 static HRESULT WINAPI
IDxDiagProviderImpl_GetRootContainer(IDxDiagProvider
*iface
,
152 IDxDiagContainer
**ppInstance
)
154 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
156 TRACE("(%p,%p)\n", iface
, ppInstance
);
158 if (FALSE
== This
->init
) {
159 return CO_E_NOTINITIALIZED
;
162 return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, This
->info_root
,
163 &This
->IDxDiagProvider_iface
, (void **)ppInstance
);
166 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl
=
168 IDxDiagProviderImpl_QueryInterface
,
169 IDxDiagProviderImpl_AddRef
,
170 IDxDiagProviderImpl_Release
,
171 IDxDiagProviderImpl_Initialize
,
172 IDxDiagProviderImpl_GetRootContainer
175 HRESULT
DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
) {
176 IDxDiagProviderImpl
* provider
;
178 TRACE("(%p, %s, %p)\n", punkOuter
, debugstr_guid(riid
), ppobj
);
181 if (punkOuter
) return CLASS_E_NOAGGREGATION
;
183 provider
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagProviderImpl
));
184 if (NULL
== provider
) return E_OUTOFMEMORY
;
185 provider
->IDxDiagProvider_iface
.lpVtbl
= &DxDiagProvider_Vtbl
;
186 provider
->ref
= 0; /* will be inited with QueryInterface */
187 return IDxDiagProviderImpl_QueryInterface(&provider
->IDxDiagProvider_iface
, riid
, ppobj
);
190 static void free_property_information(IDxDiagContainerImpl_Property
*prop
)
192 VariantClear(&prop
->vProp
);
193 HeapFree(GetProcessHeap(), 0, prop
->propName
);
194 HeapFree(GetProcessHeap(), 0, prop
);
197 static void free_information_tree(IDxDiagContainerImpl_Container
*node
)
199 IDxDiagContainerImpl_Container
*ptr
, *cursor2
;
204 HeapFree(GetProcessHeap(), 0, node
->contName
);
206 LIST_FOR_EACH_ENTRY_SAFE(ptr
, cursor2
, &node
->subContainers
, IDxDiagContainerImpl_Container
, entry
)
208 IDxDiagContainerImpl_Property
*prop
, *prop_cursor2
;
210 LIST_FOR_EACH_ENTRY_SAFE(prop
, prop_cursor2
, &ptr
->properties
, IDxDiagContainerImpl_Property
, entry
)
212 list_remove(&prop
->entry
);
213 free_property_information(prop
);
216 list_remove(&ptr
->entry
);
217 free_information_tree(ptr
);
220 HeapFree(GetProcessHeap(), 0, node
);
223 static IDxDiagContainerImpl_Container
*allocate_information_node(const WCHAR
*name
)
225 IDxDiagContainerImpl_Container
*ret
;
227 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
233 ret
->contName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
236 HeapFree(GetProcessHeap(), 0, ret
);
239 strcpyW(ret
->contName
, name
);
242 list_init(&ret
->subContainers
);
243 list_init(&ret
->properties
);
248 static IDxDiagContainerImpl_Property
*allocate_property_information(const WCHAR
*name
)
250 IDxDiagContainerImpl_Property
*ret
;
252 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
256 ret
->propName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
259 HeapFree(GetProcessHeap(), 0, ret
);
262 strcpyW(ret
->propName
, name
);
267 static inline void add_subcontainer(IDxDiagContainerImpl_Container
*node
, IDxDiagContainerImpl_Container
*subCont
)
269 list_add_tail(&node
->subContainers
, &subCont
->entry
);
270 ++node
->nSubContainers
;
273 static inline HRESULT
add_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, const WCHAR
*str
)
275 IDxDiagContainerImpl_Property
*prop
;
278 prop
= allocate_property_information(propName
);
280 return E_OUTOFMEMORY
;
282 bstr
= SysAllocString(str
);
285 free_property_information(prop
);
286 return E_OUTOFMEMORY
;
289 V_VT(&prop
->vProp
) = VT_BSTR
;
290 V_BSTR(&prop
->vProp
) = bstr
;
292 list_add_tail(&node
->properties
, &prop
->entry
);
298 static inline HRESULT
add_ui4_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, DWORD data
)
300 IDxDiagContainerImpl_Property
*prop
;
302 prop
= allocate_property_information(propName
);
304 return E_OUTOFMEMORY
;
306 V_VT(&prop
->vProp
) = VT_UI4
;
307 V_UI4(&prop
->vProp
) = data
;
309 list_add_tail(&node
->properties
, &prop
->entry
);
315 static inline HRESULT
add_bool_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, BOOL data
)
317 IDxDiagContainerImpl_Property
*prop
;
319 prop
= allocate_property_information(propName
);
321 return E_OUTOFMEMORY
;
323 V_VT(&prop
->vProp
) = VT_BOOL
;
324 V_BOOL(&prop
->vProp
) = data
;
326 list_add_tail(&node
->properties
, &prop
->entry
);
332 static inline HRESULT
add_ull_as_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, ULONGLONG data
)
334 IDxDiagContainerImpl_Property
*prop
;
336 prop
= allocate_property_information(propName
);
338 return E_OUTOFMEMORY
;
340 V_VT(&prop
->vProp
) = VT_UI8
;
341 V_UI8(&prop
->vProp
) = data
;
343 VariantChangeType(&prop
->vProp
, &prop
->vProp
, 0, VT_BSTR
);
345 list_add_tail(&node
->properties
, &prop
->entry
);
351 /* Copied from programs/taskkill/taskkill.c. */
352 static DWORD
*enumerate_processes(DWORD
*list_count
)
354 DWORD
*pid_list
, alloc_bytes
= 1024 * sizeof(*pid_list
), needed_bytes
;
356 pid_list
= HeapAlloc(GetProcessHeap(), 0, alloc_bytes
);
364 if (!EnumProcesses(pid_list
, alloc_bytes
, &needed_bytes
))
366 HeapFree(GetProcessHeap(), 0, pid_list
);
370 /* EnumProcesses can't signal an insufficient buffer condition, so the
371 * only way to possibly determine whether a larger buffer is required
372 * is to see whether the written number of bytes is the same as the
373 * buffer size. If so, the buffer will be reallocated to twice the
375 if (alloc_bytes
!= needed_bytes
)
379 realloc_list
= HeapReAlloc(GetProcessHeap(), 0, pid_list
, alloc_bytes
);
382 HeapFree(GetProcessHeap(), 0, pid_list
);
385 pid_list
= realloc_list
;
388 *list_count
= needed_bytes
/ sizeof(*pid_list
);
392 /* Copied from programs/taskkill/taskkill.c. */
393 static BOOL
get_process_name_from_pid(DWORD pid
, WCHAR
*buf
, DWORD chars
)
399 process
= OpenProcess(PROCESS_QUERY_INFORMATION
| PROCESS_VM_READ
, FALSE
, pid
);
403 if (!EnumProcessModules(process
, &module
, sizeof(module
), &required_size
))
405 CloseHandle(process
);
409 if (!GetModuleBaseNameW(process
, module
, buf
, chars
))
411 CloseHandle(process
);
415 CloseHandle(process
);
419 /* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
420 static BOOL
is_netmeeting_running(void)
422 static const WCHAR conf_exe
[] = {'c','o','n','f','.','e','x','e',0};
425 DWORD
*pid_list
= enumerate_processes(&list_count
);
430 WCHAR process_name
[MAX_PATH
];
432 for (i
= 0; i
< list_count
; i
++)
434 if (get_process_name_from_pid(pid_list
[i
], process_name
, sizeof(process_name
)/sizeof(WCHAR
)) &&
435 !lstrcmpW(conf_exe
, process_name
))
437 HeapFree(GetProcessHeap(), 0, pid_list
);
441 HeapFree(GetProcessHeap(), 0, pid_list
);
447 static HRESULT
fill_language_information(IDxDiagContainerImpl_Container
*node
)
449 static const WCHAR regional_setting_engW
[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
450 static const WCHAR languages_fmtW
[] = {'%','s',' ','(','%','s',':',' ','%','s',')',0};
451 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};
452 static const WCHAR szLanguagesEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
454 WCHAR system_lang
[80], regional_setting
[100], user_lang
[80], language_str
[300];
457 /* szLanguagesLocalized */
458 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SNATIVELANGNAME
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
459 LoadStringW(dxdiagn_instance
, IDS_REGIONAL_SETTING
, regional_setting
, sizeof(regional_setting
)/sizeof(WCHAR
));
460 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SNATIVELANGNAME
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
462 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting
, user_lang
);
464 hr
= add_bstr_property(node
, szLanguagesLocalized
, language_str
);
468 /* szLanguagesEnglish */
469 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SENGLANGUAGE
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
470 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SENGLANGUAGE
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
472 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting_engW
, user_lang
);
474 hr
= add_bstr_property(node
, szLanguagesEnglish
, language_str
);
481 static HRESULT
fill_datetime_information(IDxDiagContainerImpl_Container
*node
)
483 static const WCHAR date_fmtW
[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0};
484 static const WCHAR time_fmtW
[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
485 static const WCHAR datetime_fmtW
[] = {'%','s',',',' ','%','s',0};
486 static const WCHAR szTimeLocalized
[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
487 static const WCHAR szTimeEnglish
[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
490 WCHAR date_str
[80], time_str
[80], datetime_str
[200];
493 GetLocalTime(&curtime
);
495 GetTimeFormatW(LOCALE_NEUTRAL
, 0, &curtime
, time_fmtW
, time_str
, sizeof(time_str
)/sizeof(WCHAR
));
497 /* szTimeLocalized */
498 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_LONGDATE
, &curtime
, NULL
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
500 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
502 hr
= add_bstr_property(node
, szTimeLocalized
, datetime_str
);
507 GetDateFormatW(LOCALE_NEUTRAL
, 0, &curtime
, date_fmtW
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
509 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
511 hr
= add_bstr_property(node
, szTimeEnglish
, datetime_str
);
518 static HRESULT
fill_os_string_information(IDxDiagContainerImpl_Container
*node
, OSVERSIONINFOW
*info
)
520 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};
521 static const WCHAR szOSLocalized
[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
522 static const WCHAR szOSExLocalized
[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
523 static const WCHAR szOSExLongLocalized
[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
524 static const WCHAR szOSEnglish
[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
525 static const WCHAR szOSExEnglish
[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
526 static const WCHAR szOSExLongEnglish
[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
528 static const WCHAR
*prop_list
[] = {szOSLocalized
, szOSExLocalized
, szOSExLongLocalized
,
529 szOSEnglish
, szOSExEnglish
, szOSExLongEnglish
};
534 /* FIXME: OS detection should be performed, and localized OS strings
535 * should contain translated versions of the "build" phrase. */
536 for (i
= 0; i
< sizeof(prop_list
)/sizeof(prop_list
[0]); i
++)
538 hr
= add_bstr_property(node
, prop_list
[i
], winxpW
);
546 static HRESULT
fill_processor_information(IDxDiagContainerImpl_Container
*node
)
548 static const WCHAR szProcessorEnglish
[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
550 static const WCHAR cimv2W
[] = {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
551 static const WCHAR proc_classW
[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
552 static const WCHAR nameW
[] = {'N','a','m','e',0};
553 static const WCHAR max_clock_speedW
[] = {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
554 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};
556 static const WCHAR processor_fmtW
[] = {'%','s','(','%','d',' ','C','P','U','s',')',',',' ','~','%','d','M','H','z',0};
558 IWbemLocator
*wbem_locator
;
559 IWbemServices
*wbem_service
;
560 IWbemClassObject
*wbem_class
;
561 IEnumWbemClassObject
*wbem_enum
;
562 VARIANT cpu_name
, cpu_no
, clock_speed
;
563 WCHAR print_buf
[200];
568 hr
= CoCreateInstance(&CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
, (void**)&wbem_locator
);
572 bstr
= SysAllocString(cimv2W
);
574 IWbemLocator_Release(wbem_locator
);
575 return E_OUTOFMEMORY
;
577 hr
= IWbemLocator_ConnectServer(wbem_locator
, bstr
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, &wbem_service
);
578 IWbemLocator_Release(wbem_locator
);
583 bstr
= SysAllocString(proc_classW
);
585 IWbemServices_Release(wbem_service
);
586 return E_OUTOFMEMORY
;
588 hr
= IWbemServices_CreateInstanceEnum(wbem_service
, bstr
, WBEM_FLAG_SYSTEM_ONLY
, NULL
, &wbem_enum
);
589 IWbemServices_Release(wbem_service
);
594 hr
= IEnumWbemClassObject_Next(wbem_enum
, 1000, 1, &wbem_class
, &no
);
595 IEnumWbemClassObject_Release(wbem_enum
);
599 hr
= IWbemClassObject_Get(wbem_class
, cpu_noW
, 0, &cpu_no
, NULL
, NULL
);
601 IWbemClassObject_Release(wbem_class
);
604 hr
= IWbemClassObject_Get(wbem_class
, max_clock_speedW
, 0, &clock_speed
, NULL
, NULL
);
606 IWbemClassObject_Release(wbem_class
);
609 hr
= IWbemClassObject_Get(wbem_class
, nameW
, 0, &cpu_name
, NULL
, NULL
);
610 IWbemClassObject_Release(wbem_class
);
614 sprintfW(print_buf
, processor_fmtW
, V_BSTR(&cpu_name
), V_I4(&cpu_no
), V_I4(&clock_speed
));
615 VariantClear(&cpu_name
);
616 VariantClear(&cpu_no
);
617 VariantClear(&clock_speed
);
619 return add_bstr_property(node
, szProcessorEnglish
, print_buf
);
622 static HRESULT
build_systeminfo_tree(IDxDiagContainerImpl_Container
*node
)
624 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};
625 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};
626 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};
627 static const WCHAR szDirectXVersionLetter_v
[] = {'c',0};
628 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
629 static const WCHAR bNECPC98
[] = {'b','N','E','C','P','C','9','8',0};
630 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};
631 static const WCHAR szDirectXVersionEnglish_v
[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
632 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};
633 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};
634 static const WCHAR ullPhysicalMemory
[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
635 static const WCHAR ullUsedPageFile
[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
636 static const WCHAR ullAvailPageFile
[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
637 static const WCHAR bNetMeetingRunning
[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
638 static const WCHAR szWindowsDir
[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
639 static const WCHAR dwOSMajorVersion
[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
640 static const WCHAR dwOSMinorVersion
[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
641 static const WCHAR dwOSBuildNumber
[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
642 static const WCHAR dwOSPlatformID
[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
643 static const WCHAR szCSDVersion
[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
644 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};
645 static const WCHAR szPageFileLocalized
[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
646 static const WCHAR szPageFileEnglish
[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
647 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};
648 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};
649 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};
650 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};
651 static const WCHAR szBIOSEnglish
[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
652 static const WCHAR szSetupParamEnglish
[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
653 static const WCHAR szDxDiagVersion
[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
655 static const WCHAR notpresentW
[] = {'N','o','t',' ','p','r','e','s','e','n','t',0};
657 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};
658 static const WCHAR physmem_fmtW
[] = {'%','u','M','B',' ','R','A','M',0};
663 DWORD count
, usedpage_mb
, availpage_mb
;
664 WCHAR buffer
[MAX_PATH
], computer_name
[MAX_COMPUTERNAME_LENGTH
+ 1], print_buf
[200], localized_pagefile_fmt
[200];
667 hr
= add_ui4_property(node
, dwDirectXVersionMajor
, 9);
671 hr
= add_ui4_property(node
, dwDirectXVersionMinor
, 0);
675 hr
= add_bstr_property(node
, szDirectXVersionLetter
, szDirectXVersionLetter_v
);
679 hr
= add_bstr_property(node
, szDirectXVersionEnglish
, szDirectXVersionEnglish_v
);
683 hr
= add_bstr_property(node
, szDirectXVersionLongEnglish
, szDirectXVersionLongEnglish_v
);
687 hr
= add_bool_property(node
, bDebug
, FALSE
);
691 hr
= add_bool_property(node
, bNECPC98
, FALSE
);
695 msex
.dwLength
= sizeof(msex
);
696 GlobalMemoryStatusEx(&msex
);
698 hr
= add_ull_as_bstr_property(node
, ullPhysicalMemory
, msex
.ullTotalPhys
);
702 hr
= add_ull_as_bstr_property(node
, ullUsedPageFile
, msex
.ullTotalPageFile
- msex
.ullAvailPageFile
);
706 hr
= add_ull_as_bstr_property(node
, ullAvailPageFile
, msex
.ullAvailPageFile
);
710 hr
= add_bool_property(node
, bNetMeetingRunning
, is_netmeeting_running());
714 info
.dwOSVersionInfoSize
= sizeof(info
);
715 GetVersionExW(&info
);
717 hr
= add_ui4_property(node
, dwOSMajorVersion
, info
.dwMajorVersion
);
721 hr
= add_ui4_property(node
, dwOSMinorVersion
, info
.dwMinorVersion
);
725 hr
= add_ui4_property(node
, dwOSBuildNumber
, info
.dwBuildNumber
);
729 hr
= add_ui4_property(node
, dwOSPlatformID
, info
.dwPlatformId
);
733 hr
= add_bstr_property(node
, szCSDVersion
, info
.szCSDVersion
);
737 /* FIXME: Roundoff should not be done with truncated division. */
738 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), physmem_fmtW
, (DWORD
)(msex
.ullTotalPhys
/ (1024 * 1024)));
739 hr
= add_bstr_property(node
, szPhysicalMemoryEnglish
, print_buf
);
743 usedpage_mb
= (DWORD
)((msex
.ullTotalPageFile
- msex
.ullAvailPageFile
) / (1024 * 1024));
744 availpage_mb
= (DWORD
)(msex
.ullAvailPageFile
/ (1024 * 1024));
745 LoadStringW(dxdiagn_instance
, IDS_PAGE_FILE_FORMAT
, localized_pagefile_fmt
, sizeof(localized_pagefile_fmt
)/sizeof(WCHAR
));
746 args
[0] = usedpage_mb
;
747 args
[1] = availpage_mb
;
748 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
749 localized_pagefile_fmt
, 0, 0, print_buf
,
750 sizeof(print_buf
)/sizeof(*print_buf
), (__ms_va_list
*)args
);
752 hr
= add_bstr_property(node
, szPageFileLocalized
, print_buf
);
756 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), pagefile_fmtW
, usedpage_mb
, availpage_mb
);
758 hr
= add_bstr_property(node
, szPageFileEnglish
, print_buf
);
762 GetWindowsDirectoryW(buffer
, MAX_PATH
);
764 hr
= add_bstr_property(node
, szWindowsDir
, buffer
);
768 count
= sizeof(computer_name
)/sizeof(WCHAR
);
769 if (!GetComputerNameW(computer_name
, &count
))
772 hr
= add_bstr_property(node
, szMachineNameLocalized
, computer_name
);
776 hr
= add_bstr_property(node
, szMachineNameEnglish
, computer_name
);
780 hr
= add_bstr_property(node
, szSystemManufacturerEnglish
, szEmpty
);
784 hr
= add_bstr_property(node
, szSystemModelEnglish
, szEmpty
);
788 hr
= add_bstr_property(node
, szBIOSEnglish
, szEmpty
);
792 hr
= fill_processor_information(node
);
796 hr
= add_bstr_property(node
, szSetupParamEnglish
, notpresentW
);
800 hr
= add_bstr_property(node
, szDxDiagVersion
, szEmpty
);
804 hr
= fill_language_information(node
);
808 hr
= fill_datetime_information(node
);
812 hr
= fill_os_string_information(node
, &info
);
819 /* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
820 static DWORD
depth_for_pixelformat(D3DFORMAT format
)
824 case D3DFMT_P8
: return 8;
825 case D3DFMT_X1R5G5B5
: return 15;
826 case D3DFMT_R5G6B5
: return 16;
827 /* This case will fail to distinguish an original bpp of 24. */
828 case D3DFMT_X8R8G8B8
: return 32;
830 FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format
);
835 static BOOL
get_texture_memory(GUID
*adapter
, DWORD
*available_mem
)
837 IDirectDraw7
*pDirectDraw
;
841 hr
= DirectDrawCreateEx(adapter
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
844 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
845 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.u1
.dwCaps4
= 0;
846 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, available_mem
, NULL
);
847 IDirectDraw7_Release(pDirectDraw
);
855 static const WCHAR
*vendor_id_to_manufacturer_string(DWORD vendor_id
)
857 static const WCHAR atiW
[] = {'A','T','I',' ','T','e','c','h','n','o','l','o','g','i','e','s',' ','I','n','c','.',0};
858 static const WCHAR nvidiaW
[] = {'N','V','I','D','I','A',0};
859 static const WCHAR intelW
[] = {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
860 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
862 /* Enumeration copied from dlls/wined3d/wined3d_private.h and slightly modified. */
865 HW_VENDOR_AMD
= 0x1002,
866 HW_VENDOR_NVIDIA
= 0x10de,
867 HW_VENDOR_INTEL
= 0x8086,
874 case HW_VENDOR_NVIDIA
:
876 case HW_VENDOR_INTEL
:
879 FIXME("Unknown PCI vendor ID 0x%04x\n", vendor_id
);
884 static HRESULT
fill_display_information_d3d(IDxDiagContainerImpl_Container
*node
)
886 IDxDiagContainerImpl_Container
*display_adapter
;
888 IDirect3D9
*pDirect3D9
;
892 pDirect3D9
= Direct3DCreate9(D3D_SDK_VERSION
);
896 count
= IDirect3D9_GetAdapterCount(pDirect3D9
);
897 for (index
= 0; index
< count
; index
++)
899 static const WCHAR adapterid_fmtW
[] = {'%','u',0};
900 static const WCHAR driverversion_fmtW
[] = {'%','u','.','%','u','.','%','0','4','u','.','%','0','4','u',0};
901 static const WCHAR id_fmtW
[] = {'0','x','%','0','4','x',0};
902 static const WCHAR subsysid_fmtW
[] = {'0','x','%','0','8','x',0};
903 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
904 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};
905 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};
906 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};
907 static const WCHAR bNoHardware
[] = {'b','N','o','H','a','r','d','w','a','r','e',0};
909 D3DADAPTER_IDENTIFIER9 adapter_info
;
910 D3DDISPLAYMODE adapter_mode
;
911 D3DCAPS9 device_caps
;
912 DWORD available_mem
= 0;
915 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), adapterid_fmtW
, index
);
916 display_adapter
= allocate_information_node(buffer
);
917 if (!display_adapter
)
923 add_subcontainer(node
, display_adapter
);
925 hr
= IDirect3D9_GetAdapterIdentifier(pDirect3D9
, index
, 0, &adapter_info
);
928 WCHAR driverW
[sizeof(adapter_info
.Driver
)];
929 WCHAR descriptionW
[sizeof(adapter_info
.Description
)];
930 WCHAR devicenameW
[sizeof(adapter_info
.DeviceName
)];
932 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Driver
, -1, driverW
, sizeof(driverW
)/sizeof(WCHAR
));
933 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Description
, -1, descriptionW
, sizeof(descriptionW
)/sizeof(WCHAR
));
934 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.DeviceName
, -1, devicenameW
, sizeof(devicenameW
)/sizeof(WCHAR
));
936 hr
= add_bstr_property(display_adapter
, szDriverName
, driverW
);
940 hr
= add_bstr_property(display_adapter
, szDescription
, descriptionW
);
944 hr
= add_bstr_property(display_adapter
, szDeviceName
, devicenameW
);
948 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), driverversion_fmtW
,
949 HIWORD(adapter_info
.DriverVersion
.u
.HighPart
), LOWORD(adapter_info
.DriverVersion
.u
.HighPart
),
950 HIWORD(adapter_info
.DriverVersion
.u
.LowPart
), LOWORD(adapter_info
.DriverVersion
.u
.LowPart
));
952 hr
= add_bstr_property(display_adapter
, szDriverVersion
, buffer
);
956 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.VendorId
);
957 hr
= add_bstr_property(display_adapter
, szVendorId
, buffer
);
961 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.DeviceId
);
962 hr
= add_bstr_property(display_adapter
, szDeviceId
, buffer
);
966 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), subsysid_fmtW
, adapter_info
.SubSysId
);
967 hr
= add_bstr_property(display_adapter
, szSubSysId
, buffer
);
971 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.Revision
);
972 hr
= add_bstr_property(display_adapter
, szRevisionId
, buffer
);
976 StringFromGUID2(&adapter_info
.DeviceIdentifier
, buffer
, 39);
977 hr
= add_bstr_property(display_adapter
, szDeviceIdentifier
, buffer
);
981 hr
= add_bstr_property(display_adapter
, szManufacturer
, vendor_id_to_manufacturer_string(adapter_info
.VendorId
));
986 hr
= IDirect3D9_GetAdapterDisplayMode(pDirect3D9
, index
, &adapter_mode
);
989 hr
= add_ui4_property(display_adapter
, dwWidth
, adapter_mode
.Width
);
993 hr
= add_ui4_property(display_adapter
, dwHeight
, adapter_mode
.Height
);
997 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, adapter_mode
.RefreshRate
);
1001 hr
= add_ui4_property(display_adapter
, dwBpp
, depth_for_pixelformat(adapter_mode
.Format
));
1006 hr
= add_bstr_property(display_adapter
, szKeyDeviceKey
, szEmpty
);
1010 hr
= add_bstr_property(display_adapter
, szKeyDeviceID
, szEmpty
);
1014 hr
= add_bstr_property(display_adapter
, szChipType
, szEmpty
);
1018 hr
= add_bstr_property(display_adapter
, szDACType
, szEmpty
);
1022 hr
= add_bstr_property(display_adapter
, szRevision
, szEmpty
);
1026 if (!get_texture_memory(&adapter_info
.DeviceIdentifier
, &available_mem
))
1027 WARN("get_texture_memory helper failed\n");
1029 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, available_mem
/ 1000000.0f
);
1031 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
1035 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
1039 hr
= IDirect3D9_GetDeviceCaps(pDirect3D9
, index
, D3DDEVTYPE_HAL
, &device_caps
);
1040 hardware_accel
= SUCCEEDED(hr
);
1042 hr
= add_bool_property(display_adapter
, b3DAccelerationEnabled
, hardware_accel
);
1046 hr
= add_bool_property(display_adapter
, b3DAccelerationExists
, hardware_accel
);
1050 hr
= add_bool_property(display_adapter
, bDDAccelerationEnabled
, hardware_accel
);
1054 hr
= add_bool_property(display_adapter
, bNoHardware
, FALSE
);
1061 IDirect3D9_Release(pDirect3D9
);
1065 static HRESULT
fill_display_information_fallback(IDxDiagContainerImpl_Container
*node
)
1067 static const WCHAR szAdapterID
[] = {'0',0};
1068 static const WCHAR
*empty_properties
[] = {szDeviceIdentifier
, szVendorId
, szDeviceId
,
1069 szKeyDeviceKey
, szKeyDeviceID
, szDriverName
,
1070 szDriverVersion
, szSubSysId
, szRevisionId
,
1071 szManufacturer
, szChipType
, szDACType
, szRevision
};
1073 IDxDiagContainerImpl_Container
*display_adapter
;
1075 IDirectDraw7
*pDirectDraw
;
1077 DISPLAY_DEVICEW disp_dev
;
1078 DDSURFACEDESC2 surface_descr
;
1082 display_adapter
= allocate_information_node(szAdapterID
);
1083 if (!display_adapter
)
1084 return E_OUTOFMEMORY
;
1086 add_subcontainer(node
, display_adapter
);
1088 disp_dev
.cb
= sizeof(disp_dev
);
1089 if (EnumDisplayDevicesW( NULL
, 0, &disp_dev
, 0 ))
1091 hr
= add_bstr_property(display_adapter
, szDeviceName
, disp_dev
.DeviceName
);
1095 hr
= add_bstr_property(display_adapter
, szDescription
, disp_dev
.DeviceString
);
1100 /* Silently ignore a failure from DirectDrawCreateEx. */
1101 hr
= DirectDrawCreateEx(NULL
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
1105 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
1106 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.u1
.dwCaps4
= 0;
1107 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, &tmp
, NULL
);
1110 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
1112 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, tmp
/ 1000000.0f
);
1114 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
1118 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
1123 surface_descr
.dwSize
= sizeof(surface_descr
);
1124 hr
= IDirectDraw7_GetDisplayMode(pDirectDraw
, &surface_descr
);
1127 if (surface_descr
.dwFlags
& DDSD_WIDTH
)
1129 hr
= add_ui4_property(display_adapter
, dwWidth
, surface_descr
.dwWidth
);
1134 if (surface_descr
.dwFlags
& DDSD_HEIGHT
)
1136 hr
= add_ui4_property(display_adapter
, dwHeight
, surface_descr
.dwHeight
);
1141 if (surface_descr
.dwFlags
& DDSD_PIXELFORMAT
)
1143 hr
= add_ui4_property(display_adapter
, dwBpp
, surface_descr
.u4
.ddpfPixelFormat
.u1
.dwRGBBitCount
);
1149 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, 60);
1153 for (tmp
= 0; tmp
< sizeof(empty_properties
)/sizeof(empty_properties
[0]); tmp
++)
1155 hr
= add_bstr_property(display_adapter
, empty_properties
[tmp
], szEmpty
);
1162 IDirectDraw7_Release(pDirectDraw
);
1166 static HRESULT
build_displaydevices_tree(IDxDiagContainerImpl_Container
*node
)
1170 /* Try to use Direct3D to obtain the required information first. */
1171 hr
= fill_display_information_d3d(node
);
1175 return fill_display_information_fallback(node
);
1178 static HRESULT
build_directsound_tree(IDxDiagContainerImpl_Container
*node
)
1180 static const WCHAR DxDiag_SoundDevices
[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
1181 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};
1183 IDxDiagContainerImpl_Container
*cont
;
1185 cont
= allocate_information_node(DxDiag_SoundDevices
);
1187 return E_OUTOFMEMORY
;
1189 add_subcontainer(node
, cont
);
1191 cont
= allocate_information_node(DxDiag_SoundCaptureDevices
);
1193 return E_OUTOFMEMORY
;
1195 add_subcontainer(node
, cont
);
1200 static HRESULT
build_directmusic_tree(IDxDiagContainerImpl_Container
*node
)
1205 static HRESULT
build_directinput_tree(IDxDiagContainerImpl_Container
*node
)
1210 static HRESULT
build_directplay_tree(IDxDiagContainerImpl_Container
*node
)
1215 static HRESULT
build_systemdevices_tree(IDxDiagContainerImpl_Container
*node
)
1220 static HRESULT
fill_file_description(IDxDiagContainerImpl_Container
*node
, const WCHAR
*szFilePath
, const WCHAR
*szFileName
)
1222 static const WCHAR szSlashSep
[] = {'\\',0};
1223 static const WCHAR szPath
[] = {'s','z','P','a','t','h',0};
1224 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1225 static const WCHAR szVersion
[] = {'s','z','V','e','r','s','i','o','n',0};
1226 static const WCHAR szAttributes
[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
1227 static const WCHAR szLanguageEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
1228 static const WCHAR dwFileTimeHigh
[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
1229 static const WCHAR dwFileTimeLow
[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
1230 static const WCHAR bBeta
[] = {'b','B','e','t','a',0};
1231 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
1232 static const WCHAR bExists
[] = {'b','E','x','i','s','t','s',0};
1235 static const WCHAR szFinal_Retail_v
[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
1236 static const WCHAR szEnglish_v
[] = {'E','n','g','l','i','s','h',0};
1237 static const WCHAR szVersionFormat
[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
1241 WCHAR szVersion_v
[1024];
1243 void *pVersionInfo
= NULL
;
1244 BOOL boolret
= FALSE
;
1246 VS_FIXEDFILEINFO
*pFileInfo
;
1248 TRACE("Filling container %p for %s in %s\n", node
,
1249 debugstr_w(szFileName
), debugstr_w(szFilePath
));
1251 szFile
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * (lstrlenW(szFilePath
) +
1252 lstrlenW(szFileName
) + 2 /* slash + terminator */));
1254 return E_OUTOFMEMORY
;
1256 lstrcpyW(szFile
, szFilePath
);
1257 lstrcatW(szFile
, szSlashSep
);
1258 lstrcatW(szFile
, szFileName
);
1260 retval
= GetFileVersionInfoSizeW(szFile
, &hdl
);
1263 pVersionInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
1270 if (GetFileVersionInfoW(szFile
, 0, retval
, pVersionInfo
) &&
1271 VerQueryValueW(pVersionInfo
, szSlashSep
, (void **)&pFileInfo
, &uiLength
))
1275 hr
= add_bstr_property(node
, szPath
, szFile
);
1279 hr
= add_bstr_property(node
, szName
, szFileName
);
1283 hr
= add_bool_property(node
, bExists
, boolret
);
1289 snprintfW(szVersion_v
, sizeof(szVersion_v
)/sizeof(szVersion_v
[0]),
1291 HIWORD(pFileInfo
->dwFileVersionMS
),
1292 LOWORD(pFileInfo
->dwFileVersionMS
),
1293 HIWORD(pFileInfo
->dwFileVersionLS
),
1294 LOWORD(pFileInfo
->dwFileVersionLS
));
1296 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v
));
1298 hr
= add_bstr_property(node
, szVersion
, szVersion_v
);
1302 hr
= add_bstr_property(node
, szAttributes
, szFinal_Retail_v
);
1306 hr
= add_bstr_property(node
, szLanguageEnglish
, szEnglish_v
);
1310 hr
= add_ui4_property(node
, dwFileTimeHigh
, pFileInfo
->dwFileDateMS
);
1314 hr
= add_ui4_property(node
, dwFileTimeLow
, pFileInfo
->dwFileDateLS
);
1318 hr
= add_bool_property(node
, bBeta
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_PRERELEASE
) != 0);
1322 hr
= add_bool_property(node
, bDebug
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_DEBUG
) != 0);
1329 HeapFree(GetProcessHeap(), 0, pVersionInfo
);
1330 HeapFree(GetProcessHeap(), 0, szFile
);
1334 static HRESULT
build_directxfiles_tree(IDxDiagContainerImpl_Container
*node
)
1336 static const WCHAR dlls
[][15] =
1338 {'d','3','d','8','.','d','l','l',0},
1339 {'d','3','d','9','.','d','l','l',0},
1340 {'d','d','r','a','w','.','d','l','l',0},
1341 {'d','e','v','e','n','u','m','.','d','l','l',0},
1342 {'d','i','n','p','u','t','8','.','d','l','l',0},
1343 {'d','i','n','p','u','t','.','d','l','l',0},
1344 {'d','m','b','a','n','d','.','d','l','l',0},
1345 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
1346 {'d','m','i','m','e','.','d','l','l',0},
1347 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
1348 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
1349 {'d','m','s','t','y','l','e','.','d','l','l',0},
1350 {'d','m','s','y','n','t','h','.','d','l','l',0},
1351 {'d','m','u','s','i','c','.','d','l','l',0},
1352 {'d','p','l','a','y','x','.','d','l','l',0},
1353 {'d','p','n','e','t','.','d','l','l',0},
1354 {'d','s','o','u','n','d','.','d','l','l',0},
1355 {'d','s','w','a','v','e','.','d','l','l',0},
1356 {'d','x','d','i','a','g','n','.','d','l','l',0},
1357 {'q','u','a','r','t','z','.','d','l','l',0}
1361 WCHAR szFilePath
[MAX_PATH
];
1364 GetSystemDirectoryW(szFilePath
, MAX_PATH
);
1366 for (i
= 0; i
< sizeof(dlls
) / sizeof(dlls
[0]); i
++)
1368 static const WCHAR szFormat
[] = {'%','d',0};
1371 IDxDiagContainerImpl_Container
*file_container
;
1373 snprintfW(szFileID
, sizeof(szFileID
)/sizeof(szFileID
[0]), szFormat
, i
);
1375 file_container
= allocate_information_node(szFileID
);
1376 if (!file_container
)
1377 return E_OUTOFMEMORY
;
1379 hr
= fill_file_description(file_container
, szFilePath
, dlls
[i
]);
1382 free_information_tree(file_container
);
1386 add_subcontainer(node
, file_container
);
1392 static HRESULT
read_property_names(IPropertyBag
*pPropBag
, VARIANT
*friendly_name
, VARIANT
*clsid_name
)
1394 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
1395 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
1399 VariantInit(friendly_name
);
1400 VariantInit(clsid_name
);
1402 hr
= IPropertyBag_Read(pPropBag
, wszFriendlyName
, friendly_name
, 0);
1406 hr
= IPropertyBag_Read(pPropBag
, wszClsidName
, clsid_name
, 0);
1409 VariantClear(friendly_name
);
1416 static HRESULT
fill_filter_data_information(IDxDiagContainerImpl_Container
*subcont
, BYTE
*pData
, ULONG cb
)
1418 static const WCHAR szVersionW
[] = {'s','z','V','e','r','s','i','o','n',0};
1419 static const WCHAR dwInputs
[] = {'d','w','I','n','p','u','t','s',0};
1420 static const WCHAR dwOutputs
[] = {'d','w','O','u','t','p','u','t','s',0};
1421 static const WCHAR dwMeritW
[] = {'d','w','M','e','r','i','t',0};
1422 static const WCHAR szVersionFormat
[] = {'v','%','d',0};
1425 IFilterMapper2
*pFileMapper
= NULL
;
1426 IAMFilterData
*pFilterData
= NULL
;
1428 REGFILTER2
*pRF
= NULL
;
1431 DWORD dwNOutputs
= 0;
1432 DWORD dwNInputs
= 0;
1434 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC
, &IID_IFilterMapper2
,
1435 (void **)&pFileMapper
);
1439 hr
= IFilterMapper2_QueryInterface(pFileMapper
, &IID_IAMFilterData
, (void **)&pFilterData
);
1443 hr
= IAMFilterData_ParseFilterData(pFilterData
, pData
, cb
, (BYTE
**)&ppRF
);
1446 pRF
= ((REGFILTER2
**)ppRF
)[0];
1448 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szVersionFormat
, pRF
->dwVersion
);
1449 hr
= add_bstr_property(subcont
, szVersionW
, bufferW
);
1453 if (pRF
->dwVersion
== 1)
1455 for (j
= 0; j
< pRF
->u
.s1
.cPins
; j
++)
1456 if (pRF
->u
.s1
.rgPins
[j
].bOutput
)
1461 else if (pRF
->dwVersion
== 2)
1463 for (j
= 0; j
< pRF
->u
.s2
.cPins2
; j
++)
1464 if (pRF
->u
.s2
.rgPins2
[j
].dwFlags
& REG_PINFLAG_B_OUTPUT
)
1470 hr
= add_ui4_property(subcont
, dwInputs
, dwNInputs
);
1474 hr
= add_ui4_property(subcont
, dwOutputs
, dwNOutputs
);
1478 hr
= add_ui4_property(subcont
, dwMeritW
, pRF
->dwMerit
);
1485 if (pFilterData
) IAMFilterData_Release(pFilterData
);
1486 if (pFileMapper
) IFilterMapper2_Release(pFileMapper
);
1491 static HRESULT
fill_filter_container(IDxDiagContainerImpl_Container
*subcont
, IMoniker
*pMoniker
)
1493 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1494 static const WCHAR ClsidFilterW
[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
1495 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
1498 IPropertyBag
*pPropFilterBag
= NULL
;
1500 VARIANT friendly_name
;
1504 VariantInit(&friendly_name
);
1505 VariantInit(&clsid_name
);
1508 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropFilterBag
);
1512 hr
= read_property_names(pPropFilterBag
, &friendly_name
, &clsid_name
);
1516 TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name
)));
1517 TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name
)));
1519 hr
= add_bstr_property(subcont
, szName
, V_BSTR(&friendly_name
));
1523 hr
= add_bstr_property(subcont
, ClsidFilterW
, V_BSTR(&clsid_name
));
1527 hr
= IPropertyBag_Read(pPropFilterBag
, wszFilterDataName
, &v
, NULL
);
1531 hr
= SafeArrayAccessData(V_ARRAY(&v
), (void **)&pData
);
1535 hr
= fill_filter_data_information(subcont
, pData
, V_ARRAY(&v
)->rgsabound
->cElements
);
1536 SafeArrayUnaccessData(V_ARRAY(&v
));
1543 VariantClear(&clsid_name
);
1544 VariantClear(&friendly_name
);
1545 if (pPropFilterBag
) IPropertyBag_Release(pPropFilterBag
);
1550 static HRESULT
build_directshowfilters_tree(IDxDiagContainerImpl_Container
*node
)
1552 static const WCHAR szCatName
[] = {'s','z','C','a','t','N','a','m','e',0};
1553 static const WCHAR ClsidCatW
[] = {'C','l','s','i','d','C','a','t',0};
1554 static const WCHAR szIdFormat
[] = {'%','d',0};
1558 ICreateDevEnum
*pCreateDevEnum
;
1559 IEnumMoniker
*pEmCat
= NULL
;
1560 IMoniker
*pMCat
= NULL
;
1561 IEnumMoniker
*pEnum
= NULL
;
1563 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC_SERVER
,
1564 &IID_ICreateDevEnum
, (void **)&pCreateDevEnum
);
1568 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEmCat
, 0);
1572 while (IEnumMoniker_Next(pEmCat
, 1, &pMCat
, NULL
) == S_OK
)
1576 IPropertyBag
*pPropBag
;
1578 IMoniker
*pMoniker
= NULL
;
1580 hr
= IMoniker_BindToStorage(pMCat
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropBag
);
1583 IMoniker_Release(pMCat
);
1587 hr
= read_property_names(pPropBag
, &vCatName
, &vCatClsid
);
1588 IPropertyBag_Release(pPropBag
);
1591 IMoniker_Release(pMCat
);
1595 hr
= CLSIDFromString(V_BSTR(&vCatClsid
), &clsidCat
);
1598 IMoniker_Release(pMCat
);
1599 VariantClear(&vCatClsid
);
1600 VariantClear(&vCatName
);
1604 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
1607 IMoniker_Release(pMCat
);
1608 VariantClear(&vCatClsid
);
1609 VariantClear(&vCatName
);
1613 TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat
));
1615 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
1618 IDxDiagContainerImpl_Container
*subcont
;
1620 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szIdFormat
, i
);
1621 subcont
= allocate_information_node(bufferW
);
1625 IMoniker_Release(pMoniker
);
1629 hr
= add_bstr_property(subcont
, szCatName
, V_BSTR(&vCatName
));
1632 free_information_tree(subcont
);
1633 IMoniker_Release(pMoniker
);
1637 hr
= add_bstr_property(subcont
, ClsidCatW
, V_BSTR(&vCatClsid
));
1640 free_information_tree(subcont
);
1641 IMoniker_Release(pMoniker
);
1645 hr
= fill_filter_container(subcont
, pMoniker
);
1646 IMoniker_Release(pMoniker
);
1649 WARN("Skipping invalid filter\n");
1650 free_information_tree(subcont
);
1655 add_subcontainer(node
, subcont
);
1659 IEnumMoniker_Release(pEnum
);
1660 IMoniker_Release(pMCat
);
1661 VariantClear(&vCatClsid
);
1662 VariantClear(&vCatName
);
1669 if (pEmCat
) IEnumMoniker_Release(pEmCat
);
1670 ICreateDevEnum_Release(pCreateDevEnum
);
1674 static HRESULT
build_logicaldisks_tree(IDxDiagContainerImpl_Container
*node
)
1679 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
)
1681 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
1682 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};
1683 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
1684 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
1685 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
1686 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
1687 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};
1688 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
1689 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};
1690 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
1695 HRESULT (*initfunc
)(IDxDiagContainerImpl_Container
*);
1698 {DxDiag_SystemInfo
, build_systeminfo_tree
},
1699 {DxDiag_DisplayDevices
, build_displaydevices_tree
},
1700 {DxDiag_DirectSound
, build_directsound_tree
},
1701 {DxDiag_DirectMusic
, build_directmusic_tree
},
1702 {DxDiag_DirectInput
, build_directinput_tree
},
1703 {DxDiag_DirectPlay
, build_directplay_tree
},
1704 {DxDiag_SystemDevices
, build_systemdevices_tree
},
1705 {DxDiag_DirectXFiles
, build_directxfiles_tree
},
1706 {DxDiag_DirectShowFilters
, build_directshowfilters_tree
},
1707 {DxDiag_LogicalDisks
, build_logicaldisks_tree
},
1710 IDxDiagContainerImpl_Container
*info_root
;
1713 info_root
= allocate_information_node(NULL
);
1715 return E_OUTOFMEMORY
;
1717 for (index
= 0; index
< sizeof(root_children
)/sizeof(root_children
[0]); index
++)
1719 IDxDiagContainerImpl_Container
*node
;
1722 node
= allocate_information_node(root_children
[index
].name
);
1725 free_information_tree(info_root
);
1726 return E_OUTOFMEMORY
;
1729 hr
= root_children
[index
].initfunc(node
);
1732 free_information_tree(node
);
1733 free_information_tree(info_root
);
1737 add_subcontainer(info_root
, node
);
1740 *pinfo_root
= info_root
;