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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
28 #include "dxdiag_private.h"
29 #include "wine/unicode.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag
);
47 static const WCHAR szEmpty
[] = {0};
49 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
);
50 static void free_information_tree(IDxDiagContainerImpl_Container
*node
);
52 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
53 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
54 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
55 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
56 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
57 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
58 static const WCHAR szDeviceIdentifier
[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
59 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
60 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
61 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
62 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};
63 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};
64 static const WCHAR szDriverName
[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0};
65 static const WCHAR szDriverVersion
[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0};
66 static const WCHAR szSubSysId
[] = {'s','z','S','u','b','S','y','s','I','d',0};
67 static const WCHAR szRevisionId
[] = {'s','z','R','e','v','i','s','i','o','n','I','d',0};
68 static const WCHAR dwRefreshRate
[] = {'d','w','R','e','f','r','e','s','h','R','a','t','e',0};
69 static const WCHAR szManufacturer
[] = {'s','z','M','a','n','u','f','a','c','t','u','r','e','r',0};
71 struct IDxDiagProviderImpl
73 IDxDiagProvider IDxDiagProvider_iface
;
76 DXDIAG_INIT_PARAMS params
;
77 IDxDiagContainerImpl_Container
*info_root
;
80 static inline IDxDiagProviderImpl
*impl_from_IDxDiagProvider(IDxDiagProvider
*iface
)
82 return CONTAINING_RECORD(iface
, IDxDiagProviderImpl
, IDxDiagProvider_iface
);
85 /* IDxDiagProvider IUnknown parts follow: */
86 static HRESULT WINAPI
IDxDiagProviderImpl_QueryInterface(IDxDiagProvider
*iface
, REFIID riid
,
89 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
91 if (!ppobj
) return E_INVALIDARG
;
93 if (IsEqualGUID(riid
, &IID_IUnknown
)
94 || IsEqualGUID(riid
, &IID_IDxDiagProvider
)) {
95 IUnknown_AddRef(iface
);
100 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
102 return E_NOINTERFACE
;
105 static ULONG WINAPI
IDxDiagProviderImpl_AddRef(IDxDiagProvider
*iface
)
107 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
108 ULONG refCount
= InterlockedIncrement(&This
->ref
);
110 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
112 DXDIAGN_LockModule();
117 static ULONG WINAPI
IDxDiagProviderImpl_Release(IDxDiagProvider
*iface
)
119 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
120 ULONG refCount
= InterlockedDecrement(&This
->ref
);
122 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
125 free_information_tree(This
->info_root
);
126 HeapFree(GetProcessHeap(), 0, This
);
129 DXDIAGN_UnlockModule();
134 /* IDxDiagProvider Interface follow: */
135 static HRESULT WINAPI
IDxDiagProviderImpl_Initialize(IDxDiagProvider
*iface
,
136 DXDIAG_INIT_PARAMS
*pParams
)
138 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
141 TRACE("(%p,%p)\n", iface
, pParams
);
143 if (NULL
== pParams
) {
146 if (pParams
->dwSize
!= sizeof(DXDIAG_INIT_PARAMS
) ||
147 pParams
->dwDxDiagHeaderVersion
!= DXDIAG_DX9_SDK_VERSION
) {
151 if (!This
->info_root
)
153 hr
= build_information_tree(&This
->info_root
);
159 memcpy(&This
->params
, pParams
, pParams
->dwSize
);
163 static HRESULT WINAPI
IDxDiagProviderImpl_GetRootContainer(IDxDiagProvider
*iface
,
164 IDxDiagContainer
**ppInstance
)
166 IDxDiagProviderImpl
*This
= impl_from_IDxDiagProvider(iface
);
168 TRACE("(%p,%p)\n", iface
, ppInstance
);
170 if (FALSE
== This
->init
) {
171 return CO_E_NOTINITIALIZED
;
174 return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, This
->info_root
,
175 &This
->IDxDiagProvider_iface
, (void **)ppInstance
);
178 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl
=
180 IDxDiagProviderImpl_QueryInterface
,
181 IDxDiagProviderImpl_AddRef
,
182 IDxDiagProviderImpl_Release
,
183 IDxDiagProviderImpl_Initialize
,
184 IDxDiagProviderImpl_GetRootContainer
187 HRESULT
DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
) {
188 IDxDiagProviderImpl
* provider
;
190 TRACE("(%p, %s, %p)\n", punkOuter
, debugstr_guid(riid
), ppobj
);
193 if (punkOuter
) return CLASS_E_NOAGGREGATION
;
195 provider
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagProviderImpl
));
196 if (NULL
== provider
) return E_OUTOFMEMORY
;
197 provider
->IDxDiagProvider_iface
.lpVtbl
= &DxDiagProvider_Vtbl
;
198 provider
->ref
= 0; /* will be inited with QueryInterface */
199 return IDxDiagProviderImpl_QueryInterface(&provider
->IDxDiagProvider_iface
, riid
, ppobj
);
202 static void free_property_information(IDxDiagContainerImpl_Property
*prop
)
204 VariantClear(&prop
->vProp
);
205 HeapFree(GetProcessHeap(), 0, prop
->propName
);
206 HeapFree(GetProcessHeap(), 0, prop
);
209 static void free_information_tree(IDxDiagContainerImpl_Container
*node
)
211 IDxDiagContainerImpl_Container
*ptr
, *cursor2
;
216 HeapFree(GetProcessHeap(), 0, node
->contName
);
218 LIST_FOR_EACH_ENTRY_SAFE(ptr
, cursor2
, &node
->subContainers
, IDxDiagContainerImpl_Container
, entry
)
220 IDxDiagContainerImpl_Property
*prop
, *prop_cursor2
;
222 LIST_FOR_EACH_ENTRY_SAFE(prop
, prop_cursor2
, &ptr
->properties
, IDxDiagContainerImpl_Property
, entry
)
224 list_remove(&prop
->entry
);
225 free_property_information(prop
);
228 list_remove(&ptr
->entry
);
229 free_information_tree(ptr
);
232 HeapFree(GetProcessHeap(), 0, node
);
235 static IDxDiagContainerImpl_Container
*allocate_information_node(const WCHAR
*name
)
237 IDxDiagContainerImpl_Container
*ret
;
239 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
245 ret
->contName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
248 HeapFree(GetProcessHeap(), 0, ret
);
251 strcpyW(ret
->contName
, name
);
254 list_init(&ret
->subContainers
);
255 list_init(&ret
->properties
);
260 static IDxDiagContainerImpl_Property
*allocate_property_information(const WCHAR
*name
)
262 IDxDiagContainerImpl_Property
*ret
;
264 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
268 ret
->propName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
271 HeapFree(GetProcessHeap(), 0, ret
);
274 strcpyW(ret
->propName
, name
);
279 static inline void add_subcontainer(IDxDiagContainerImpl_Container
*node
, IDxDiagContainerImpl_Container
*subCont
)
281 list_add_tail(&node
->subContainers
, &subCont
->entry
);
282 ++node
->nSubContainers
;
285 static inline HRESULT
add_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, const WCHAR
*str
)
287 IDxDiagContainerImpl_Property
*prop
;
290 prop
= allocate_property_information(propName
);
292 return E_OUTOFMEMORY
;
294 bstr
= SysAllocString(str
);
297 free_property_information(prop
);
298 return E_OUTOFMEMORY
;
301 V_VT(&prop
->vProp
) = VT_BSTR
;
302 V_BSTR(&prop
->vProp
) = bstr
;
304 list_add_tail(&node
->properties
, &prop
->entry
);
310 static inline HRESULT
add_ui4_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, DWORD data
)
312 IDxDiagContainerImpl_Property
*prop
;
314 prop
= allocate_property_information(propName
);
316 return E_OUTOFMEMORY
;
318 V_VT(&prop
->vProp
) = VT_UI4
;
319 V_UI4(&prop
->vProp
) = data
;
321 list_add_tail(&node
->properties
, &prop
->entry
);
327 static inline HRESULT
add_bool_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, BOOL data
)
329 IDxDiagContainerImpl_Property
*prop
;
331 prop
= allocate_property_information(propName
);
333 return E_OUTOFMEMORY
;
335 V_VT(&prop
->vProp
) = VT_BOOL
;
336 V_BOOL(&prop
->vProp
) = data
;
338 list_add_tail(&node
->properties
, &prop
->entry
);
344 static inline HRESULT
add_ull_as_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, ULONGLONG data
)
346 IDxDiagContainerImpl_Property
*prop
;
348 prop
= allocate_property_information(propName
);
350 return E_OUTOFMEMORY
;
352 V_VT(&prop
->vProp
) = VT_UI8
;
353 V_UI8(&prop
->vProp
) = data
;
355 VariantChangeType(&prop
->vProp
, &prop
->vProp
, 0, VT_BSTR
);
357 list_add_tail(&node
->properties
, &prop
->entry
);
363 /* Copied from programs/taskkill/taskkill.c. */
364 static DWORD
*enumerate_processes(DWORD
*list_count
)
366 DWORD
*pid_list
, alloc_bytes
= 1024 * sizeof(*pid_list
), needed_bytes
;
368 pid_list
= HeapAlloc(GetProcessHeap(), 0, alloc_bytes
);
376 if (!EnumProcesses(pid_list
, alloc_bytes
, &needed_bytes
))
378 HeapFree(GetProcessHeap(), 0, pid_list
);
382 /* EnumProcesses can't signal an insufficient buffer condition, so the
383 * only way to possibly determine whether a larger buffer is required
384 * is to see whether the written number of bytes is the same as the
385 * buffer size. If so, the buffer will be reallocated to twice the
387 if (alloc_bytes
!= needed_bytes
)
391 realloc_list
= HeapReAlloc(GetProcessHeap(), 0, pid_list
, alloc_bytes
);
394 HeapFree(GetProcessHeap(), 0, pid_list
);
397 pid_list
= realloc_list
;
400 *list_count
= needed_bytes
/ sizeof(*pid_list
);
404 /* Copied from programs/taskkill/taskkill.c. */
405 static BOOL
get_process_name_from_pid(DWORD pid
, WCHAR
*buf
, DWORD chars
)
411 process
= OpenProcess(PROCESS_QUERY_INFORMATION
| PROCESS_VM_READ
, FALSE
, pid
);
415 if (!EnumProcessModules(process
, &module
, sizeof(module
), &required_size
))
417 CloseHandle(process
);
421 if (!GetModuleBaseNameW(process
, module
, buf
, chars
))
423 CloseHandle(process
);
427 CloseHandle(process
);
431 /* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
432 static BOOL
is_netmeeting_running(void)
434 static const WCHAR conf_exe
[] = {'c','o','n','f','.','e','x','e',0};
437 DWORD
*pid_list
= enumerate_processes(&list_count
);
442 WCHAR process_name
[MAX_PATH
];
444 for (i
= 0; i
< list_count
; i
++)
446 if (get_process_name_from_pid(pid_list
[i
], process_name
, sizeof(process_name
)/sizeof(WCHAR
)) &&
447 !lstrcmpW(conf_exe
, process_name
))
449 HeapFree(GetProcessHeap(), 0, pid_list
);
453 HeapFree(GetProcessHeap(), 0, pid_list
);
459 static HRESULT
fill_language_information(IDxDiagContainerImpl_Container
*node
)
461 static const WCHAR regional_setting_engW
[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
462 static const WCHAR languages_fmtW
[] = {'%','s',' ','(','%','s',':',' ','%','s',')',0};
463 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};
464 static const WCHAR szLanguagesEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
466 WCHAR system_lang
[80], regional_setting
[100], user_lang
[80], language_str
[300];
469 /* szLanguagesLocalized */
470 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SNATIVELANGNAME
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
471 LoadStringW(dxdiagn_instance
, IDS_REGIONAL_SETTING
, regional_setting
, sizeof(regional_setting
)/sizeof(WCHAR
));
472 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SNATIVELANGNAME
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
474 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting
, user_lang
);
476 hr
= add_bstr_property(node
, szLanguagesLocalized
, language_str
);
480 /* szLanguagesEnglish */
481 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SENGLANGUAGE
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
482 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SENGLANGUAGE
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
484 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting_engW
, user_lang
);
486 hr
= add_bstr_property(node
, szLanguagesEnglish
, language_str
);
493 static HRESULT
fill_datetime_information(IDxDiagContainerImpl_Container
*node
)
495 static const WCHAR date_fmtW
[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0};
496 static const WCHAR time_fmtW
[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
497 static const WCHAR datetime_fmtW
[] = {'%','s',',',' ','%','s',0};
498 static const WCHAR szTimeLocalized
[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
499 static const WCHAR szTimeEnglish
[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
502 WCHAR date_str
[80], time_str
[80], datetime_str
[200];
505 GetLocalTime(&curtime
);
507 GetTimeFormatW(LOCALE_NEUTRAL
, 0, &curtime
, time_fmtW
, time_str
, sizeof(time_str
)/sizeof(WCHAR
));
509 /* szTimeLocalized */
510 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_LONGDATE
, &curtime
, NULL
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
512 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
514 hr
= add_bstr_property(node
, szTimeLocalized
, datetime_str
);
519 GetDateFormatW(LOCALE_NEUTRAL
, 0, &curtime
, date_fmtW
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
521 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
523 hr
= add_bstr_property(node
, szTimeEnglish
, datetime_str
);
530 static HRESULT
fill_os_string_information(IDxDiagContainerImpl_Container
*node
, OSVERSIONINFOW
*info
)
532 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};
533 static const WCHAR szOSLocalized
[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
534 static const WCHAR szOSExLocalized
[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
535 static const WCHAR szOSExLongLocalized
[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
536 static const WCHAR szOSEnglish
[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
537 static const WCHAR szOSExEnglish
[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
538 static const WCHAR szOSExLongEnglish
[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
540 static const WCHAR
*prop_list
[] = {szOSLocalized
, szOSExLocalized
, szOSExLongLocalized
,
541 szOSEnglish
, szOSExEnglish
, szOSExLongEnglish
};
546 /* FIXME: OS detection should be performed, and localized OS strings
547 * should contain translated versions of the "build" phrase. */
548 for (i
= 0; i
< sizeof(prop_list
)/sizeof(prop_list
[0]); i
++)
550 hr
= add_bstr_property(node
, prop_list
[i
], winxpW
);
558 static HRESULT
fill_processor_information(IDxDiagContainerImpl_Container
*node
)
560 static const WCHAR szProcessorEnglish
[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
562 static const WCHAR cimv2W
[] = {'\\','\\','.','\\','r','o','o','t','\\','c','i','m','v','2',0};
563 static const WCHAR proc_classW
[] = {'W','i','n','3','2','_','P','r','o','c','e','s','s','o','r',0};
564 static const WCHAR nameW
[] = {'N','a','m','e',0};
565 static const WCHAR max_clock_speedW
[] = {'M','a','x','C','l','o','c','k','S','p','e','e','d',0};
566 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};
568 static const WCHAR processor_fmtW
[] = {'%','s','(','%','d',' ','C','P','U','s',')',',',' ','~','%','d','M','H','z',0};
570 IWbemLocator
*wbem_locator
;
571 IWbemServices
*wbem_service
;
572 IWbemClassObject
*wbem_class
;
573 IEnumWbemClassObject
*wbem_enum
;
574 VARIANT cpu_name
, cpu_no
, clock_speed
;
575 WCHAR print_buf
[200];
580 hr
= CoCreateInstance(&CLSID_WbemLocator
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWbemLocator
, (void**)&wbem_locator
);
584 bstr
= SysAllocString(cimv2W
);
586 IWbemLocator_Release(wbem_locator
);
587 return E_OUTOFMEMORY
;
589 hr
= IWbemLocator_ConnectServer(wbem_locator
, bstr
, NULL
, NULL
, NULL
, 0, NULL
, NULL
, &wbem_service
);
590 IWbemLocator_Release(wbem_locator
);
595 bstr
= SysAllocString(proc_classW
);
597 IWbemServices_Release(wbem_service
);
598 return E_OUTOFMEMORY
;
600 hr
= IWbemServices_CreateInstanceEnum(wbem_service
, bstr
, WBEM_FLAG_SYSTEM_ONLY
, NULL
, &wbem_enum
);
601 IWbemServices_Release(wbem_service
);
606 hr
= IEnumWbemClassObject_Next(wbem_enum
, 1000, 1, &wbem_class
, &no
);
607 IEnumWbemClassObject_Release(wbem_enum
);
611 hr
= IWbemClassObject_Get(wbem_class
, cpu_noW
, 0, &cpu_no
, NULL
, NULL
);
613 IWbemClassObject_Release(wbem_class
);
616 hr
= IWbemClassObject_Get(wbem_class
, max_clock_speedW
, 0, &clock_speed
, NULL
, NULL
);
618 IWbemClassObject_Release(wbem_class
);
621 hr
= IWbemClassObject_Get(wbem_class
, nameW
, 0, &cpu_name
, NULL
, NULL
);
622 IWbemClassObject_Release(wbem_class
);
626 sprintfW(print_buf
, processor_fmtW
, V_BSTR(&cpu_name
), V_I4(&cpu_no
), V_I4(&clock_speed
));
627 VariantClear(&cpu_name
);
628 VariantClear(&cpu_no
);
629 VariantClear(&clock_speed
);
631 return add_bstr_property(node
, szProcessorEnglish
, print_buf
);
634 static HRESULT
build_systeminfo_tree(IDxDiagContainerImpl_Container
*node
)
636 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};
637 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};
638 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};
639 static const WCHAR szDirectXVersionLetter_v
[] = {'c',0};
640 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
641 static const WCHAR bNECPC98
[] = {'b','N','E','C','P','C','9','8',0};
642 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};
643 static const WCHAR szDirectXVersionEnglish_v
[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
644 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};
645 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};
646 static const WCHAR ullPhysicalMemory
[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
647 static const WCHAR ullUsedPageFile
[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
648 static const WCHAR ullAvailPageFile
[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
649 static const WCHAR bNetMeetingRunning
[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
650 static const WCHAR szWindowsDir
[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
651 static const WCHAR dwOSMajorVersion
[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
652 static const WCHAR dwOSMinorVersion
[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
653 static const WCHAR dwOSBuildNumber
[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
654 static const WCHAR dwOSPlatformID
[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
655 static const WCHAR szCSDVersion
[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
656 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};
657 static const WCHAR szPageFileLocalized
[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
658 static const WCHAR szPageFileEnglish
[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
659 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};
660 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};
661 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};
662 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};
663 static const WCHAR szBIOSEnglish
[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
664 static const WCHAR szSetupParamEnglish
[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
665 static const WCHAR szDxDiagVersion
[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
667 static const WCHAR notpresentW
[] = {'N','o','t',' ','p','r','e','s','e','n','t',0};
669 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};
670 static const WCHAR physmem_fmtW
[] = {'%','u','M','B',' ','R','A','M',0};
675 DWORD count
, usedpage_mb
, availpage_mb
;
676 WCHAR buffer
[MAX_PATH
], computer_name
[MAX_COMPUTERNAME_LENGTH
+ 1], print_buf
[200], localized_pagefile_fmt
[200];
679 hr
= add_ui4_property(node
, dwDirectXVersionMajor
, 9);
683 hr
= add_ui4_property(node
, dwDirectXVersionMinor
, 0);
687 hr
= add_bstr_property(node
, szDirectXVersionLetter
, szDirectXVersionLetter_v
);
691 hr
= add_bstr_property(node
, szDirectXVersionEnglish
, szDirectXVersionEnglish_v
);
695 hr
= add_bstr_property(node
, szDirectXVersionLongEnglish
, szDirectXVersionLongEnglish_v
);
699 hr
= add_bool_property(node
, bDebug
, FALSE
);
703 hr
= add_bool_property(node
, bNECPC98
, FALSE
);
707 msex
.dwLength
= sizeof(msex
);
708 GlobalMemoryStatusEx(&msex
);
710 hr
= add_ull_as_bstr_property(node
, ullPhysicalMemory
, msex
.ullTotalPhys
);
714 hr
= add_ull_as_bstr_property(node
, ullUsedPageFile
, msex
.ullTotalPageFile
- msex
.ullAvailPageFile
);
718 hr
= add_ull_as_bstr_property(node
, ullAvailPageFile
, msex
.ullAvailPageFile
);
722 hr
= add_bool_property(node
, bNetMeetingRunning
, is_netmeeting_running());
726 info
.dwOSVersionInfoSize
= sizeof(info
);
727 GetVersionExW(&info
);
729 hr
= add_ui4_property(node
, dwOSMajorVersion
, info
.dwMajorVersion
);
733 hr
= add_ui4_property(node
, dwOSMinorVersion
, info
.dwMinorVersion
);
737 hr
= add_ui4_property(node
, dwOSBuildNumber
, info
.dwBuildNumber
);
741 hr
= add_ui4_property(node
, dwOSPlatformID
, info
.dwPlatformId
);
745 hr
= add_bstr_property(node
, szCSDVersion
, info
.szCSDVersion
);
749 /* FIXME: Roundoff should not be done with truncated division. */
750 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), physmem_fmtW
, (DWORD
)(msex
.ullTotalPhys
/ (1024 * 1024)));
751 hr
= add_bstr_property(node
, szPhysicalMemoryEnglish
, print_buf
);
755 usedpage_mb
= (DWORD
)((msex
.ullTotalPageFile
- msex
.ullAvailPageFile
) / (1024 * 1024));
756 availpage_mb
= (DWORD
)(msex
.ullAvailPageFile
/ (1024 * 1024));
757 LoadStringW(dxdiagn_instance
, IDS_PAGE_FILE_FORMAT
, localized_pagefile_fmt
, sizeof(localized_pagefile_fmt
)/sizeof(WCHAR
));
758 args
[0] = usedpage_mb
;
759 args
[1] = availpage_mb
;
760 FormatMessageW(FORMAT_MESSAGE_FROM_STRING
|FORMAT_MESSAGE_ARGUMENT_ARRAY
,
761 localized_pagefile_fmt
, 0, 0, print_buf
,
762 sizeof(print_buf
)/sizeof(*print_buf
), (__ms_va_list
*)args
);
764 hr
= add_bstr_property(node
, szPageFileLocalized
, print_buf
);
768 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), pagefile_fmtW
, usedpage_mb
, availpage_mb
);
770 hr
= add_bstr_property(node
, szPageFileEnglish
, print_buf
);
774 GetWindowsDirectoryW(buffer
, MAX_PATH
);
776 hr
= add_bstr_property(node
, szWindowsDir
, buffer
);
780 count
= sizeof(computer_name
)/sizeof(WCHAR
);
781 if (!GetComputerNameW(computer_name
, &count
))
784 hr
= add_bstr_property(node
, szMachineNameLocalized
, computer_name
);
788 hr
= add_bstr_property(node
, szMachineNameEnglish
, computer_name
);
792 hr
= add_bstr_property(node
, szSystemManufacturerEnglish
, szEmpty
);
796 hr
= add_bstr_property(node
, szSystemModelEnglish
, szEmpty
);
800 hr
= add_bstr_property(node
, szBIOSEnglish
, szEmpty
);
804 hr
= fill_processor_information(node
);
808 hr
= add_bstr_property(node
, szSetupParamEnglish
, notpresentW
);
812 hr
= add_bstr_property(node
, szDxDiagVersion
, szEmpty
);
816 hr
= fill_language_information(node
);
820 hr
= fill_datetime_information(node
);
824 hr
= fill_os_string_information(node
, &info
);
831 /* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
832 static DWORD
depth_for_pixelformat(D3DFORMAT format
)
836 case D3DFMT_P8
: return 8;
837 case D3DFMT_X1R5G5B5
: return 15;
838 case D3DFMT_R5G6B5
: return 16;
839 /* This case will fail to distinguish an original bpp of 24. */
840 case D3DFMT_X8R8G8B8
: return 32;
842 FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format
);
847 static BOOL
get_texture_memory(GUID
*adapter
, DWORD
*available_mem
)
849 IDirectDraw7
*pDirectDraw
;
853 hr
= DirectDrawCreateEx(adapter
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
856 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
857 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.dwCaps4
= 0;
858 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, available_mem
, NULL
);
859 IDirectDraw7_Release(pDirectDraw
);
867 static const WCHAR
*vendor_id_to_manufacturer_string(DWORD vendor_id
)
869 static const WCHAR atiW
[] = {'A','T','I',' ','T','e','c','h','n','o','l','o','g','i','e','s',' ','I','n','c','.',0};
870 static const WCHAR nvidiaW
[] = {'N','V','I','D','I','A',0};
871 static const WCHAR intelW
[] = {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
872 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
874 /* Enumeration copied from dlls/wined3d/wined3d_private.h and slightly modified. */
877 HW_VENDOR_AMD
= 0x1002,
878 HW_VENDOR_NVIDIA
= 0x10de,
879 HW_VENDOR_INTEL
= 0x8086,
886 case HW_VENDOR_NVIDIA
:
888 case HW_VENDOR_INTEL
:
891 FIXME("Unknown PCI vendor ID 0x%04x\n", vendor_id
);
896 static HRESULT
fill_display_information_d3d(IDxDiagContainerImpl_Container
*node
)
898 IDxDiagContainerImpl_Container
*display_adapter
;
900 IDirect3D9
*pDirect3D9
;
904 pDirect3D9
= Direct3DCreate9(D3D_SDK_VERSION
);
908 count
= IDirect3D9_GetAdapterCount(pDirect3D9
);
909 for (index
= 0; index
< count
; index
++)
911 static const WCHAR adapterid_fmtW
[] = {'%','u',0};
912 static const WCHAR driverversion_fmtW
[] = {'%','u','.','%','u','.','%','0','4','u','.','%','0','4','u',0};
913 static const WCHAR id_fmtW
[] = {'0','x','%','0','4','x',0};
914 static const WCHAR subsysid_fmtW
[] = {'0','x','%','0','8','x',0};
915 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
917 D3DADAPTER_IDENTIFIER9 adapter_info
;
918 D3DDISPLAYMODE adapter_mode
;
919 DWORD available_mem
= 0;
921 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), adapterid_fmtW
, index
);
922 display_adapter
= allocate_information_node(buffer
);
923 if (!display_adapter
)
929 add_subcontainer(node
, display_adapter
);
931 hr
= IDirect3D9_GetAdapterIdentifier(pDirect3D9
, index
, 0, &adapter_info
);
934 WCHAR driverW
[sizeof(adapter_info
.Driver
)];
935 WCHAR descriptionW
[sizeof(adapter_info
.Description
)];
936 WCHAR devicenameW
[sizeof(adapter_info
.DeviceName
)];
938 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Driver
, -1, driverW
, sizeof(driverW
)/sizeof(WCHAR
));
939 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Description
, -1, descriptionW
, sizeof(descriptionW
)/sizeof(WCHAR
));
940 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.DeviceName
, -1, devicenameW
, sizeof(devicenameW
)/sizeof(WCHAR
));
942 hr
= add_bstr_property(display_adapter
, szDriverName
, driverW
);
946 hr
= add_bstr_property(display_adapter
, szDescription
, descriptionW
);
950 hr
= add_bstr_property(display_adapter
, szDeviceName
, devicenameW
);
954 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), driverversion_fmtW
,
955 HIWORD(adapter_info
.DriverVersion
.u
.HighPart
), LOWORD(adapter_info
.DriverVersion
.u
.HighPart
),
956 HIWORD(adapter_info
.DriverVersion
.u
.LowPart
), LOWORD(adapter_info
.DriverVersion
.u
.LowPart
));
958 hr
= add_bstr_property(display_adapter
, szDriverVersion
, buffer
);
962 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.VendorId
);
963 hr
= add_bstr_property(display_adapter
, szVendorId
, buffer
);
967 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.DeviceId
);
968 hr
= add_bstr_property(display_adapter
, szDeviceId
, buffer
);
972 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), subsysid_fmtW
, adapter_info
.SubSysId
);
973 hr
= add_bstr_property(display_adapter
, szSubSysId
, buffer
);
977 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.Revision
);
978 hr
= add_bstr_property(display_adapter
, szRevisionId
, buffer
);
982 StringFromGUID2(&adapter_info
.DeviceIdentifier
, buffer
, 39);
983 hr
= add_bstr_property(display_adapter
, szDeviceIdentifier
, buffer
);
987 hr
= add_bstr_property(display_adapter
, szManufacturer
, vendor_id_to_manufacturer_string(adapter_info
.VendorId
));
992 hr
= IDirect3D9_GetAdapterDisplayMode(pDirect3D9
, index
, &adapter_mode
);
995 hr
= add_ui4_property(display_adapter
, dwWidth
, adapter_mode
.Width
);
999 hr
= add_ui4_property(display_adapter
, dwHeight
, adapter_mode
.Height
);
1003 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, adapter_mode
.RefreshRate
);
1007 hr
= add_ui4_property(display_adapter
, dwBpp
, depth_for_pixelformat(adapter_mode
.Format
));
1012 hr
= add_bstr_property(display_adapter
, szKeyDeviceKey
, szEmpty
);
1016 hr
= add_bstr_property(display_adapter
, szKeyDeviceID
, szEmpty
);
1020 if (!get_texture_memory(&adapter_info
.DeviceIdentifier
, &available_mem
))
1021 WARN("get_texture_memory helper failed\n");
1023 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, available_mem
/ 1000000.0f
);
1025 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
1029 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
1036 IDirect3D9_Release(pDirect3D9
);
1040 static HRESULT
fill_display_information_fallback(IDxDiagContainerImpl_Container
*node
)
1042 static const WCHAR szAdapterID
[] = {'0',0};
1043 static const WCHAR
*empty_properties
[] = {szDeviceIdentifier
, szVendorId
, szDeviceId
,
1044 szKeyDeviceKey
, szKeyDeviceID
, szDriverName
,
1045 szDriverVersion
, szSubSysId
, szRevisionId
,
1048 IDxDiagContainerImpl_Container
*display_adapter
;
1050 IDirectDraw7
*pDirectDraw
;
1052 DISPLAY_DEVICEW disp_dev
;
1053 DDSURFACEDESC2 surface_descr
;
1057 display_adapter
= allocate_information_node(szAdapterID
);
1058 if (!display_adapter
)
1059 return E_OUTOFMEMORY
;
1061 add_subcontainer(node
, display_adapter
);
1063 disp_dev
.cb
= sizeof(disp_dev
);
1064 if (EnumDisplayDevicesW( NULL
, 0, &disp_dev
, 0 ))
1066 hr
= add_bstr_property(display_adapter
, szDeviceName
, disp_dev
.DeviceName
);
1070 hr
= add_bstr_property(display_adapter
, szDescription
, disp_dev
.DeviceString
);
1075 /* Silently ignore a failure from DirectDrawCreateEx. */
1076 hr
= DirectDrawCreateEx(NULL
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
1080 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
1081 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.dwCaps4
= 0;
1082 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, &tmp
, NULL
);
1085 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
1087 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, tmp
/ 1000000.0f
);
1089 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
1093 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
1098 surface_descr
.dwSize
= sizeof(surface_descr
);
1099 hr
= IDirectDraw7_GetDisplayMode(pDirectDraw
, &surface_descr
);
1102 if (surface_descr
.dwFlags
& DDSD_WIDTH
)
1104 hr
= add_ui4_property(display_adapter
, dwWidth
, surface_descr
.dwWidth
);
1109 if (surface_descr
.dwFlags
& DDSD_HEIGHT
)
1111 hr
= add_ui4_property(display_adapter
, dwHeight
, surface_descr
.dwHeight
);
1116 if (surface_descr
.dwFlags
& DDSD_PIXELFORMAT
)
1118 hr
= add_ui4_property(display_adapter
, dwBpp
, surface_descr
.u4
.ddpfPixelFormat
.u1
.dwRGBBitCount
);
1124 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, 60);
1128 for (tmp
= 0; tmp
< sizeof(empty_properties
)/sizeof(empty_properties
[0]); tmp
++)
1130 hr
= add_bstr_property(display_adapter
, empty_properties
[tmp
], szEmpty
);
1137 IDirectDraw7_Release(pDirectDraw
);
1141 static HRESULT
build_displaydevices_tree(IDxDiagContainerImpl_Container
*node
)
1145 /* Try to use Direct3D to obtain the required information first. */
1146 hr
= fill_display_information_d3d(node
);
1150 return fill_display_information_fallback(node
);
1153 static HRESULT
build_directsound_tree(IDxDiagContainerImpl_Container
*node
)
1155 static const WCHAR DxDiag_SoundDevices
[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
1156 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};
1158 IDxDiagContainerImpl_Container
*cont
;
1160 cont
= allocate_information_node(DxDiag_SoundDevices
);
1162 return E_OUTOFMEMORY
;
1164 add_subcontainer(node
, cont
);
1166 cont
= allocate_information_node(DxDiag_SoundCaptureDevices
);
1168 return E_OUTOFMEMORY
;
1170 add_subcontainer(node
, cont
);
1175 static HRESULT
build_directmusic_tree(IDxDiagContainerImpl_Container
*node
)
1180 static HRESULT
build_directinput_tree(IDxDiagContainerImpl_Container
*node
)
1185 static HRESULT
build_directplay_tree(IDxDiagContainerImpl_Container
*node
)
1190 static HRESULT
build_systemdevices_tree(IDxDiagContainerImpl_Container
*node
)
1195 static HRESULT
fill_file_description(IDxDiagContainerImpl_Container
*node
, const WCHAR
*szFilePath
, const WCHAR
*szFileName
)
1197 static const WCHAR szSlashSep
[] = {'\\',0};
1198 static const WCHAR szPath
[] = {'s','z','P','a','t','h',0};
1199 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1200 static const WCHAR szVersion
[] = {'s','z','V','e','r','s','i','o','n',0};
1201 static const WCHAR szAttributes
[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
1202 static const WCHAR szLanguageEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
1203 static const WCHAR dwFileTimeHigh
[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
1204 static const WCHAR dwFileTimeLow
[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
1205 static const WCHAR bBeta
[] = {'b','B','e','t','a',0};
1206 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
1207 static const WCHAR bExists
[] = {'b','E','x','i','s','t','s',0};
1210 static const WCHAR szFinal_Retail_v
[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
1211 static const WCHAR szEnglish_v
[] = {'E','n','g','l','i','s','h',0};
1212 static const WCHAR szVersionFormat
[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
1216 WCHAR szVersion_v
[1024];
1218 void *pVersionInfo
= NULL
;
1219 BOOL boolret
= FALSE
;
1221 VS_FIXEDFILEINFO
*pFileInfo
;
1223 TRACE("Filling container %p for %s in %s\n", node
,
1224 debugstr_w(szFileName
), debugstr_w(szFilePath
));
1226 szFile
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * (lstrlenW(szFilePath
) +
1227 lstrlenW(szFileName
) + 2 /* slash + terminator */));
1229 return E_OUTOFMEMORY
;
1231 lstrcpyW(szFile
, szFilePath
);
1232 lstrcatW(szFile
, szSlashSep
);
1233 lstrcatW(szFile
, szFileName
);
1235 retval
= GetFileVersionInfoSizeW(szFile
, &hdl
);
1238 pVersionInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
1245 if (GetFileVersionInfoW(szFile
, 0, retval
, pVersionInfo
) &&
1246 VerQueryValueW(pVersionInfo
, szSlashSep
, (void **)&pFileInfo
, &uiLength
))
1250 hr
= add_bstr_property(node
, szPath
, szFile
);
1254 hr
= add_bstr_property(node
, szName
, szFileName
);
1258 hr
= add_bool_property(node
, bExists
, boolret
);
1264 snprintfW(szVersion_v
, sizeof(szVersion_v
)/sizeof(szVersion_v
[0]),
1266 HIWORD(pFileInfo
->dwFileVersionMS
),
1267 LOWORD(pFileInfo
->dwFileVersionMS
),
1268 HIWORD(pFileInfo
->dwFileVersionLS
),
1269 LOWORD(pFileInfo
->dwFileVersionLS
));
1271 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v
));
1273 hr
= add_bstr_property(node
, szVersion
, szVersion_v
);
1277 hr
= add_bstr_property(node
, szAttributes
, szFinal_Retail_v
);
1281 hr
= add_bstr_property(node
, szLanguageEnglish
, szEnglish_v
);
1285 hr
= add_ui4_property(node
, dwFileTimeHigh
, pFileInfo
->dwFileDateMS
);
1289 hr
= add_ui4_property(node
, dwFileTimeLow
, pFileInfo
->dwFileDateLS
);
1293 hr
= add_bool_property(node
, bBeta
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_PRERELEASE
) != 0);
1297 hr
= add_bool_property(node
, bDebug
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_DEBUG
) != 0);
1304 HeapFree(GetProcessHeap(), 0, pVersionInfo
);
1305 HeapFree(GetProcessHeap(), 0, szFile
);
1309 static HRESULT
build_directxfiles_tree(IDxDiagContainerImpl_Container
*node
)
1311 static const WCHAR dlls
[][15] =
1313 {'d','3','d','8','.','d','l','l',0},
1314 {'d','3','d','9','.','d','l','l',0},
1315 {'d','d','r','a','w','.','d','l','l',0},
1316 {'d','e','v','e','n','u','m','.','d','l','l',0},
1317 {'d','i','n','p','u','t','8','.','d','l','l',0},
1318 {'d','i','n','p','u','t','.','d','l','l',0},
1319 {'d','m','b','a','n','d','.','d','l','l',0},
1320 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
1321 {'d','m','i','m','e','.','d','l','l',0},
1322 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
1323 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
1324 {'d','m','s','t','y','l','e','.','d','l','l',0},
1325 {'d','m','s','y','n','t','h','.','d','l','l',0},
1326 {'d','m','u','s','i','c','.','d','l','l',0},
1327 {'d','p','l','a','y','x','.','d','l','l',0},
1328 {'d','p','n','e','t','.','d','l','l',0},
1329 {'d','s','o','u','n','d','.','d','l','l',0},
1330 {'d','s','w','a','v','e','.','d','l','l',0},
1331 {'d','x','d','i','a','g','n','.','d','l','l',0},
1332 {'q','u','a','r','t','z','.','d','l','l',0}
1336 WCHAR szFilePath
[MAX_PATH
];
1339 GetSystemDirectoryW(szFilePath
, MAX_PATH
);
1341 for (i
= 0; i
< sizeof(dlls
) / sizeof(dlls
[0]); i
++)
1343 static const WCHAR szFormat
[] = {'%','d',0};
1346 IDxDiagContainerImpl_Container
*file_container
;
1348 snprintfW(szFileID
, sizeof(szFileID
)/sizeof(szFileID
[0]), szFormat
, i
);
1350 file_container
= allocate_information_node(szFileID
);
1351 if (!file_container
)
1352 return E_OUTOFMEMORY
;
1354 hr
= fill_file_description(file_container
, szFilePath
, dlls
[i
]);
1357 free_information_tree(file_container
);
1361 add_subcontainer(node
, file_container
);
1367 static HRESULT
read_property_names(IPropertyBag
*pPropBag
, VARIANT
*friendly_name
, VARIANT
*clsid_name
)
1369 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
1370 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
1374 VariantInit(friendly_name
);
1375 VariantInit(clsid_name
);
1377 hr
= IPropertyBag_Read(pPropBag
, wszFriendlyName
, friendly_name
, 0);
1381 hr
= IPropertyBag_Read(pPropBag
, wszClsidName
, clsid_name
, 0);
1384 VariantClear(friendly_name
);
1391 static HRESULT
fill_filter_data_information(IDxDiagContainerImpl_Container
*subcont
, BYTE
*pData
, ULONG cb
)
1393 static const WCHAR szVersionW
[] = {'s','z','V','e','r','s','i','o','n',0};
1394 static const WCHAR dwInputs
[] = {'d','w','I','n','p','u','t','s',0};
1395 static const WCHAR dwOutputs
[] = {'d','w','O','u','t','p','u','t','s',0};
1396 static const WCHAR dwMeritW
[] = {'d','w','M','e','r','i','t',0};
1397 static const WCHAR szVersionFormat
[] = {'v','%','d',0};
1400 IFilterMapper2
*pFileMapper
= NULL
;
1401 IAMFilterData
*pFilterData
= NULL
;
1403 REGFILTER2
*pRF
= NULL
;
1406 DWORD dwNOutputs
= 0;
1407 DWORD dwNInputs
= 0;
1409 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC
, &IID_IFilterMapper2
,
1410 (void **)&pFileMapper
);
1414 hr
= IFilterMapper2_QueryInterface(pFileMapper
, &IID_IAMFilterData
, (void **)&pFilterData
);
1418 hr
= IAMFilterData_ParseFilterData(pFilterData
, pData
, cb
, (BYTE
**)&ppRF
);
1421 pRF
= ((REGFILTER2
**)ppRF
)[0];
1423 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szVersionFormat
, pRF
->dwVersion
);
1424 hr
= add_bstr_property(subcont
, szVersionW
, bufferW
);
1428 if (pRF
->dwVersion
== 1)
1430 for (j
= 0; j
< pRF
->u
.s1
.cPins
; j
++)
1431 if (pRF
->u
.s1
.rgPins
[j
].bOutput
)
1436 else if (pRF
->dwVersion
== 2)
1438 for (j
= 0; j
< pRF
->u
.s2
.cPins2
; j
++)
1439 if (pRF
->u
.s2
.rgPins2
[j
].dwFlags
& REG_PINFLAG_B_OUTPUT
)
1445 hr
= add_ui4_property(subcont
, dwInputs
, dwNInputs
);
1449 hr
= add_ui4_property(subcont
, dwOutputs
, dwNOutputs
);
1453 hr
= add_ui4_property(subcont
, dwMeritW
, pRF
->dwMerit
);
1460 if (pFilterData
) IAMFilterData_Release(pFilterData
);
1461 if (pFileMapper
) IFilterMapper2_Release(pFileMapper
);
1466 static HRESULT
fill_filter_container(IDxDiagContainerImpl_Container
*subcont
, IMoniker
*pMoniker
)
1468 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1469 static const WCHAR ClsidFilterW
[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
1470 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
1473 IPropertyBag
*pPropFilterBag
= NULL
;
1475 VARIANT friendly_name
;
1479 VariantInit(&friendly_name
);
1480 VariantInit(&clsid_name
);
1483 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropFilterBag
);
1487 hr
= read_property_names(pPropFilterBag
, &friendly_name
, &clsid_name
);
1491 TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name
)));
1492 TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name
)));
1494 hr
= add_bstr_property(subcont
, szName
, V_BSTR(&friendly_name
));
1498 hr
= add_bstr_property(subcont
, ClsidFilterW
, V_BSTR(&clsid_name
));
1502 hr
= IPropertyBag_Read(pPropFilterBag
, wszFilterDataName
, &v
, NULL
);
1506 hr
= SafeArrayAccessData(V_ARRAY(&v
), (void **)&pData
);
1510 hr
= fill_filter_data_information(subcont
, pData
, V_ARRAY(&v
)->rgsabound
->cElements
);
1511 SafeArrayUnaccessData(V_ARRAY(&v
));
1518 VariantClear(&clsid_name
);
1519 VariantClear(&friendly_name
);
1520 if (pPropFilterBag
) IPropertyBag_Release(pPropFilterBag
);
1525 static HRESULT
build_directshowfilters_tree(IDxDiagContainerImpl_Container
*node
)
1527 static const WCHAR szCatName
[] = {'s','z','C','a','t','N','a','m','e',0};
1528 static const WCHAR ClsidCatW
[] = {'C','l','s','i','d','C','a','t',0};
1529 static const WCHAR szIdFormat
[] = {'%','d',0};
1533 ICreateDevEnum
*pCreateDevEnum
;
1534 IEnumMoniker
*pEmCat
= NULL
;
1535 IMoniker
*pMCat
= NULL
;
1536 IEnumMoniker
*pEnum
= NULL
;
1538 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC_SERVER
,
1539 &IID_ICreateDevEnum
, (void **)&pCreateDevEnum
);
1543 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEmCat
, 0);
1547 while (IEnumMoniker_Next(pEmCat
, 1, &pMCat
, NULL
) == S_OK
)
1551 IPropertyBag
*pPropBag
;
1553 IMoniker
*pMoniker
= NULL
;
1555 hr
= IMoniker_BindToStorage(pMCat
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropBag
);
1558 IMoniker_Release(pMCat
);
1562 hr
= read_property_names(pPropBag
, &vCatName
, &vCatClsid
);
1563 IPropertyBag_Release(pPropBag
);
1566 IMoniker_Release(pMCat
);
1570 hr
= CLSIDFromString(V_BSTR(&vCatClsid
), &clsidCat
);
1573 IMoniker_Release(pMCat
);
1574 VariantClear(&vCatClsid
);
1575 VariantClear(&vCatName
);
1579 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
1582 IMoniker_Release(pMCat
);
1583 VariantClear(&vCatClsid
);
1584 VariantClear(&vCatName
);
1588 TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat
));
1590 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
1593 IDxDiagContainerImpl_Container
*subcont
;
1595 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szIdFormat
, i
);
1596 subcont
= allocate_information_node(bufferW
);
1600 IMoniker_Release(pMoniker
);
1604 hr
= add_bstr_property(subcont
, szCatName
, V_BSTR(&vCatName
));
1607 free_information_tree(subcont
);
1608 IMoniker_Release(pMoniker
);
1612 hr
= add_bstr_property(subcont
, ClsidCatW
, V_BSTR(&vCatClsid
));
1615 free_information_tree(subcont
);
1616 IMoniker_Release(pMoniker
);
1620 hr
= fill_filter_container(subcont
, pMoniker
);
1623 free_information_tree(subcont
);
1624 IMoniker_Release(pMoniker
);
1628 add_subcontainer(node
, subcont
);
1630 IMoniker_Release(pMoniker
);
1633 IEnumMoniker_Release(pEnum
);
1634 IMoniker_Release(pMCat
);
1635 VariantClear(&vCatClsid
);
1636 VariantClear(&vCatName
);
1643 if (pEmCat
) IEnumMoniker_Release(pEmCat
);
1644 ICreateDevEnum_Release(pCreateDevEnum
);
1648 static HRESULT
build_logicaldisks_tree(IDxDiagContainerImpl_Container
*node
)
1653 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
)
1655 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
1656 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};
1657 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
1658 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
1659 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
1660 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
1661 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};
1662 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
1663 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};
1664 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
1669 HRESULT (*initfunc
)(IDxDiagContainerImpl_Container
*);
1672 {DxDiag_SystemInfo
, build_systeminfo_tree
},
1673 {DxDiag_DisplayDevices
, build_displaydevices_tree
},
1674 {DxDiag_DirectSound
, build_directsound_tree
},
1675 {DxDiag_DirectMusic
, build_directmusic_tree
},
1676 {DxDiag_DirectInput
, build_directinput_tree
},
1677 {DxDiag_DirectPlay
, build_directplay_tree
},
1678 {DxDiag_SystemDevices
, build_systemdevices_tree
},
1679 {DxDiag_DirectXFiles
, build_directxfiles_tree
},
1680 {DxDiag_DirectShowFilters
, build_directshowfilters_tree
},
1681 {DxDiag_LogicalDisks
, build_logicaldisks_tree
},
1684 IDxDiagContainerImpl_Container
*info_root
;
1687 info_root
= allocate_information_node(NULL
);
1689 return E_OUTOFMEMORY
;
1691 for (index
= 0; index
< sizeof(root_children
)/sizeof(root_children
[0]); index
++)
1693 IDxDiagContainerImpl_Container
*node
;
1696 node
= allocate_information_node(root_children
[index
].name
);
1699 free_information_tree(info_root
);
1700 return E_OUTOFMEMORY
;
1703 hr
= root_children
[index
].initfunc(node
);
1706 free_information_tree(node
);
1707 free_information_tree(info_root
);
1711 add_subcontainer(info_root
, node
);
1714 *pinfo_root
= info_root
;