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"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag
);
46 static const WCHAR szEmpty
[] = {0};
48 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
);
49 static void free_information_tree(IDxDiagContainerImpl_Container
*node
);
51 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
52 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
53 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
54 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
55 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
56 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
57 static const WCHAR szDeviceIdentifier
[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
58 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
59 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
60 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
61 static const WCHAR szDisplayMemoryLocalized
[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','L','o','c','a','l','i','z','e','d',0};
62 static const WCHAR szDisplayMemoryEnglish
[] = {'s','z','D','i','s','p','l','a','y','M','e','m','o','r','y','E','n','g','l','i','s','h',0};
63 static const WCHAR szDriverName
[] = {'s','z','D','r','i','v','e','r','N','a','m','e',0};
64 static const WCHAR szDriverVersion
[] = {'s','z','D','r','i','v','e','r','V','e','r','s','i','o','n',0};
65 static const WCHAR szSubSysId
[] = {'s','z','S','u','b','S','y','s','I','d',0};
66 static const WCHAR szRevisionId
[] = {'s','z','R','e','v','i','s','i','o','n','I','d',0};
67 static const WCHAR dwRefreshRate
[] = {'d','w','R','e','f','r','e','s','h','R','a','t','e',0};
68 static const WCHAR szManufacturer
[] = {'s','z','M','a','n','u','f','a','c','t','u','r','e','r',0};
70 /* IDxDiagProvider IUnknown parts follow: */
71 static HRESULT WINAPI
IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface
, REFIID riid
, LPVOID
*ppobj
)
73 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
75 if (!ppobj
) return E_INVALIDARG
;
77 if (IsEqualGUID(riid
, &IID_IUnknown
)
78 || IsEqualGUID(riid
, &IID_IDxDiagProvider
)) {
79 IUnknown_AddRef(iface
);
84 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
89 static ULONG WINAPI
IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface
) {
90 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
91 ULONG refCount
= InterlockedIncrement(&This
->ref
);
93 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
100 static ULONG WINAPI
IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface
) {
101 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
102 ULONG refCount
= InterlockedDecrement(&This
->ref
);
104 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
107 free_information_tree(This
->info_root
);
108 HeapFree(GetProcessHeap(), 0, This
);
111 DXDIAGN_UnlockModule();
116 /* IDxDiagProvider Interface follow: */
117 static HRESULT WINAPI
IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface
, DXDIAG_INIT_PARAMS
* pParams
) {
118 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
121 TRACE("(%p,%p)\n", iface
, pParams
);
123 if (NULL
== pParams
) {
126 if (pParams
->dwSize
!= sizeof(DXDIAG_INIT_PARAMS
) ||
127 pParams
->dwDxDiagHeaderVersion
!= DXDIAG_DX9_SDK_VERSION
) {
131 if (!This
->info_root
)
133 hr
= build_information_tree(&This
->info_root
);
139 memcpy(&This
->params
, pParams
, pParams
->dwSize
);
143 static HRESULT WINAPI
IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface
, IDxDiagContainer
** ppInstance
) {
144 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
146 TRACE("(%p,%p)\n", iface
, ppInstance
);
148 if (FALSE
== This
->init
) {
149 return CO_E_NOTINITIALIZED
;
152 return DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, This
->info_root
,
153 (IDxDiagProvider
*)This
, (void **)ppInstance
);
156 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl
=
158 IDxDiagProviderImpl_QueryInterface
,
159 IDxDiagProviderImpl_AddRef
,
160 IDxDiagProviderImpl_Release
,
161 IDxDiagProviderImpl_Initialize
,
162 IDxDiagProviderImpl_GetRootContainer
165 HRESULT
DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
) {
166 IDxDiagProviderImpl
* provider
;
168 TRACE("(%p, %s, %p)\n", punkOuter
, debugstr_guid(riid
), ppobj
);
171 if (punkOuter
) return CLASS_E_NOAGGREGATION
;
173 provider
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagProviderImpl
));
174 if (NULL
== provider
) return E_OUTOFMEMORY
;
175 provider
->lpVtbl
= &DxDiagProvider_Vtbl
;
176 provider
->ref
= 0; /* will be inited with QueryInterface */
177 return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER
)provider
, riid
, ppobj
);
180 static void free_property_information(IDxDiagContainerImpl_Property
*prop
)
182 VariantClear(&prop
->vProp
);
183 HeapFree(GetProcessHeap(), 0, prop
->propName
);
184 HeapFree(GetProcessHeap(), 0, prop
);
187 static void free_information_tree(IDxDiagContainerImpl_Container
*node
)
189 IDxDiagContainerImpl_Container
*ptr
, *cursor2
;
194 HeapFree(GetProcessHeap(), 0, node
->contName
);
196 LIST_FOR_EACH_ENTRY_SAFE(ptr
, cursor2
, &node
->subContainers
, IDxDiagContainerImpl_Container
, entry
)
198 IDxDiagContainerImpl_Property
*prop
, *prop_cursor2
;
200 LIST_FOR_EACH_ENTRY_SAFE(prop
, prop_cursor2
, &ptr
->properties
, IDxDiagContainerImpl_Property
, entry
)
202 list_remove(&prop
->entry
);
203 free_property_information(prop
);
206 list_remove(&ptr
->entry
);
207 free_information_tree(ptr
);
210 HeapFree(GetProcessHeap(), 0, node
);
213 static IDxDiagContainerImpl_Container
*allocate_information_node(const WCHAR
*name
)
215 IDxDiagContainerImpl_Container
*ret
;
217 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
223 ret
->contName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
226 HeapFree(GetProcessHeap(), 0, ret
);
229 strcpyW(ret
->contName
, name
);
232 list_init(&ret
->subContainers
);
233 list_init(&ret
->properties
);
238 static IDxDiagContainerImpl_Property
*allocate_property_information(const WCHAR
*name
)
240 IDxDiagContainerImpl_Property
*ret
;
242 ret
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*ret
));
246 ret
->propName
= HeapAlloc(GetProcessHeap(), 0, (strlenW(name
) + 1) * sizeof(*name
));
249 HeapFree(GetProcessHeap(), 0, ret
);
252 strcpyW(ret
->propName
, name
);
257 static inline void add_subcontainer(IDxDiagContainerImpl_Container
*node
, IDxDiagContainerImpl_Container
*subCont
)
259 list_add_tail(&node
->subContainers
, &subCont
->entry
);
260 ++node
->nSubContainers
;
263 static inline HRESULT
add_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, const WCHAR
*str
)
265 IDxDiagContainerImpl_Property
*prop
;
268 prop
= allocate_property_information(propName
);
270 return E_OUTOFMEMORY
;
272 bstr
= SysAllocString(str
);
275 free_property_information(prop
);
276 return E_OUTOFMEMORY
;
279 V_VT(&prop
->vProp
) = VT_BSTR
;
280 V_BSTR(&prop
->vProp
) = bstr
;
282 list_add_tail(&node
->properties
, &prop
->entry
);
288 static inline HRESULT
add_ui4_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, DWORD data
)
290 IDxDiagContainerImpl_Property
*prop
;
292 prop
= allocate_property_information(propName
);
294 return E_OUTOFMEMORY
;
296 V_VT(&prop
->vProp
) = VT_UI4
;
297 V_UI4(&prop
->vProp
) = data
;
299 list_add_tail(&node
->properties
, &prop
->entry
);
305 static inline HRESULT
add_bool_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, BOOL data
)
307 IDxDiagContainerImpl_Property
*prop
;
309 prop
= allocate_property_information(propName
);
311 return E_OUTOFMEMORY
;
313 V_VT(&prop
->vProp
) = VT_BOOL
;
314 V_BOOL(&prop
->vProp
) = data
;
316 list_add_tail(&node
->properties
, &prop
->entry
);
322 static inline HRESULT
add_ull_as_bstr_property(IDxDiagContainerImpl_Container
*node
, const WCHAR
*propName
, ULONGLONG data
)
324 IDxDiagContainerImpl_Property
*prop
;
326 prop
= allocate_property_information(propName
);
328 return E_OUTOFMEMORY
;
330 V_VT(&prop
->vProp
) = VT_UI8
;
331 V_UI8(&prop
->vProp
) = data
;
333 VariantChangeType(&prop
->vProp
, &prop
->vProp
, 0, VT_BSTR
);
335 list_add_tail(&node
->properties
, &prop
->entry
);
341 /* Copied from programs/taskkill/taskkill.c. */
342 static DWORD
*enumerate_processes(DWORD
*list_count
)
344 DWORD
*pid_list
, alloc_bytes
= 1024 * sizeof(*pid_list
), needed_bytes
;
346 pid_list
= HeapAlloc(GetProcessHeap(), 0, alloc_bytes
);
354 if (!EnumProcesses(pid_list
, alloc_bytes
, &needed_bytes
))
356 HeapFree(GetProcessHeap(), 0, pid_list
);
360 /* EnumProcesses can't signal an insufficient buffer condition, so the
361 * only way to possibly determine whether a larger buffer is required
362 * is to see whether the written number of bytes is the same as the
363 * buffer size. If so, the buffer will be reallocated to twice the
365 if (alloc_bytes
!= needed_bytes
)
369 realloc_list
= HeapReAlloc(GetProcessHeap(), 0, pid_list
, alloc_bytes
);
372 HeapFree(GetProcessHeap(), 0, pid_list
);
375 pid_list
= realloc_list
;
378 *list_count
= needed_bytes
/ sizeof(*pid_list
);
382 /* Copied from programs/taskkill/taskkill.c. */
383 static BOOL
get_process_name_from_pid(DWORD pid
, WCHAR
*buf
, DWORD chars
)
389 process
= OpenProcess(PROCESS_QUERY_INFORMATION
| PROCESS_VM_READ
, FALSE
, pid
);
393 if (!EnumProcessModules(process
, &module
, sizeof(module
), &required_size
))
395 CloseHandle(process
);
399 if (!GetModuleBaseNameW(process
, module
, buf
, chars
))
401 CloseHandle(process
);
405 CloseHandle(process
);
409 /* dxdiagn's detection scheme is simply to look for a process called conf.exe. */
410 static BOOL
is_netmeeting_running(void)
412 static const WCHAR conf_exe
[] = {'c','o','n','f','.','e','x','e',0};
415 DWORD
*pid_list
= enumerate_processes(&list_count
);
420 WCHAR process_name
[MAX_PATH
];
422 for (i
= 0; i
< list_count
; i
++)
424 if (get_process_name_from_pid(pid_list
[i
], process_name
, sizeof(process_name
)/sizeof(WCHAR
)) &&
425 !lstrcmpW(conf_exe
, process_name
))
427 HeapFree(GetProcessHeap(), 0, pid_list
);
431 HeapFree(GetProcessHeap(), 0, pid_list
);
437 static HRESULT
fill_language_information(IDxDiagContainerImpl_Container
*node
)
439 static const WCHAR regional_setting_engW
[] = {'R','e','g','i','o','n','a','l',' ','S','e','t','t','i','n','g',0};
440 static const WCHAR languages_fmtW
[] = {'%','s',' ','(','%','s',':',' ','%','s',')',0};
441 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};
442 static const WCHAR szLanguagesEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','s','E','n','g','l','i','s','h',0};
444 WCHAR system_lang
[80], regional_setting
[100], user_lang
[80], language_str
[300];
447 /* szLanguagesLocalized */
448 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SNATIVELANGNAME
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
449 LoadStringW(dxdiagn_instance
, IDS_REGIONAL_SETTING
, regional_setting
, sizeof(regional_setting
)/sizeof(WCHAR
));
450 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SNATIVELANGNAME
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
452 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting
, user_lang
);
454 hr
= add_bstr_property(node
, szLanguagesLocalized
, language_str
);
458 /* szLanguagesEnglish */
459 GetLocaleInfoW(LOCALE_SYSTEM_DEFAULT
, LOCALE_SENGLANGUAGE
, system_lang
, sizeof(system_lang
)/sizeof(WCHAR
));
460 GetLocaleInfoW(LOCALE_USER_DEFAULT
, LOCALE_SENGLANGUAGE
, user_lang
, sizeof(user_lang
)/sizeof(WCHAR
));
462 snprintfW(language_str
, sizeof(language_str
)/sizeof(WCHAR
), languages_fmtW
, system_lang
, regional_setting_engW
, user_lang
);
464 hr
= add_bstr_property(node
, szLanguagesEnglish
, language_str
);
471 static HRESULT
fill_datetime_information(IDxDiagContainerImpl_Container
*node
)
473 static const WCHAR date_fmtW
[] = {'M','\'','/','\'','d','\'','/','\'','y','y','y','y',0};
474 static const WCHAR time_fmtW
[] = {'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0};
475 static const WCHAR datetime_fmtW
[] = {'%','s',',',' ','%','s',0};
476 static const WCHAR szTimeLocalized
[] = {'s','z','T','i','m','e','L','o','c','a','l','i','z','e','d',0};
477 static const WCHAR szTimeEnglish
[] = {'s','z','T','i','m','e','E','n','g','l','i','s','h',0};
480 WCHAR date_str
[80], time_str
[80], datetime_str
[200];
483 GetLocalTime(&curtime
);
485 GetTimeFormatW(LOCALE_NEUTRAL
, 0, &curtime
, time_fmtW
, time_str
, sizeof(time_str
)/sizeof(WCHAR
));
487 /* szTimeLocalized */
488 GetDateFormatW(LOCALE_USER_DEFAULT
, DATE_LONGDATE
, &curtime
, NULL
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
490 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
492 hr
= add_bstr_property(node
, szTimeLocalized
, datetime_str
);
497 GetDateFormatW(LOCALE_NEUTRAL
, 0, &curtime
, date_fmtW
, date_str
, sizeof(date_str
)/sizeof(WCHAR
));
499 snprintfW(datetime_str
, sizeof(datetime_str
)/sizeof(WCHAR
), datetime_fmtW
, date_str
, time_str
);
501 hr
= add_bstr_property(node
, szTimeEnglish
, datetime_str
);
508 static HRESULT
fill_os_string_information(IDxDiagContainerImpl_Container
*node
, OSVERSIONINFOW
*info
)
510 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};
511 static const WCHAR szOSLocalized
[] = {'s','z','O','S','L','o','c','a','l','i','z','e','d',0};
512 static const WCHAR szOSExLocalized
[] = {'s','z','O','S','E','x','L','o','c','a','l','i','z','e','d',0};
513 static const WCHAR szOSExLongLocalized
[] = {'s','z','O','S','E','x','L','o','n','g','L','o','c','a','l','i','z','e','d',0};
514 static const WCHAR szOSEnglish
[] = {'s','z','O','S','E','n','g','l','i','s','h',0};
515 static const WCHAR szOSExEnglish
[] = {'s','z','O','S','E','x','E','n','g','l','i','s','h',0};
516 static const WCHAR szOSExLongEnglish
[] = {'s','z','O','S','E','x','L','o','n','g','E','n','g','l','i','s','h',0};
518 static const WCHAR
*prop_list
[] = {szOSLocalized
, szOSExLocalized
, szOSExLongLocalized
,
519 szOSEnglish
, szOSExEnglish
, szOSExLongEnglish
};
524 /* FIXME: OS detection should be performed, and localized OS strings
525 * should contain translated versions of the "build" phrase. */
526 for (i
= 0; i
< sizeof(prop_list
)/sizeof(prop_list
[0]); i
++)
528 hr
= add_bstr_property(node
, prop_list
[i
], winxpW
);
536 static HRESULT
build_systeminfo_tree(IDxDiagContainerImpl_Container
*node
)
538 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};
539 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};
540 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};
541 static const WCHAR szDirectXVersionLetter_v
[] = {'c',0};
542 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
543 static const WCHAR bNECPC98
[] = {'b','N','E','C','P','C','9','8',0};
544 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};
545 static const WCHAR szDirectXVersionEnglish_v
[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
546 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};
547 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};
548 static const WCHAR ullPhysicalMemory
[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
549 static const WCHAR ullUsedPageFile
[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
550 static const WCHAR ullAvailPageFile
[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
551 static const WCHAR bNetMeetingRunning
[] = {'b','N','e','t','M','e','e','t','i','n','g','R','u','n','n','i','n','g',0};
552 static const WCHAR szWindowsDir
[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
553 static const WCHAR dwOSMajorVersion
[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
554 static const WCHAR dwOSMinorVersion
[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
555 static const WCHAR dwOSBuildNumber
[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
556 static const WCHAR dwOSPlatformID
[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
557 static const WCHAR szCSDVersion
[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
558 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};
559 static const WCHAR szPageFileLocalized
[] = {'s','z','P','a','g','e','F','i','l','e','L','o','c','a','l','i','z','e','d',0};
560 static const WCHAR szPageFileEnglish
[] = {'s','z','P','a','g','e','F','i','l','e','E','n','g','l','i','s','h',0};
561 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};
562 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};
563 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};
564 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};
565 static const WCHAR szBIOSEnglish
[] = {'s','z','B','I','O','S','E','n','g','l','i','s','h',0};
566 static const WCHAR szProcessorEnglish
[] = {'s','z','P','r','o','c','e','s','s','o','r','E','n','g','l','i','s','h',0};
567 static const WCHAR szSetupParamEnglish
[] = {'s','z','S','e','t','u','p','P','a','r','a','m','E','n','g','l','i','s','h',0};
568 static const WCHAR szDxDiagVersion
[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};
570 static const WCHAR notpresentW
[] = {'N','o','t',' ','p','r','e','s','e','n','t',0};
572 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};
573 static const WCHAR physmem_fmtW
[] = {'%','u','M','B',' ','R','A','M',0};
578 DWORD count
, usedpage_mb
, availpage_mb
;
579 WCHAR buffer
[MAX_PATH
], computer_name
[MAX_COMPUTERNAME_LENGTH
+ 1], print_buf
[200], localized_pagefile_fmt
[200];
581 hr
= add_ui4_property(node
, dwDirectXVersionMajor
, 9);
585 hr
= add_ui4_property(node
, dwDirectXVersionMinor
, 0);
589 hr
= add_bstr_property(node
, szDirectXVersionLetter
, szDirectXVersionLetter_v
);
593 hr
= add_bstr_property(node
, szDirectXVersionEnglish
, szDirectXVersionEnglish_v
);
597 hr
= add_bstr_property(node
, szDirectXVersionLongEnglish
, szDirectXVersionLongEnglish_v
);
601 hr
= add_bool_property(node
, bDebug
, FALSE
);
605 hr
= add_bool_property(node
, bNECPC98
, FALSE
);
609 msex
.dwLength
= sizeof(msex
);
610 GlobalMemoryStatusEx(&msex
);
612 hr
= add_ull_as_bstr_property(node
, ullPhysicalMemory
, msex
.ullTotalPhys
);
616 hr
= add_ull_as_bstr_property(node
, ullUsedPageFile
, msex
.ullTotalPageFile
- msex
.ullAvailPageFile
);
620 hr
= add_ull_as_bstr_property(node
, ullAvailPageFile
, msex
.ullAvailPageFile
);
624 hr
= add_bool_property(node
, bNetMeetingRunning
, is_netmeeting_running());
628 info
.dwOSVersionInfoSize
= sizeof(info
);
629 GetVersionExW(&info
);
631 hr
= add_ui4_property(node
, dwOSMajorVersion
, info
.dwMajorVersion
);
635 hr
= add_ui4_property(node
, dwOSMinorVersion
, info
.dwMinorVersion
);
639 hr
= add_ui4_property(node
, dwOSBuildNumber
, info
.dwBuildNumber
);
643 hr
= add_ui4_property(node
, dwOSPlatformID
, info
.dwPlatformId
);
647 hr
= add_bstr_property(node
, szCSDVersion
, info
.szCSDVersion
);
651 /* FIXME: Roundoff should not be done with truncated division. */
652 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), physmem_fmtW
, (DWORD
)(msex
.ullTotalPhys
/ (1024 * 1024)));
653 hr
= add_bstr_property(node
, szPhysicalMemoryEnglish
, print_buf
);
657 usedpage_mb
= (DWORD
)((msex
.ullTotalPageFile
- msex
.ullAvailPageFile
) / (1024 * 1024));
658 availpage_mb
= (DWORD
)(msex
.ullAvailPageFile
/ (1024 * 1024));
659 LoadStringW(dxdiagn_instance
, IDS_PAGE_FILE_FORMAT
, localized_pagefile_fmt
, sizeof(localized_pagefile_fmt
)/sizeof(WCHAR
));
660 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), localized_pagefile_fmt
, usedpage_mb
, availpage_mb
);
662 hr
= add_bstr_property(node
, szPageFileLocalized
, print_buf
);
666 snprintfW(print_buf
, sizeof(print_buf
)/sizeof(WCHAR
), pagefile_fmtW
, usedpage_mb
, availpage_mb
);
668 hr
= add_bstr_property(node
, szPageFileEnglish
, print_buf
);
672 GetWindowsDirectoryW(buffer
, MAX_PATH
);
674 hr
= add_bstr_property(node
, szWindowsDir
, buffer
);
678 count
= sizeof(computer_name
)/sizeof(WCHAR
);
679 if (!GetComputerNameW(computer_name
, &count
))
682 hr
= add_bstr_property(node
, szMachineNameLocalized
, computer_name
);
686 hr
= add_bstr_property(node
, szMachineNameEnglish
, computer_name
);
690 hr
= add_bstr_property(node
, szSystemManufacturerEnglish
, szEmpty
);
694 hr
= add_bstr_property(node
, szSystemModelEnglish
, szEmpty
);
698 hr
= add_bstr_property(node
, szBIOSEnglish
, szEmpty
);
702 hr
= add_bstr_property(node
, szProcessorEnglish
, szEmpty
);
706 hr
= add_bstr_property(node
, szSetupParamEnglish
, notpresentW
);
710 hr
= add_bstr_property(node
, szDxDiagVersion
, szEmpty
);
714 hr
= fill_language_information(node
);
718 hr
= fill_datetime_information(node
);
722 hr
= fill_os_string_information(node
, &info
);
729 /* The logic from pixelformat_for_depth() in dlls/wined3d/utils.c is reversed. */
730 static DWORD
depth_for_pixelformat(D3DFORMAT format
)
734 case D3DFMT_P8
: return 8;
735 case D3DFMT_X1R5G5B5
: return 15;
736 case D3DFMT_R5G6B5
: return 16;
737 /* This case will fail to distinguish an original bpp of 24. */
738 case D3DFMT_X8R8G8B8
: return 32;
740 FIXME("Unknown D3DFORMAT %d, returning 32 bpp\n", format
);
745 static BOOL
get_texture_memory(GUID
*adapter
, DWORD
*available_mem
)
747 IDirectDraw7
*pDirectDraw
;
751 hr
= DirectDrawCreateEx(adapter
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
754 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
755 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.dwCaps4
= 0;
756 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, available_mem
, NULL
);
757 IDirectDraw7_Release(pDirectDraw
);
765 static const WCHAR
*vendor_id_to_manufacturer_string(DWORD vendor_id
)
767 static const WCHAR atiW
[] = {'A','T','I',' ','T','e','c','h','n','o','l','o','g','i','e','s',' ','I','n','c','.',0};
768 static const WCHAR nvidiaW
[] = {'N','V','I','D','I','A',0};
769 static const WCHAR intelW
[] = {'I','n','t','e','l',' ','C','o','r','p','o','r','a','t','i','o','n',0};
770 static const WCHAR unknownW
[] = {'U','n','k','n','o','w','n',0};
772 /* Enumeration copied from dlls/wined3d/wined3d_private.h and slightly modified. */
775 HW_VENDOR_AMD
= 0x1002,
776 HW_VENDOR_NVIDIA
= 0x10de,
777 HW_VENDOR_INTEL
= 0x8086,
784 case HW_VENDOR_NVIDIA
:
786 case HW_VENDOR_INTEL
:
789 FIXME("Unknown PCI vendor ID 0x%04x\n", vendor_id
);
794 static HRESULT
fill_display_information_d3d(IDxDiagContainerImpl_Container
*node
)
796 IDxDiagContainerImpl_Container
*display_adapter
;
798 IDirect3D9
*pDirect3D9
;
802 pDirect3D9
= Direct3DCreate9(D3D_SDK_VERSION
);
806 count
= IDirect3D9_GetAdapterCount(pDirect3D9
);
807 for (index
= 0; index
< count
; index
++)
809 static const WCHAR adapterid_fmtW
[] = {'%','u',0};
810 static const WCHAR driverversion_fmtW
[] = {'%','u','.','%','u','.','%','0','4','u','.','%','0','4','u',0};
811 static const WCHAR id_fmtW
[] = {'0','x','%','0','4','x',0};
812 static const WCHAR subsysid_fmtW
[] = {'0','x','%','0','8','x',0};
813 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
815 D3DADAPTER_IDENTIFIER9 adapter_info
;
816 D3DDISPLAYMODE adapter_mode
;
817 DWORD available_mem
= 0;
819 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), adapterid_fmtW
, index
);
820 display_adapter
= allocate_information_node(buffer
);
821 if (!display_adapter
)
827 add_subcontainer(node
, display_adapter
);
829 hr
= IDirect3D9_GetAdapterIdentifier(pDirect3D9
, index
, 0, &adapter_info
);
832 WCHAR driverW
[sizeof(adapter_info
.Driver
)];
833 WCHAR descriptionW
[sizeof(adapter_info
.Description
)];
834 WCHAR devicenameW
[sizeof(adapter_info
.DeviceName
)];
836 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Driver
, -1, driverW
, sizeof(driverW
)/sizeof(WCHAR
));
837 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.Description
, -1, descriptionW
, sizeof(descriptionW
)/sizeof(WCHAR
));
838 MultiByteToWideChar(CP_ACP
, 0, adapter_info
.DeviceName
, -1, devicenameW
, sizeof(devicenameW
)/sizeof(WCHAR
));
840 hr
= add_bstr_property(display_adapter
, szDriverName
, driverW
);
844 hr
= add_bstr_property(display_adapter
, szDescription
, descriptionW
);
848 hr
= add_bstr_property(display_adapter
, szDeviceName
, devicenameW
);
852 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), driverversion_fmtW
,
853 HIWORD(adapter_info
.DriverVersion
.u
.HighPart
), LOWORD(adapter_info
.DriverVersion
.u
.HighPart
),
854 HIWORD(adapter_info
.DriverVersion
.u
.LowPart
), LOWORD(adapter_info
.DriverVersion
.u
.LowPart
));
856 hr
= add_bstr_property(display_adapter
, szDriverVersion
, buffer
);
860 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.VendorId
);
861 hr
= add_bstr_property(display_adapter
, szVendorId
, buffer
);
865 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.DeviceId
);
866 hr
= add_bstr_property(display_adapter
, szDeviceId
, buffer
);
870 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), subsysid_fmtW
, adapter_info
.SubSysId
);
871 hr
= add_bstr_property(display_adapter
, szSubSysId
, buffer
);
875 snprintfW(buffer
, sizeof(buffer
)/sizeof(WCHAR
), id_fmtW
, adapter_info
.Revision
);
876 hr
= add_bstr_property(display_adapter
, szRevisionId
, buffer
);
880 StringFromGUID2(&adapter_info
.DeviceIdentifier
, buffer
, 39);
881 hr
= add_bstr_property(display_adapter
, szDeviceIdentifier
, buffer
);
885 hr
= add_bstr_property(display_adapter
, szManufacturer
, vendor_id_to_manufacturer_string(adapter_info
.VendorId
));
890 hr
= IDirect3D9_GetAdapterDisplayMode(pDirect3D9
, index
, &adapter_mode
);
893 hr
= add_ui4_property(display_adapter
, dwWidth
, adapter_mode
.Width
);
897 hr
= add_ui4_property(display_adapter
, dwHeight
, adapter_mode
.Height
);
901 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, adapter_mode
.RefreshRate
);
905 hr
= add_ui4_property(display_adapter
, dwBpp
, depth_for_pixelformat(adapter_mode
.Format
));
910 hr
= add_bstr_property(display_adapter
, szKeyDeviceKey
, szEmpty
);
914 hr
= add_bstr_property(display_adapter
, szKeyDeviceID
, szEmpty
);
918 if (!get_texture_memory(&adapter_info
.DeviceIdentifier
, &available_mem
))
919 WARN("get_texture_memory helper failed\n");
921 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, available_mem
/ 1000000.0f
);
923 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
927 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
934 IDirect3D9_Release(pDirect3D9
);
938 static HRESULT
fill_display_information_fallback(IDxDiagContainerImpl_Container
*node
)
940 static const WCHAR szAdapterID
[] = {'0',0};
941 static const WCHAR
*empty_properties
[] = {szDeviceIdentifier
, szVendorId
, szDeviceId
,
942 szKeyDeviceKey
, szKeyDeviceID
, szDriverName
,
943 szDriverVersion
, szSubSysId
, szRevisionId
,
946 IDxDiagContainerImpl_Container
*display_adapter
;
948 IDirectDraw7
*pDirectDraw
;
950 DISPLAY_DEVICEW disp_dev
;
951 DDSURFACEDESC2 surface_descr
;
955 display_adapter
= allocate_information_node(szAdapterID
);
956 if (!display_adapter
)
957 return E_OUTOFMEMORY
;
959 add_subcontainer(node
, display_adapter
);
961 disp_dev
.cb
= sizeof(disp_dev
);
962 if (EnumDisplayDevicesW( NULL
, 0, &disp_dev
, 0 ))
964 hr
= add_bstr_property(display_adapter
, szDeviceName
, disp_dev
.DeviceName
);
968 hr
= add_bstr_property(display_adapter
, szDescription
, disp_dev
.DeviceString
);
973 /* Silently ignore a failure from DirectDrawCreateEx. */
974 hr
= DirectDrawCreateEx(NULL
, (void **)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
978 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
979 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.dwCaps4
= 0;
980 hr
= IDirectDraw7_GetAvailableVidMem(pDirectDraw
, &dd_caps
, &tmp
, NULL
);
983 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
985 snprintfW(buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, tmp
/ 1000000.0f
);
987 hr
= add_bstr_property(display_adapter
, szDisplayMemoryLocalized
, buffer
);
991 hr
= add_bstr_property(display_adapter
, szDisplayMemoryEnglish
, buffer
);
996 surface_descr
.dwSize
= sizeof(surface_descr
);
997 hr
= IDirectDraw7_GetDisplayMode(pDirectDraw
, &surface_descr
);
1000 if (surface_descr
.dwFlags
& DDSD_WIDTH
)
1002 hr
= add_ui4_property(display_adapter
, dwWidth
, surface_descr
.dwWidth
);
1007 if (surface_descr
.dwFlags
& DDSD_HEIGHT
)
1009 hr
= add_ui4_property(display_adapter
, dwHeight
, surface_descr
.dwHeight
);
1014 if (surface_descr
.dwFlags
& DDSD_PIXELFORMAT
)
1016 hr
= add_ui4_property(display_adapter
, dwBpp
, surface_descr
.u4
.ddpfPixelFormat
.u1
.dwRGBBitCount
);
1022 hr
= add_ui4_property(display_adapter
, dwRefreshRate
, 60);
1026 for (tmp
= 0; tmp
< sizeof(empty_properties
)/sizeof(empty_properties
[0]); tmp
++)
1028 hr
= add_bstr_property(display_adapter
, empty_properties
[tmp
], szEmpty
);
1035 IDirectDraw7_Release(pDirectDraw
);
1039 static HRESULT
build_displaydevices_tree(IDxDiagContainerImpl_Container
*node
)
1043 /* Try to use Direct3D to obtain the required information first. */
1044 hr
= fill_display_information_d3d(node
);
1048 return fill_display_information_fallback(node
);
1051 static HRESULT
build_directsound_tree(IDxDiagContainerImpl_Container
*node
)
1053 static const WCHAR DxDiag_SoundDevices
[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
1054 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};
1056 IDxDiagContainerImpl_Container
*cont
;
1058 cont
= allocate_information_node(DxDiag_SoundDevices
);
1060 return E_OUTOFMEMORY
;
1062 add_subcontainer(node
, cont
);
1064 cont
= allocate_information_node(DxDiag_SoundCaptureDevices
);
1066 return E_OUTOFMEMORY
;
1068 add_subcontainer(node
, cont
);
1073 static HRESULT
build_directmusic_tree(IDxDiagContainerImpl_Container
*node
)
1078 static HRESULT
build_directinput_tree(IDxDiagContainerImpl_Container
*node
)
1083 static HRESULT
build_directplay_tree(IDxDiagContainerImpl_Container
*node
)
1088 static HRESULT
build_systemdevices_tree(IDxDiagContainerImpl_Container
*node
)
1093 static HRESULT
fill_file_description(IDxDiagContainerImpl_Container
*node
, const WCHAR
*szFilePath
, const WCHAR
*szFileName
)
1095 static const WCHAR szSlashSep
[] = {'\\',0};
1096 static const WCHAR szPath
[] = {'s','z','P','a','t','h',0};
1097 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1098 static const WCHAR szVersion
[] = {'s','z','V','e','r','s','i','o','n',0};
1099 static const WCHAR szAttributes
[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
1100 static const WCHAR szLanguageEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
1101 static const WCHAR dwFileTimeHigh
[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
1102 static const WCHAR dwFileTimeLow
[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
1103 static const WCHAR bBeta
[] = {'b','B','e','t','a',0};
1104 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
1105 static const WCHAR bExists
[] = {'b','E','x','i','s','t','s',0};
1108 static const WCHAR szFinal_Retail_v
[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
1109 static const WCHAR szEnglish_v
[] = {'E','n','g','l','i','s','h',0};
1110 static const WCHAR szVersionFormat
[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
1114 WCHAR szVersion_v
[1024];
1116 void *pVersionInfo
= NULL
;
1117 BOOL boolret
= FALSE
;
1119 VS_FIXEDFILEINFO
*pFileInfo
;
1121 TRACE("Filling container %p for %s in %s\n", node
,
1122 debugstr_w(szFileName
), debugstr_w(szFilePath
));
1124 szFile
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
) * (lstrlenW(szFilePath
) +
1125 lstrlenW(szFileName
) + 2 /* slash + terminator */));
1127 return E_OUTOFMEMORY
;
1129 lstrcpyW(szFile
, szFilePath
);
1130 lstrcatW(szFile
, szSlashSep
);
1131 lstrcatW(szFile
, szFileName
);
1133 retval
= GetFileVersionInfoSizeW(szFile
, &hdl
);
1136 pVersionInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
1143 if (GetFileVersionInfoW(szFile
, 0, retval
, pVersionInfo
) &&
1144 VerQueryValueW(pVersionInfo
, szSlashSep
, (void **)&pFileInfo
, &uiLength
))
1148 hr
= add_bstr_property(node
, szPath
, szFile
);
1152 hr
= add_bstr_property(node
, szName
, szFileName
);
1156 hr
= add_bool_property(node
, bExists
, boolret
);
1162 snprintfW(szVersion_v
, sizeof(szVersion_v
)/sizeof(szVersion_v
[0]),
1164 HIWORD(pFileInfo
->dwFileVersionMS
),
1165 LOWORD(pFileInfo
->dwFileVersionMS
),
1166 HIWORD(pFileInfo
->dwFileVersionLS
),
1167 LOWORD(pFileInfo
->dwFileVersionLS
));
1169 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v
));
1171 hr
= add_bstr_property(node
, szVersion
, szVersion_v
);
1175 hr
= add_bstr_property(node
, szAttributes
, szFinal_Retail_v
);
1179 hr
= add_bstr_property(node
, szLanguageEnglish
, szEnglish_v
);
1183 hr
= add_ui4_property(node
, dwFileTimeHigh
, pFileInfo
->dwFileDateMS
);
1187 hr
= add_ui4_property(node
, dwFileTimeLow
, pFileInfo
->dwFileDateLS
);
1191 hr
= add_bool_property(node
, bBeta
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_PRERELEASE
) != 0);
1195 hr
= add_bool_property(node
, bDebug
, ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_DEBUG
) != 0);
1202 HeapFree(GetProcessHeap(), 0, pVersionInfo
);
1203 HeapFree(GetProcessHeap(), 0, szFile
);
1207 static HRESULT
build_directxfiles_tree(IDxDiagContainerImpl_Container
*node
)
1209 static const WCHAR dlls
[][15] =
1211 {'d','3','d','8','.','d','l','l',0},
1212 {'d','3','d','9','.','d','l','l',0},
1213 {'d','d','r','a','w','.','d','l','l',0},
1214 {'d','e','v','e','n','u','m','.','d','l','l',0},
1215 {'d','i','n','p','u','t','8','.','d','l','l',0},
1216 {'d','i','n','p','u','t','.','d','l','l',0},
1217 {'d','m','b','a','n','d','.','d','l','l',0},
1218 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
1219 {'d','m','i','m','e','.','d','l','l',0},
1220 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
1221 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
1222 {'d','m','s','t','y','l','e','.','d','l','l',0},
1223 {'d','m','s','y','n','t','h','.','d','l','l',0},
1224 {'d','m','u','s','i','c','.','d','l','l',0},
1225 {'d','p','l','a','y','x','.','d','l','l',0},
1226 {'d','p','n','e','t','.','d','l','l',0},
1227 {'d','s','o','u','n','d','.','d','l','l',0},
1228 {'d','s','w','a','v','e','.','d','l','l',0},
1229 {'d','x','d','i','a','g','n','.','d','l','l',0},
1230 {'q','u','a','r','t','z','.','d','l','l',0}
1234 WCHAR szFilePath
[MAX_PATH
];
1237 GetSystemDirectoryW(szFilePath
, MAX_PATH
);
1239 for (i
= 0; i
< sizeof(dlls
) / sizeof(dlls
[0]); i
++)
1241 static const WCHAR szFormat
[] = {'%','d',0};
1244 IDxDiagContainerImpl_Container
*file_container
;
1246 snprintfW(szFileID
, sizeof(szFileID
)/sizeof(szFileID
[0]), szFormat
, i
);
1248 file_container
= allocate_information_node(szFileID
);
1249 if (!file_container
)
1250 return E_OUTOFMEMORY
;
1252 hr
= fill_file_description(file_container
, szFilePath
, dlls
[i
]);
1255 free_information_tree(file_container
);
1259 add_subcontainer(node
, file_container
);
1265 static HRESULT
read_property_names(IPropertyBag
*pPropBag
, VARIANT
*friendly_name
, VARIANT
*clsid_name
)
1267 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
1268 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
1272 VariantInit(friendly_name
);
1273 VariantInit(clsid_name
);
1275 hr
= IPropertyBag_Read(pPropBag
, wszFriendlyName
, friendly_name
, 0);
1279 hr
= IPropertyBag_Read(pPropBag
, wszClsidName
, clsid_name
, 0);
1282 VariantClear(friendly_name
);
1289 static HRESULT
fill_filter_data_information(IDxDiagContainerImpl_Container
*subcont
, BYTE
*pData
, ULONG cb
)
1291 static const WCHAR szVersionW
[] = {'s','z','V','e','r','s','i','o','n',0};
1292 static const WCHAR dwInputs
[] = {'d','w','I','n','p','u','t','s',0};
1293 static const WCHAR dwOutputs
[] = {'d','w','O','u','t','p','u','t','s',0};
1294 static const WCHAR dwMeritW
[] = {'d','w','M','e','r','i','t',0};
1295 static const WCHAR szVersionFormat
[] = {'v','%','d',0};
1298 IFilterMapper2
*pFileMapper
= NULL
;
1299 IAMFilterData
*pFilterData
= NULL
;
1300 REGFILTER2
*pRF
= NULL
;
1303 DWORD dwNOutputs
= 0;
1304 DWORD dwNInputs
= 0;
1306 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC
, &IID_IFilterMapper2
,
1307 (void **)&pFileMapper
);
1311 hr
= IFilterMapper2_QueryInterface(pFileMapper
, &IID_IAMFilterData
, (void **)&pFilterData
);
1315 hr
= IAMFilterData_ParseFilterData(pFilterData
, pData
, cb
, (BYTE
**)&pRF
);
1319 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szVersionFormat
, pRF
->dwVersion
);
1320 hr
= add_bstr_property(subcont
, szVersionW
, bufferW
);
1324 if (pRF
->dwVersion
== 1)
1326 for (j
= 0; j
< pRF
->u
.s
.cPins
; j
++)
1327 if (pRF
->u
.s
.rgPins
[j
].bOutput
)
1332 else if (pRF
->dwVersion
== 2)
1334 for (j
= 0; j
< pRF
->u
.s1
.cPins2
; j
++)
1335 if (pRF
->u
.s1
.rgPins2
[j
].dwFlags
& REG_PINFLAG_B_OUTPUT
)
1341 hr
= add_ui4_property(subcont
, dwInputs
, dwNInputs
);
1345 hr
= add_ui4_property(subcont
, dwOutputs
, dwNOutputs
);
1349 hr
= add_ui4_property(subcont
, dwMeritW
, pRF
->dwMerit
);
1356 if (pFilterData
) IAMFilterData_Release(pFilterData
);
1357 if (pFileMapper
) IFilterMapper2_Release(pFileMapper
);
1362 static HRESULT
fill_filter_container(IDxDiagContainerImpl_Container
*subcont
, IMoniker
*pMoniker
)
1364 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
1365 static const WCHAR ClsidFilterW
[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
1366 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
1369 IPropertyBag
*pPropFilterBag
= NULL
;
1371 VARIANT friendly_name
;
1375 VariantInit(&friendly_name
);
1376 VariantInit(&clsid_name
);
1379 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropFilterBag
);
1383 hr
= read_property_names(pPropFilterBag
, &friendly_name
, &clsid_name
);
1387 TRACE("Name = %s\n", debugstr_w(V_BSTR(&friendly_name
)));
1388 TRACE("CLSID = %s\n", debugstr_w(V_BSTR(&clsid_name
)));
1390 hr
= add_bstr_property(subcont
, szName
, V_BSTR(&friendly_name
));
1394 hr
= add_bstr_property(subcont
, ClsidFilterW
, V_BSTR(&clsid_name
));
1398 hr
= IPropertyBag_Read(pPropFilterBag
, wszFilterDataName
, &v
, NULL
);
1402 hr
= SafeArrayAccessData(V_ARRAY(&v
), (void **)&pData
);
1406 hr
= fill_filter_data_information(subcont
, pData
, V_ARRAY(&v
)->rgsabound
->cElements
);
1407 SafeArrayUnaccessData(V_ARRAY(&v
));
1414 VariantClear(&clsid_name
);
1415 VariantClear(&friendly_name
);
1416 if (pPropFilterBag
) IPropertyBag_Release(pPropFilterBag
);
1421 static HRESULT
build_directshowfilters_tree(IDxDiagContainerImpl_Container
*node
)
1423 static const WCHAR szCatName
[] = {'s','z','C','a','t','N','a','m','e',0};
1424 static const WCHAR ClsidCatW
[] = {'C','l','s','i','d','C','a','t',0};
1425 static const WCHAR szIdFormat
[] = {'%','d',0};
1429 ICreateDevEnum
*pCreateDevEnum
;
1430 IEnumMoniker
*pEmCat
= NULL
;
1431 IMoniker
*pMCat
= NULL
;
1432 IEnumMoniker
*pEnum
= NULL
;
1434 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
, NULL
, CLSCTX_INPROC_SERVER
,
1435 &IID_ICreateDevEnum
, (void **)&pCreateDevEnum
);
1439 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEmCat
, 0);
1443 while (IEnumMoniker_Next(pEmCat
, 1, &pMCat
, NULL
) == S_OK
)
1447 IPropertyBag
*pPropBag
;
1449 IMoniker
*pMoniker
= NULL
;
1451 hr
= IMoniker_BindToStorage(pMCat
, NULL
, NULL
, &IID_IPropertyBag
, (void **)&pPropBag
);
1454 IMoniker_Release(pMCat
);
1458 hr
= read_property_names(pPropBag
, &vCatName
, &vCatClsid
);
1459 IPropertyBag_Release(pPropBag
);
1462 IMoniker_Release(pMCat
);
1466 hr
= CLSIDFromString(V_BSTR(&vCatClsid
), &clsidCat
);
1469 IMoniker_Release(pMCat
);
1470 VariantClear(&vCatClsid
);
1471 VariantClear(&vCatName
);
1475 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
1478 IMoniker_Release(pMCat
);
1479 VariantClear(&vCatClsid
);
1480 VariantClear(&vCatName
);
1484 TRACE("Enumerating class %s\n", debugstr_guid(&clsidCat
));
1486 while (IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
) == S_OK
)
1489 IDxDiagContainerImpl_Container
*subcont
;
1491 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szIdFormat
, i
);
1492 subcont
= allocate_information_node(bufferW
);
1496 IMoniker_Release(pMoniker
);
1500 hr
= add_bstr_property(subcont
, szCatName
, V_BSTR(&vCatName
));
1503 free_information_tree(subcont
);
1504 IMoniker_Release(pMoniker
);
1508 hr
= add_bstr_property(subcont
, ClsidCatW
, V_BSTR(&vCatClsid
));
1511 free_information_tree(subcont
);
1512 IMoniker_Release(pMoniker
);
1516 hr
= fill_filter_container(subcont
, pMoniker
);
1519 free_information_tree(subcont
);
1520 IMoniker_Release(pMoniker
);
1524 add_subcontainer(node
, subcont
);
1526 IMoniker_Release(pMoniker
);
1529 IEnumMoniker_Release(pEnum
);
1530 IMoniker_Release(pMCat
);
1531 VariantClear(&vCatClsid
);
1532 VariantClear(&vCatName
);
1539 if (pEmCat
) IEnumMoniker_Release(pEmCat
);
1540 ICreateDevEnum_Release(pCreateDevEnum
);
1544 static HRESULT
build_logicaldisks_tree(IDxDiagContainerImpl_Container
*node
)
1549 static HRESULT
build_information_tree(IDxDiagContainerImpl_Container
**pinfo_root
)
1551 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
1552 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};
1553 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
1554 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
1555 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
1556 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
1557 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};
1558 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
1559 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};
1560 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
1565 HRESULT (*initfunc
)(IDxDiagContainerImpl_Container
*);
1568 {DxDiag_SystemInfo
, build_systeminfo_tree
},
1569 {DxDiag_DisplayDevices
, build_displaydevices_tree
},
1570 {DxDiag_DirectSound
, build_directsound_tree
},
1571 {DxDiag_DirectMusic
, build_directmusic_tree
},
1572 {DxDiag_DirectInput
, build_directinput_tree
},
1573 {DxDiag_DirectPlay
, build_directplay_tree
},
1574 {DxDiag_SystemDevices
, build_systemdevices_tree
},
1575 {DxDiag_DirectXFiles
, build_directxfiles_tree
},
1576 {DxDiag_DirectShowFilters
, build_directshowfilters_tree
},
1577 {DxDiag_LogicalDisks
, build_logicaldisks_tree
},
1580 IDxDiagContainerImpl_Container
*info_root
;
1583 info_root
= allocate_information_node(NULL
);
1585 return E_OUTOFMEMORY
;
1587 for (index
= 0; index
< sizeof(root_children
)/sizeof(root_children
[0]); index
++)
1589 IDxDiagContainerImpl_Container
*node
;
1592 node
= allocate_information_node(root_children
[index
].name
);
1595 free_information_tree(info_root
);
1596 return E_OUTOFMEMORY
;
1599 hr
= root_children
[index
].initfunc(node
);
1602 free_information_tree(node
);
1603 free_information_tree(info_root
);
1607 add_subcontainer(info_root
, node
);
1610 *pinfo_root
= info_root
;