2 * IDxDiagProvider Implementation
4 * Copyright 2004-2005 Raphael Junqueira
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
27 #include "dxdiag_private.h"
28 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag
);
44 static HRESULT
DXDiag_InitRootDXDiagContainer(IDxDiagContainer
* pRootCont
);
46 /* IDxDiagProvider IUnknown parts follow: */
47 static HRESULT WINAPI
IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface
, REFIID riid
, LPVOID
*ppobj
)
49 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
51 if (!ppobj
) return E_INVALIDARG
;
53 if (IsEqualGUID(riid
, &IID_IUnknown
)
54 || IsEqualGUID(riid
, &IID_IDxDiagProvider
)) {
55 IUnknown_AddRef(iface
);
60 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
65 static ULONG WINAPI
IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface
) {
66 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
67 ULONG refCount
= InterlockedIncrement(&This
->ref
);
69 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
76 static ULONG WINAPI
IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface
) {
77 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
78 ULONG refCount
= InterlockedDecrement(&This
->ref
);
80 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
83 HeapFree(GetProcessHeap(), 0, This
);
86 DXDIAGN_UnlockModule();
91 /* IDxDiagProvider Interface follow: */
92 static HRESULT WINAPI
IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface
, DXDIAG_INIT_PARAMS
* pParams
) {
93 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
94 TRACE("(%p,%p)\n", iface
, pParams
);
96 if (NULL
== pParams
) {
99 if (pParams
->dwSize
!= sizeof(DXDIAG_INIT_PARAMS
) ||
100 pParams
->dwDxDiagHeaderVersion
!= DXDIAG_DX9_SDK_VERSION
) {
105 memcpy(&This
->params
, pParams
, pParams
->dwSize
);
109 static HRESULT WINAPI
IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface
, IDxDiagContainer
** ppInstance
) {
111 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
112 TRACE("(%p,%p)\n", iface
, ppInstance
);
114 if (FALSE
== This
->init
) {
115 return CO_E_NOTINITIALIZED
;
117 if (NULL
== This
->pRootContainer
) {
118 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &This
->pRootContainer
);
122 hr
= DXDiag_InitRootDXDiagContainer(This
->pRootContainer
);
124 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER
)This
->pRootContainer
, &IID_IDxDiagContainer
, (void**) ppInstance
);
127 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl
=
129 IDxDiagProviderImpl_QueryInterface
,
130 IDxDiagProviderImpl_AddRef
,
131 IDxDiagProviderImpl_Release
,
132 IDxDiagProviderImpl_Initialize
,
133 IDxDiagProviderImpl_GetRootContainer
136 HRESULT
DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
) {
137 IDxDiagProviderImpl
* provider
;
139 TRACE("(%p, %s, %p)\n", punkOuter
, debugstr_guid(riid
), ppobj
);
142 if (punkOuter
) return CLASS_E_NOAGGREGATION
;
144 provider
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagProviderImpl
));
145 if (NULL
== provider
) return E_OUTOFMEMORY
;
146 provider
->lpVtbl
= &DxDiagProvider_Vtbl
;
147 provider
->ref
= 0; /* will be inited with QueryInterface */
148 return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER
)provider
, riid
, ppobj
);
151 static inline HRESULT
add_prop_str( IDxDiagContainer
* cont
, LPCWSTR prop
, LPCWSTR str
)
156 V_VT( &var
) = VT_BSTR
;
157 V_BSTR( &var
) = SysAllocString( str
);
158 hr
= IDxDiagContainerImpl_AddProp( cont
, prop
, &var
);
159 VariantClear( &var
);
164 static inline HRESULT
add_prop_ui4( IDxDiagContainer
* cont
, LPCWSTR prop
, DWORD data
)
168 V_VT( &var
) = VT_UI4
;
169 V_UI4( &var
) = data
;
170 return IDxDiagContainerImpl_AddProp( cont
, prop
, &var
);
173 static inline HRESULT
add_prop_bool( IDxDiagContainer
* cont
, LPCWSTR prop
, BOOL data
)
177 V_VT( &var
) = VT_BOOL
;
178 V_BOOL( &var
) = data
;
179 return IDxDiagContainerImpl_AddProp( cont
, prop
, &var
);
182 static inline HRESULT
add_prop_ull_as_str( IDxDiagContainer
* cont
, LPCWSTR prop
, ULONGLONG data
)
187 V_VT( &var
) = VT_UI8
;
188 V_UI8( &var
) = data
;
189 VariantChangeType( &var
, &var
, 0, VT_BSTR
);
190 hr
= IDxDiagContainerImpl_AddProp( cont
, prop
, &var
);
191 VariantClear( &var
);
196 static void get_display_device_id(WCHAR
*szIdentifierBuffer
)
198 static const WCHAR szNA
[] = {'n','/','a',0};
203 IDirect3D9
*(WINAPI
*pDirect3DCreate9
)(UINT
) = NULL
;
204 IDirect3D9
*pD3d
= NULL
;
205 D3DADAPTER_IDENTIFIER9 adapter_ident
;
207 /* Retrieves the display device identifier from the d3d9 implementation. */
208 d3d9_handle
= LoadLibraryA("d3d9.dll");
210 pDirect3DCreate9
= (void *)GetProcAddress(d3d9_handle
, "Direct3DCreate9");
212 pD3d
= pDirect3DCreate9(D3D_SDK_VERSION
);
214 hr
= IDirect3D9_GetAdapterIdentifier(pD3d
, D3DADAPTER_DEFAULT
, 0, &adapter_ident
);
216 StringFromGUID2(&adapter_ident
.DeviceIdentifier
, szIdentifierBuffer
, 39);
218 memcpy(szIdentifierBuffer
, szNA
, sizeof(szNA
));
222 IDirect3D9_Release(pD3d
);
224 FreeLibrary(d3d9_handle
);
228 * @param szFilePath: usually GetSystemDirectoryW
229 * @param szFileName: name of the dll without path
231 static HRESULT
DXDiag_AddFileDescContainer(IDxDiagContainer
* pSubCont
, const WCHAR
* szFilePath
, const WCHAR
* szFileName
) {
234 static const WCHAR szSlashSep
[] = {'\\',0};
235 static const WCHAR szPath
[] = {'s','z','P','a','t','h',0};
236 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
237 static const WCHAR szVersion
[] = {'s','z','V','e','r','s','i','o','n',0};
238 static const WCHAR szAttributes
[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
239 static const WCHAR szLanguageEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
240 static const WCHAR dwFileTimeHigh
[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
241 static const WCHAR dwFileTimeLow
[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
242 static const WCHAR bBeta
[] = {'b','B','e','t','a',0};
243 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
244 static const WCHAR bExists
[] = {'b','E','x','i','s','t','s',0};
246 static const WCHAR szFinal_Retail_v
[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
247 static const WCHAR szEnglish_v
[] = {'E','n','g','l','i','s','h',0};
248 static const WCHAR szVersionFormat
[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
251 WCHAR szVersion_v
[1024];
256 VS_FIXEDFILEINFO
* pFileInfo
;
258 TRACE("(%p,%s)\n", pSubCont
, debugstr_w(szFileName
));
260 lstrcpyW(szFile
, szFilePath
);
261 lstrcatW(szFile
, szSlashSep
);
262 lstrcatW(szFile
, szFileName
);
264 retval
= GetFileVersionInfoSizeW(szFile
, &hdl
);
265 pVersionInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
266 boolret
= GetFileVersionInfoW(szFile
, 0, retval
, pVersionInfo
);
267 boolret
= VerQueryValueW(pVersionInfo
, szSlashSep
, (LPVOID
) &pFileInfo
, &uiLength
);
269 add_prop_str(pSubCont
, szPath
, szFile
);
270 add_prop_str(pSubCont
, szName
, szFileName
);
271 add_prop_bool(pSubCont
, bExists
, boolret
);
274 snprintfW(szVersion_v
, sizeof(szVersion_v
)/sizeof(szVersion_v
[0]),
276 HIWORD(pFileInfo
->dwFileVersionMS
),
277 LOWORD(pFileInfo
->dwFileVersionMS
),
278 HIWORD(pFileInfo
->dwFileVersionLS
),
279 LOWORD(pFileInfo
->dwFileVersionLS
));
281 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v
));
283 add_prop_str(pSubCont
, szVersion
, szVersion_v
);
284 add_prop_str(pSubCont
, szAttributes
, szFinal_Retail_v
);
285 add_prop_str(pSubCont
, szLanguageEnglish
, szEnglish_v
);
286 add_prop_ui4(pSubCont
, dwFileTimeHigh
, pFileInfo
->dwFileDateMS
);
287 add_prop_ui4(pSubCont
, dwFileTimeLow
, pFileInfo
->dwFileDateLS
);
288 add_prop_bool(pSubCont
, bBeta
, 0 != ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_PRERELEASE
));
289 add_prop_bool(pSubCont
, bDebug
, 0 != ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_DEBUG
));
292 HeapFree(GetProcessHeap(), 0, pVersionInfo
);
297 static HRESULT
DXDiag_InitDXDiagSystemInfoContainer(IDxDiagContainer
* pSubCont
) {
298 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};
299 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};
300 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};
301 static const WCHAR szDirectXVersionLetter_v
[] = {'c',0};
302 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
303 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};
304 static const WCHAR szDirectXVersionEnglish_v
[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
305 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};
306 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};
307 static const WCHAR ullPhysicalMemory
[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
308 static const WCHAR ullUsedPageFile
[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
309 static const WCHAR ullAvailPageFile
[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
310 /*static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};*/
311 static const WCHAR szWindowsDir
[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
312 static const WCHAR dwOSMajorVersion
[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
313 static const WCHAR dwOSMinorVersion
[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
314 static const WCHAR dwOSBuildNumber
[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
315 static const WCHAR dwOSPlatformID
[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
316 static const WCHAR szCSDVersion
[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
319 WCHAR buffer
[MAX_PATH
];
321 add_prop_ui4(pSubCont
, dwDirectXVersionMajor
, 9);
322 add_prop_ui4(pSubCont
, dwDirectXVersionMinor
, 0);
323 add_prop_str(pSubCont
, szDirectXVersionLetter
, szDirectXVersionLetter_v
);
324 add_prop_str(pSubCont
, szDirectXVersionEnglish
, szDirectXVersionEnglish_v
);
325 add_prop_str(pSubCont
, szDirectXVersionLongEnglish
, szDirectXVersionLongEnglish_v
);
326 add_prop_bool(pSubCont
, bDebug
, FALSE
);
328 msex
.dwLength
= sizeof(msex
);
329 GlobalMemoryStatusEx( &msex
);
330 add_prop_ull_as_str(pSubCont
, ullPhysicalMemory
, msex
.ullTotalPhys
);
331 add_prop_ull_as_str(pSubCont
, ullUsedPageFile
, msex
.ullTotalPageFile
- msex
.ullAvailPageFile
);
332 add_prop_ull_as_str(pSubCont
, ullAvailPageFile
, msex
.ullAvailPageFile
);
334 info
.dwOSVersionInfoSize
= sizeof(info
);
335 GetVersionExW( &info
);
336 add_prop_ui4(pSubCont
, dwOSMajorVersion
, info
.dwMajorVersion
);
337 add_prop_ui4(pSubCont
, dwOSMinorVersion
, info
.dwMinorVersion
);
338 add_prop_ui4(pSubCont
, dwOSBuildNumber
, info
.dwBuildNumber
);
339 add_prop_ui4(pSubCont
, dwOSPlatformID
, info
.dwPlatformId
);
340 add_prop_str(pSubCont
, szCSDVersion
, info
.szCSDVersion
);
342 GetWindowsDirectoryW(buffer
, MAX_PATH
);
343 add_prop_str(pSubCont
, szWindowsDir
, buffer
);
348 static HRESULT
DXDiag_InitDXDiagSystemDevicesContainer(IDxDiagContainer
* pSubCont
) {
351 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
352 static const WCHAR szDeviceID[] = {'s','z','D','e','v','i','c','e','I','D',0};
354 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
357 IDxDiagContainer* pDeviceSubCont = NULL;
358 IDxDiagContainer* pDriversCont = NULL;
360 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDeviceSubCont);
361 if (FAILED(hr)) { return hr; }
362 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
363 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDescription, &v);
365 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
366 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDeviceID, &v);
369 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "", pDeviceSubCont);
373 * Drivers Cont contains Files Desc Containers
376 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDriversCont);
377 if (FAILED(hr)) { return hr; }
378 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
384 static HRESULT
DXDiag_InitDXDiagLogicalDisksContainer(IDxDiagContainer
* pSubCont
) {
387 static const WCHAR szDriveLetter[] = {'s','z','D','r','i','v','e','L','e','t','t','e','r',0};
388 static const WCHAR szFreeSpace[] = {'s','z','F','r','e','e','S','p','a','c','e',0};
389 static const WCHAR szMaxSpace[] = {'s','z','M','a','x','S','p','a','c','e',0};
390 static const WCHAR szFileSystem[] = {'s','z','F','i','l','e','S','y','s','t','e','m',0};
391 static const WCHAR szModel[] = {'s','z','M','o','d','e','l',0};
392 static const WCHAR szPNPDeviceID[] = {'s','z','P','N','P','D','e','v','i','c','e','I','D',0};
393 static const WCHAR dwHardDriveIndex[] = {'d','w','H','a','r','d','D','r','i','v','e','I','n','d','e','x',0};
395 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
398 IDxDiagContainer* pDiskSubCont = NULL;
399 IDxDiagContainer* pDriversCont = NULL;
401 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDiskSubCont);
402 if (FAILED(hr)) { return hr; }
403 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "" , pDiskSubCont);
407 * Drivers Cont contains Files Desc Containers
410 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDriversCont);
411 if (FAILED(hr)) { return hr; }
412 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
417 static HRESULT
DXDiag_InitDXDiagDirectXFilesContainer(IDxDiagContainer
* pSubCont
)
420 static const WCHAR dlls
[][15] =
422 {'d','3','d','8','.','d','l','l',0},
423 {'d','3','d','9','.','d','l','l',0},
424 {'d','d','r','a','w','.','d','l','l',0},
425 {'d','e','v','e','n','u','m','.','d','l','l',0},
426 {'d','i','n','p','u','t','8','.','d','l','l',0},
427 {'d','i','n','p','u','t','.','d','l','l',0},
428 {'d','m','b','a','n','d','.','d','l','l',0},
429 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
430 {'d','m','i','m','e','.','d','l','l',0},
431 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
432 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
433 {'d','m','s','t','y','l','e','.','d','l','l',0},
434 {'d','m','s','y','n','t','h','.','d','l','l',0},
435 {'d','m','u','s','i','c','.','d','l','l',0},
436 {'d','p','l','a','y','x','.','d','l','l',0},
437 {'d','p','n','e','t','.','d','l','l',0},
438 {'d','s','o','u','n','d','.','d','l','l',0},
439 {'d','s','w','a','v','e','.','d','l','l',0},
440 {'d','x','d','i','a','g','n','.','d','l','l',0},
441 {'q','u','a','r','t','z','.','d','l','l',0}
443 WCHAR szFilePath
[MAX_PATH
];
446 GetSystemDirectoryW(szFilePath
, MAX_PATH
);
448 for (i
= 0; i
< sizeof(dlls
) / sizeof(dlls
[0]); i
++)
450 static const WCHAR szFormat
[] = {'%','d',0};
452 IDxDiagContainer
*pDXFileSubCont
;
454 snprintfW(szFileID
, sizeof(szFileID
)/sizeof(szFileID
[0]), szFormat
, i
);
456 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pDXFileSubCont
);
457 if (FAILED(hr
)) continue;
459 if (FAILED(DXDiag_AddFileDescContainer(pDXFileSubCont
, szFilePath
, dlls
[i
])) ||
460 FAILED(IDxDiagContainerImpl_AddChildContainer(pSubCont
, szFileID
, pDXFileSubCont
)))
462 IUnknown_Release(pDXFileSubCont
);
469 static HRESULT
DXDiag_InitDXDiagDisplayContainer(IDxDiagContainer
* pSubCont
)
471 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
472 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
473 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
474 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
475 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
476 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
477 static const WCHAR szDeviceIdentifier
[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
478 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
479 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
480 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
481 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};
482 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};
484 static const WCHAR szAdapterID
[] = {'0',0};
485 static const WCHAR szEmpty
[] = {0};
488 IDxDiagContainer
*pDisplayAdapterSubCont
= NULL
;
490 IDirectDraw7
*pDirectDraw
;
492 DISPLAY_DEVICEW disp_dev
;
493 DDSURFACEDESC2 surface_descr
;
497 hr
= DXDiag_CreateDXDiagContainer( &IID_IDxDiagContainer
, (void**) &pDisplayAdapterSubCont
);
498 if (FAILED( hr
)) return hr
;
499 hr
= IDxDiagContainerImpl_AddChildContainer( pSubCont
, szAdapterID
, pDisplayAdapterSubCont
);
500 if (FAILED( hr
)) return hr
;
502 disp_dev
.cb
= sizeof(disp_dev
);
503 if (EnumDisplayDevicesW( NULL
, 0, &disp_dev
, 0 ))
505 add_prop_str( pDisplayAdapterSubCont
, szDeviceName
, disp_dev
.DeviceName
);
506 add_prop_str( pDisplayAdapterSubCont
, szDescription
, disp_dev
.DeviceString
);
509 hr
= DirectDrawCreateEx( NULL
, (LPVOID
*)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
510 if (FAILED( hr
)) return hr
;
512 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
513 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.dwCaps4
= 0;
514 hr
= IDirectDraw7_GetAvailableVidMem( pDirectDraw
, &dd_caps
, &tmp
, NULL
);
517 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
519 snprintfW( buffer
, sizeof(buffer
)/sizeof(buffer
[0]), mem_fmt
, ((float)tmp
) / 1000000.0 );
520 add_prop_str( pDisplayAdapterSubCont
, szDisplayMemoryLocalized
, buffer
);
521 add_prop_str( pDisplayAdapterSubCont
, szDisplayMemoryEnglish
, buffer
);
524 surface_descr
.dwSize
= sizeof(surface_descr
);
525 hr
= IDirectDraw7_GetDisplayMode( pDirectDraw
, &surface_descr
);
528 if (surface_descr
.dwFlags
& DDSD_WIDTH
)
529 add_prop_ui4( pDisplayAdapterSubCont
, dwWidth
, surface_descr
.dwWidth
);
530 if (surface_descr
.dwFlags
& DDSD_HEIGHT
)
531 add_prop_ui4( pDisplayAdapterSubCont
, dwHeight
, surface_descr
.dwHeight
);
532 if (surface_descr
.dwFlags
& DDSD_PIXELFORMAT
)
533 add_prop_ui4( pDisplayAdapterSubCont
, dwBpp
, surface_descr
.u4
.ddpfPixelFormat
.u1
.dwRGBBitCount
);
536 get_display_device_id( buffer
);
537 add_prop_str( pDisplayAdapterSubCont
, szDeviceIdentifier
, buffer
);
539 add_prop_str( pDisplayAdapterSubCont
, szVendorId
, szEmpty
);
540 add_prop_str( pDisplayAdapterSubCont
, szDeviceId
, szEmpty
);
541 add_prop_str( pDisplayAdapterSubCont
, szKeyDeviceKey
, szEmpty
);
542 add_prop_str( pDisplayAdapterSubCont
, szKeyDeviceID
, szEmpty
);
544 IUnknown_Release( pDirectDraw
);
548 static HRESULT
DXDiag_InitDXDiagDirectSoundContainer(IDxDiagContainer
* pSubCont
) {
550 static const WCHAR DxDiag_SoundDevices
[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
551 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};
552 IDxDiagContainer
* pSubSubCont
= NULL
;
554 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubSubCont
);
555 if (FAILED(hr
)) { return hr
; }
556 hr
= IDxDiagContainerImpl_AddChildContainer(pSubCont
, DxDiag_SoundDevices
, pSubSubCont
);
558 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubSubCont
);
559 if (FAILED(hr
)) { return hr
; }
560 hr
= IDxDiagContainerImpl_AddChildContainer(pSubCont
, DxDiag_SoundCaptureDevices
, pSubSubCont
);
565 static HRESULT
DXDiag_InitDXDiagDirectMusicContainer(IDxDiagContainer
* pSubCont
) {
570 static HRESULT
DXDiag_InitDXDiagDirectInputContainer(IDxDiagContainer
* pSubCont
) {
575 static HRESULT
DXDiag_InitDXDiagDirectPlayContainer(IDxDiagContainer
* pSubCont
) {
580 static HRESULT
DXDiag_InitDXDiagDirectShowFiltersContainer(IDxDiagContainer
* pSubCont
) {
582 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
583 static const WCHAR szVersionW
[] = {'s','z','V','e','r','s','i','o','n',0};
584 static const WCHAR szCatName
[] = {'s','z','C','a','t','N','a','m','e',0};
585 static const WCHAR ClsidCatW
[] = {'C','l','s','i','d','C','a','t',0};
586 static const WCHAR ClsidFilterW
[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
587 static const WCHAR dwInputs
[] = {'d','w','I','n','p','u','t','s',0};
588 static const WCHAR dwOutputs
[] = {'d','w','O','u','t','p','u','t','s',0};
589 static const WCHAR dwMeritW
[] = {'d','w','M','e','r','i','t',0};
591 static const WCHAR szFileName[] = {'s','z','F','i','l','e','N','a','m','e',0};
592 static const WCHAR szFileVersion[] = {'s','z','F','i','l','e','V','e','r','s','i','o','n',0};
596 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
597 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
598 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
600 static const WCHAR szVersionFormat
[] = {'v','%','d',0};
601 static const WCHAR szIdFormat
[] = {'%','d',0};
605 ICreateDevEnum
* pCreateDevEnum
= NULL
;
606 IEnumMoniker
* pEmCat
= NULL
;
607 IMoniker
* pMCat
= NULL
;
609 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
,
611 CLSCTX_INPROC_SERVER
,
613 (void**) &pCreateDevEnum
);
614 if (FAILED(hr
)) return hr
;
616 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEmCat
, 0);
617 if (FAILED(hr
)) goto out_show_filters
;
621 while (S_OK
== IEnumMoniker_Next(pEmCat
, 1, &pMCat
, NULL
)) {
622 IPropertyBag
* pPropBag
= NULL
;
624 hr
= IMoniker_BindToStorage(pMCat
, NULL
, NULL
, &IID_IPropertyBag
, (void**) &pPropBag
);
626 WCHAR
* wszCatName
= NULL
;
627 WCHAR
* wszCatClsid
= NULL
;
629 hr
= IPropertyBag_Read(pPropBag
, wszFriendlyName
, &v
, 0);
630 wszCatName
= SysAllocString(V_BSTR(&v
));
633 hr
= IPropertyBag_Read(pPropBag
, wszClsidName
, &v
, 0);
634 wszCatClsid
= SysAllocString(V_BSTR(&v
));
635 hr
= CLSIDFromString(V_UNION(&v
, bstrVal
), &clsidCat
);
639 hr = IPropertyBag_Read(pPropBag, wszMeritName, &v, 0);
640 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwMerit, &v);
645 IEnumMoniker
* pEnum
= NULL
;
646 IMoniker
* pMoniker
= NULL
;
647 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
648 TRACE("\tClassEnumerator for clsid(%s) pEnum(%p)\n", debugstr_guid(&clsidCat
), pEnum
);
649 if (FAILED(hr
) || pEnum
== NULL
) {
650 goto class_enum_failed
;
652 while (NULL
!= pEnum
&& S_OK
== IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
)) {
653 IPropertyBag
* pPropFilterBag
= NULL
;
654 TRACE("\tIEnumMoniker_Next(%p, 1, %p)\n", pEnum
, pMoniker
);
655 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (void**) &pPropFilterBag
);
658 DWORD dwNOutputs
= 0;
662 IDxDiagContainer
*pDShowSubCont
= NULL
;
663 IFilterMapper2
*pFileMapper
= NULL
;
664 IAMFilterData
*pFilterData
= NULL
;
666 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szIdFormat
, i
);
667 if (FAILED(DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pDShowSubCont
)) ||
668 FAILED(IDxDiagContainerImpl_AddChildContainer(pSubCont
, bufferW
, pDShowSubCont
)))
670 IPropertyBag_Release(pPropFilterBag
);
671 if (pDShowSubCont
) IUnknown_Release(pDShowSubCont
);
676 hr
= IPropertyBag_Read(pPropFilterBag
, wszFriendlyName
, &v
, 0);
677 hr
= IDxDiagContainerImpl_AddProp(pDShowSubCont
, szName
, &v
);
678 TRACE("\tName:%s\n", debugstr_w(V_BSTR(&v
)));
681 hr
= IPropertyBag_Read(pPropFilterBag
, wszClsidName
, &v
, 0);
682 TRACE("\tClsid:%s\n", debugstr_w(V_BSTR(&v
)));
683 hr
= IDxDiagContainerImpl_AddProp(pDShowSubCont
, ClsidFilterW
, &v
);
686 hr
= CoCreateInstance(&CLSID_FilterMapper2
, NULL
, CLSCTX_INPROC
, &IID_IFilterMapper2
,
687 (LPVOID
*)&pFileMapper
);
689 SUCCEEDED(IFilterMapper2_QueryInterface(pFileMapper
, &IID_IAMFilterData
, (void **)&pFilterData
)))
694 if (SUCCEEDED(IPropertyBag_Read(pPropFilterBag
, wszFilterDataName
, &v
, NULL
)) &&
695 SUCCEEDED(SafeArrayAccessData(V_UNION(&v
, parray
), (LPVOID
*) &pData
)))
698 array_size
= V_UNION(&v
, parray
)->rgsabound
->cElements
;
700 if (SUCCEEDED(IAMFilterData_ParseFilterData(pFilterData
, pData
, array_size
, (BYTE
**)&pRF
)))
702 snprintfW(bufferW
, sizeof(bufferW
)/sizeof(bufferW
[0]), szVersionFormat
, pRF
->dwVersion
);
703 if (pRF
->dwVersion
== 1)
705 for (j
= 0; j
< pRF
->u
.s
.cPins
; j
++)
706 if (pRF
->u
.s
.rgPins
[j
].bOutput
)
711 else if (pRF
->dwVersion
== 2)
713 for (j
= 0; j
< pRF
->u
.s1
.cPins2
; j
++)
714 if (pRF
->u
.s1
.rgPins2
[j
].dwFlags
& REG_PINFLAG_B_OUTPUT
)
720 dwMerit
= pRF
->dwMerit
;
724 SafeArrayUnaccessData(V_UNION(&v
, parray
));
727 IFilterMapper2_Release(pFilterData
);
729 if (pFileMapper
) IFilterMapper2_Release(pFileMapper
);
731 add_prop_str(pDShowSubCont
, szVersionW
, bufferW
);
732 add_prop_str(pDShowSubCont
, szCatName
, wszCatName
);
733 add_prop_str(pDShowSubCont
, ClsidCatW
, wszCatClsid
);
734 add_prop_ui4(pDShowSubCont
, dwInputs
, dwNInputs
);
735 add_prop_ui4(pDShowSubCont
, dwOutputs
, dwNOutputs
);
736 add_prop_ui4(pDShowSubCont
, dwMeritW
, dwMerit
);
740 IPropertyBag_Release(pPropFilterBag
); pPropFilterBag
= NULL
;
742 IEnumMoniker_Release(pEnum
); pEnum
= NULL
;
745 SysFreeString(wszCatName
);
746 SysFreeString(wszCatClsid
);
747 IPropertyBag_Release(pPropBag
); pPropBag
= NULL
;
749 IEnumMoniker_Release(pMCat
); pMCat
= NULL
;
753 if (NULL
!= pEmCat
) { IEnumMoniker_Release(pEmCat
); pEmCat
= NULL
; }
754 if (NULL
!= pCreateDevEnum
) { ICreateDevEnum_Release(pCreateDevEnum
); pCreateDevEnum
= NULL
; }
758 static HRESULT
DXDiag_InitRootDXDiagContainer(IDxDiagContainer
* pRootCont
) {
760 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
761 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};
762 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
763 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
764 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};
765 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
766 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
767 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
768 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
769 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};
770 IDxDiagContainer
* pSubCont
= NULL
;
772 TRACE("(%p)\n", pRootCont
);
774 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
775 if (FAILED(hr
)) { return hr
; }
776 hr
= DXDiag_InitDXDiagSystemInfoContainer(pSubCont
);
777 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_SystemInfo
, pSubCont
);
779 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
780 if (FAILED(hr
)) { return hr
; }
781 hr
= DXDiag_InitDXDiagSystemDevicesContainer(pSubCont
);
782 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_SystemDevices
, pSubCont
);
784 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
785 if (FAILED(hr
)) { return hr
; }
786 hr
= DXDiag_InitDXDiagLogicalDisksContainer(pSubCont
);
787 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_LogicalDisks
, pSubCont
);
789 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
790 if (FAILED(hr
)) { return hr
; }
791 hr
= DXDiag_InitDXDiagDirectXFilesContainer(pSubCont
);
792 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectXFiles
, pSubCont
);
794 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
795 if (FAILED(hr
)) { return hr
; }
796 hr
= DXDiag_InitDXDiagDisplayContainer(pSubCont
);
797 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DisplayDevices
, pSubCont
);
799 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
800 if (FAILED(hr
)) { return hr
; }
801 hr
= DXDiag_InitDXDiagDirectSoundContainer(pSubCont
);
802 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectSound
, pSubCont
);
804 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
805 if (FAILED(hr
)) { return hr
; }
806 hr
= DXDiag_InitDXDiagDirectMusicContainer(pSubCont
);
807 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectMusic
, pSubCont
);
809 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
810 if (FAILED(hr
)) { return hr
; }
811 hr
= DXDiag_InitDXDiagDirectInputContainer(pSubCont
);
812 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectInput
, pSubCont
);
814 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
815 if (FAILED(hr
)) { return hr
; }
816 hr
= DXDiag_InitDXDiagDirectPlayContainer(pSubCont
);
817 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectPlay
, pSubCont
);
819 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
820 if (FAILED(hr
)) { return hr
; }
821 hr
= DXDiag_InitDXDiagDirectShowFiltersContainer(pSubCont
);
822 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectShowFilters
, pSubCont
);