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 (IsEqualGUID(riid, &IID_IUnknown)
52 || IsEqualGUID(riid, &IID_IDxDiagProvider)) {
53 IUnknown_AddRef(iface);
58 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
62 static ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) {
63 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
64 ULONG refCount = InterlockedIncrement(&This->ref);
66 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
73 static ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) {
74 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
75 ULONG refCount = InterlockedDecrement(&This->ref);
77 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
80 HeapFree(GetProcessHeap(), 0, This);
83 DXDIAGN_UnlockModule();
88 /* IDxDiagProvider Interface follow: */
89 static HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS* pParams) {
90 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
91 TRACE("(%p,%p)\n", iface, pParams);
93 if (NULL == pParams) {
96 if (pParams->dwSize != sizeof(DXDIAG_INIT_PARAMS)) {
101 memcpy(&This->params, pParams, pParams->dwSize);
105 static HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
107 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
108 TRACE("(%p,%p)\n", iface, ppInstance);
110 if (NULL == ppInstance) {
113 if (FALSE == This->init) {
114 return E_INVALIDARG; /* should be E_CO_UNINITIALIZED */
116 if (NULL == This->pRootContainer) {
117 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &This->pRootContainer);
121 hr = DXDiag_InitRootDXDiagContainer(This->pRootContainer);
123 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance);
126 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
128 IDxDiagProviderImpl_QueryInterface,
129 IDxDiagProviderImpl_AddRef,
130 IDxDiagProviderImpl_Release,
131 IDxDiagProviderImpl_Initialize,
132 IDxDiagProviderImpl_GetRootContainer
135 HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
136 IDxDiagProviderImpl* provider;
138 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
140 provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
141 if (NULL == provider) {
143 return E_OUTOFMEMORY;
145 provider->lpVtbl = &DxDiagProvider_Vtbl;
146 provider->ref = 0; /* will be inited with QueryInterface */
147 return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER)provider, riid, ppobj);
150 static inline HRESULT add_prop_str( IDxDiagContainer* cont, LPCWSTR prop, LPCWSTR str )
155 V_VT( &var ) = VT_BSTR;
156 V_BSTR( &var ) = SysAllocString( str );
157 hr = IDxDiagContainerImpl_AddProp( cont, prop, &var );
158 VariantClear( &var );
163 static inline HRESULT add_prop_ui4( IDxDiagContainer* cont, LPCWSTR prop, DWORD data )
167 V_VT( &var ) = VT_UI4;
168 V_UI4( &var ) = data;
169 return IDxDiagContainerImpl_AddProp( cont, prop, &var );
172 static inline HRESULT add_prop_bool( IDxDiagContainer* cont, LPCWSTR prop, BOOL data )
176 V_VT( &var ) = VT_BOOL;
177 V_BOOL( &var ) = data;
178 return IDxDiagContainerImpl_AddProp( cont, prop, &var );
181 static inline HRESULT add_prop_ull_as_str( IDxDiagContainer* cont, LPCWSTR prop, ULONGLONG data )
186 V_VT( &var ) = VT_UI8;
187 V_UI8( &var ) = data;
188 VariantChangeType( &var, &var, 0, VT_BSTR );
189 hr = IDxDiagContainerImpl_AddProp( cont, prop, &var );
190 VariantClear( &var );
195 static void get_display_device_id(WCHAR *szIdentifierBuffer)
197 static const WCHAR szNA[] = {'n','/','a',0};
202 IDirect3D9 *(WINAPI *pDirect3DCreate9)(UINT) = NULL;
203 IDirect3D9 *pD3d = NULL;
204 D3DADAPTER_IDENTIFIER9 adapter_ident;
206 /* Retrieves the display device identifier from the d3d9 implementation. */
207 d3d9_handle = LoadLibraryA("d3d9.dll");
209 pDirect3DCreate9 = (void *)GetProcAddress(d3d9_handle, "Direct3DCreate9");
211 pD3d = pDirect3DCreate9(D3D_SDK_VERSION);
213 hr = IDirect3D9_GetAdapterIdentifier(pD3d, D3DADAPTER_DEFAULT, 0, &adapter_ident);
215 StringFromGUID2(&adapter_ident.DeviceIdentifier, szIdentifierBuffer, 39);
217 memcpy(szIdentifierBuffer, szNA, sizeof(szNA));
221 IDirect3D9_Release(pD3d);
223 FreeLibrary(d3d9_handle);
227 * @param szFilePath: usually GetSystemDirectoryW
228 * @param szFileName: name of the dll without path
230 static HRESULT DXDiag_AddFileDescContainer(IDxDiagContainer* pSubCont, const WCHAR* szFilePath, const WCHAR* szFileName) {
233 static const WCHAR szSlashSep[] = {'\\',0};
234 static const WCHAR szPath[] = {'s','z','P','a','t','h',0};
235 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
236 static const WCHAR szVersion[] = {'s','z','V','e','r','s','i','o','n',0};
237 static const WCHAR szAttributes[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
238 static const WCHAR szLanguageEnglish[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
239 static const WCHAR dwFileTimeHigh[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
240 static const WCHAR dwFileTimeLow[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
241 static const WCHAR bBeta[] = {'b','B','e','t','a',0};
242 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
243 static const WCHAR bExists[] = {'b','E','x','i','s','t','s',0};
245 static const WCHAR szFinal_Retail_v[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
246 static const WCHAR szEnglish_v[] = {'E','n','g','l','i','s','h',0};
247 static const WCHAR szVersionFormat[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
250 WCHAR szVersion_v[1024];
255 VS_FIXEDFILEINFO* pFileInfo;
257 TRACE("(%p,%s)\n", pSubCont, debugstr_w(szFileName));
259 lstrcpyW(szFile, szFilePath);
260 lstrcatW(szFile, szSlashSep);
261 lstrcatW(szFile, szFileName);
263 retval = GetFileVersionInfoSizeW(szFile, &hdl);
264 pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
265 boolret = GetFileVersionInfoW(szFile, 0, retval, pVersionInfo);
266 boolret = VerQueryValueW(pVersionInfo, szSlashSep, (LPVOID) &pFileInfo, &uiLength);
268 add_prop_str(pSubCont, szPath, szFile);
269 add_prop_str(pSubCont, szName, szFileName);
270 add_prop_bool(pSubCont, bExists, boolret);
273 snprintfW(szVersion_v, sizeof(szVersion_v)/sizeof(szVersion_v[0]),
275 HIWORD(pFileInfo->dwFileVersionMS),
276 LOWORD(pFileInfo->dwFileVersionMS),
277 HIWORD(pFileInfo->dwFileVersionLS),
278 LOWORD(pFileInfo->dwFileVersionLS));
280 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v));
282 add_prop_str(pSubCont, szVersion, szVersion_v);
283 add_prop_str(pSubCont, szAttributes, szFinal_Retail_v);
284 add_prop_str(pSubCont, szLanguageEnglish, szEnglish_v);
285 add_prop_ui4(pSubCont, dwFileTimeHigh, pFileInfo->dwFileDateMS);
286 add_prop_ui4(pSubCont, dwFileTimeLow, pFileInfo->dwFileDateLS);
287 add_prop_bool(pSubCont, bBeta, 0 != ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_PRERELEASE));
288 add_prop_bool(pSubCont, bDebug, 0 != ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_DEBUG));
291 HeapFree(GetProcessHeap(), 0, pVersionInfo);
296 static HRESULT DXDiag_InitDXDiagSystemInfoContainer(IDxDiagContainer* pSubCont) {
297 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};
298 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};
299 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};
300 static const WCHAR szDirectXVersionLetter_v[] = {'c',0};
301 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
302 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};
303 static const WCHAR szDirectXVersionEnglish_v[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
304 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};
305 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};
306 static const WCHAR ullPhysicalMemory[] = {'u','l','l','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
307 static const WCHAR ullUsedPageFile[] = {'u','l','l','U','s','e','d','P','a','g','e','F','i','l','e',0};
308 static const WCHAR ullAvailPageFile[] = {'u','l','l','A','v','a','i','l','P','a','g','e','F','i','l','e',0};
309 /*static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};*/
310 static const WCHAR szWindowsDir[] = {'s','z','W','i','n','d','o','w','s','D','i','r',0};
311 static const WCHAR dwOSMajorVersion[] = {'d','w','O','S','M','a','j','o','r','V','e','r','s','i','o','n',0};
312 static const WCHAR dwOSMinorVersion[] = {'d','w','O','S','M','i','n','o','r','V','e','r','s','i','o','n',0};
313 static const WCHAR dwOSBuildNumber[] = {'d','w','O','S','B','u','i','l','d','N','u','m','b','e','r',0};
314 static const WCHAR dwOSPlatformID[] = {'d','w','O','S','P','l','a','t','f','o','r','m','I','D',0};
315 static const WCHAR szCSDVersion[] = {'s','z','C','S','D','V','e','r','s','i','o','n',0};
318 WCHAR buffer[MAX_PATH];
320 add_prop_ui4(pSubCont, dwDirectXVersionMajor, 9);
321 add_prop_ui4(pSubCont, dwDirectXVersionMinor, 0);
322 add_prop_str(pSubCont, szDirectXVersionLetter, szDirectXVersionLetter_v);
323 add_prop_str(pSubCont, szDirectXVersionEnglish, szDirectXVersionEnglish_v);
324 add_prop_str(pSubCont, szDirectXVersionLongEnglish, szDirectXVersionLongEnglish_v);
325 add_prop_bool(pSubCont, bDebug, FALSE);
327 msex.dwLength = sizeof(msex);
328 GlobalMemoryStatusEx( &msex );
329 add_prop_ull_as_str(pSubCont, ullPhysicalMemory, msex.ullTotalPhys);
330 add_prop_ull_as_str(pSubCont, ullUsedPageFile, msex.ullTotalPageFile - msex.ullAvailPageFile);
331 add_prop_ull_as_str(pSubCont, ullAvailPageFile, msex.ullAvailPageFile);
333 info.dwOSVersionInfoSize = sizeof(info);
334 GetVersionExW( &info );
335 add_prop_ui4(pSubCont, dwOSMajorVersion, info.dwMajorVersion);
336 add_prop_ui4(pSubCont, dwOSMinorVersion, info.dwMinorVersion);
337 add_prop_ui4(pSubCont, dwOSBuildNumber, info.dwBuildNumber);
338 add_prop_ui4(pSubCont, dwOSPlatformID, info.dwPlatformId);
339 add_prop_str(pSubCont, szCSDVersion, info.szCSDVersion);
341 GetWindowsDirectoryW(buffer, MAX_PATH);
342 add_prop_str(pSubCont, szWindowsDir, buffer);
347 static HRESULT DXDiag_InitDXDiagSystemDevicesContainer(IDxDiagContainer* pSubCont) {
350 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
351 static const WCHAR szDeviceID[] = {'s','z','D','e','v','i','c','e','I','D',0};
353 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
356 IDxDiagContainer* pDeviceSubCont = NULL;
357 IDxDiagContainer* pDriversCont = NULL;
359 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDeviceSubCont);
360 if (FAILED(hr)) { return hr; }
361 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
362 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDescription, &v);
364 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
365 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDeviceID, &v);
368 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "", pDeviceSubCont);
372 * Drivers Cont contains Files Desc Containers
375 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDriversCont);
376 if (FAILED(hr)) { return hr; }
377 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
383 static HRESULT DXDiag_InitDXDiagLogicalDisksContainer(IDxDiagContainer* pSubCont) {
386 static const WCHAR szDriveLetter[] = {'s','z','D','r','i','v','e','L','e','t','t','e','r',0};
387 static const WCHAR szFreeSpace[] = {'s','z','F','r','e','e','S','p','a','c','e',0};
388 static const WCHAR szMaxSpace[] = {'s','z','M','a','x','S','p','a','c','e',0};
389 static const WCHAR szFileSystem[] = {'s','z','F','i','l','e','S','y','s','t','e','m',0};
390 static const WCHAR szModel[] = {'s','z','M','o','d','e','l',0};
391 static const WCHAR szPNPDeviceID[] = {'s','z','P','N','P','D','e','v','i','c','e','I','D',0};
392 static const WCHAR dwHardDriveIndex[] = {'d','w','H','a','r','d','D','r','i','v','e','I','n','d','e','x',0};
394 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
397 IDxDiagContainer* pDiskSubCont = NULL;
398 IDxDiagContainer* pDriversCont = NULL;
400 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDiskSubCont);
401 if (FAILED(hr)) { return hr; }
402 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "" , pDiskSubCont);
406 * Drivers Cont contains Files Desc Containers
409 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, &pDriversCont);
410 if (FAILED(hr)) { return hr; }
411 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
416 static HRESULT DXDiag_InitDXDiagDirectXFilesContainer(IDxDiagContainer* pSubCont)
419 static const WCHAR dlls[][15] =
421 {'d','3','d','8','.','d','l','l',0},
422 {'d','3','d','9','.','d','l','l',0},
423 {'d','d','r','a','w','.','d','l','l',0},
424 {'d','e','v','e','n','u','m','.','d','l','l',0},
425 {'d','i','n','p','u','t','8','.','d','l','l',0},
426 {'d','i','n','p','u','t','.','d','l','l',0},
427 {'d','m','b','a','n','d','.','d','l','l',0},
428 {'d','m','c','o','m','p','o','s','.','d','l','l',0},
429 {'d','m','i','m','e','.','d','l','l',0},
430 {'d','m','l','o','a','d','e','r','.','d','l','l',0},
431 {'d','m','s','c','r','i','p','t','.','d','l','l',0},
432 {'d','m','s','t','y','l','e','.','d','l','l',0},
433 {'d','m','s','y','n','t','h','.','d','l','l',0},
434 {'d','m','u','s','i','c','.','d','l','l',0},
435 {'d','p','l','a','y','x','.','d','l','l',0},
436 {'d','p','n','e','t','.','d','l','l',0},
437 {'d','s','o','u','n','d','.','d','l','l',0},
438 {'d','s','w','a','v','e','.','d','l','l',0},
439 {'d','x','d','i','a','g','n','.','d','l','l',0},
440 {'q','u','a','r','t','z','.','d','l','l',0}
442 WCHAR szFilePath[MAX_PATH];
445 GetSystemDirectoryW(szFilePath, MAX_PATH);
447 for (i = 0; i < sizeof(dlls) / sizeof(dlls[0]); i++)
449 static const WCHAR szFormat[] = {'%','d',0};
451 IDxDiagContainer *pDXFileSubCont;
453 snprintfW(szFileID, sizeof(szFileID)/sizeof(szFileID[0]), szFormat, i);
455 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDXFileSubCont);
456 if (FAILED(hr)) continue;
458 if (FAILED(DXDiag_AddFileDescContainer(pDXFileSubCont, szFilePath, dlls[i])) ||
459 FAILED(IDxDiagContainerImpl_AddChildContainer(pSubCont, szFileID, pDXFileSubCont)))
461 IUnknown_Release(pDXFileSubCont);
468 static HRESULT DXDiag_InitDXDiagDisplayContainer(IDxDiagContainer* pSubCont)
470 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
471 static const WCHAR szDeviceName[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
472 static const WCHAR szKeyDeviceID[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
473 static const WCHAR szKeyDeviceKey[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
474 static const WCHAR szVendorId[] = {'s','z','V','e','n','d','o','r','I','d',0};
475 static const WCHAR szDeviceId[] = {'s','z','D','e','v','i','c','e','I','d',0};
476 static const WCHAR szDeviceIdentifier[] = {'s','z','D','e','v','i','c','e','I','d','e','n','t','i','f','i','e','r',0};
477 static const WCHAR dwWidth[] = {'d','w','W','i','d','t','h',0};
478 static const WCHAR dwHeight[] = {'d','w','H','e','i','g','h','t',0};
479 static const WCHAR dwBpp[] = {'d','w','B','p','p',0};
480 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};
481 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};
483 static const WCHAR szAdapterID[] = {'0',0};
484 static const WCHAR szEmpty[] = {0};
487 IDxDiagContainer *pDisplayAdapterSubCont = NULL;
489 IDirectDraw7 *pDirectDraw;
491 DISPLAY_DEVICEW disp_dev;
492 DDSURFACEDESC2 surface_descr;
496 hr = DXDiag_CreateDXDiagContainer( &IID_IDxDiagContainer, (void**) &pDisplayAdapterSubCont );
497 if (FAILED( hr )) return hr;
498 hr = IDxDiagContainerImpl_AddChildContainer( pSubCont, szAdapterID, pDisplayAdapterSubCont );
499 if (FAILED( hr )) return hr;
501 disp_dev.cb = sizeof(disp_dev);
502 if (EnumDisplayDevicesW( NULL, 0, &disp_dev, 0 ))
504 add_prop_str( pDisplayAdapterSubCont, szDeviceName, disp_dev.DeviceName );
505 add_prop_str( pDisplayAdapterSubCont, szDescription, disp_dev.DeviceString );
508 hr = DirectDrawCreateEx( NULL, (LPVOID *)&pDirectDraw, &IID_IDirectDraw7, NULL);
509 if (FAILED( hr )) return hr;
511 dd_caps.dwCaps = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
512 dd_caps.dwCaps2 = dd_caps.dwCaps3 = dd_caps.dwCaps4 = 0;
513 hr = IDirectDraw7_GetAvailableVidMem( pDirectDraw, &dd_caps, &tmp, NULL );
516 static const WCHAR mem_fmt[] = {'%','.','1','f',' ','M','B',0};
518 snprintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), mem_fmt, ((float)tmp) / 1000000.0 );
519 add_prop_str( pDisplayAdapterSubCont, szDisplayMemoryLocalized, buffer );
520 add_prop_str( pDisplayAdapterSubCont, szDisplayMemoryEnglish, buffer );
523 surface_descr.dwSize = sizeof(surface_descr);
524 hr = IDirectDraw7_GetDisplayMode( pDirectDraw, &surface_descr );
527 if (surface_descr.dwFlags & DDSD_WIDTH)
528 add_prop_ui4( pDisplayAdapterSubCont, dwWidth, surface_descr.dwWidth );
529 if (surface_descr.dwFlags & DDSD_HEIGHT)
530 add_prop_ui4( pDisplayAdapterSubCont, dwHeight, surface_descr.dwHeight );
531 if (surface_descr.dwFlags & DDSD_PIXELFORMAT)
532 add_prop_ui4( pDisplayAdapterSubCont, dwBpp, surface_descr.u4.ddpfPixelFormat.u1.dwRGBBitCount );
535 get_display_device_id( buffer );
536 add_prop_str( pDisplayAdapterSubCont, szDeviceIdentifier, buffer );
538 add_prop_str( pDisplayAdapterSubCont, szVendorId, szEmpty );
539 add_prop_str( pDisplayAdapterSubCont, szDeviceId, szEmpty );
540 add_prop_str( pDisplayAdapterSubCont, szKeyDeviceKey, szEmpty );
541 add_prop_str( pDisplayAdapterSubCont, szKeyDeviceID, szEmpty );
543 IUnknown_Release( pDirectDraw );
547 static HRESULT DXDiag_InitDXDiagDirectSoundContainer(IDxDiagContainer* pSubCont) {
549 static const WCHAR DxDiag_SoundDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
550 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};
551 IDxDiagContainer* pSubSubCont = NULL;
553 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubSubCont);
554 if (FAILED(hr)) { return hr; }
555 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, DxDiag_SoundDevices, pSubSubCont);
557 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubSubCont);
558 if (FAILED(hr)) { return hr; }
559 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, DxDiag_SoundCaptureDevices, pSubSubCont);
564 static HRESULT DXDiag_InitDXDiagDirectMusicContainer(IDxDiagContainer* pSubCont) {
569 static HRESULT DXDiag_InitDXDiagDirectInputContainer(IDxDiagContainer* pSubCont) {
574 static HRESULT DXDiag_InitDXDiagDirectPlayContainer(IDxDiagContainer* pSubCont) {
579 static HRESULT DXDiag_InitDXDiagDirectShowFiltersContainer(IDxDiagContainer* pSubCont) {
581 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
582 static const WCHAR szVersionW[] = {'s','z','V','e','r','s','i','o','n',0};
583 static const WCHAR szCatName[] = {'s','z','C','a','t','N','a','m','e',0};
584 static const WCHAR ClsidCatW[] = {'C','l','s','i','d','C','a','t',0};
585 static const WCHAR ClsidFilterW[] = {'C','l','s','i','d','F','i','l','t','e','r',0};
586 static const WCHAR dwInputs[] = {'d','w','I','n','p','u','t','s',0};
587 static const WCHAR dwOutputs[] = {'d','w','O','u','t','p','u','t','s',0};
588 static const WCHAR dwMeritW[] = {'d','w','M','e','r','i','t',0};
590 static const WCHAR szFileName[] = {'s','z','F','i','l','e','N','a','m','e',0};
591 static const WCHAR szFileVersion[] = {'s','z','F','i','l','e','V','e','r','s','i','o','n',0};
595 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
596 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
597 static const WCHAR wszFilterDataName[] = {'F','i','l','t','e','r','D','a','t','a',0};
599 static const WCHAR szVersionFormat[] = {'v','%','d',0};
600 static const WCHAR szIdFormat[] = {'%','d',0};
604 ICreateDevEnum* pCreateDevEnum = NULL;
605 IEnumMoniker* pEmCat = NULL;
606 IMoniker* pMCat = NULL;
608 hr = CoCreateInstance(&CLSID_SystemDeviceEnum,
610 CLSCTX_INPROC_SERVER,
612 (void**) &pCreateDevEnum);
613 if (FAILED(hr)) return hr;
615 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &CLSID_ActiveMovieCategories, &pEmCat, 0);
616 if (FAILED(hr)) goto out_show_filters;
620 while (S_OK == IEnumMoniker_Next(pEmCat, 1, &pMCat, NULL)) {
621 IPropertyBag* pPropBag = NULL;
623 hr = IMoniker_BindToStorage(pMCat, NULL, NULL, &IID_IPropertyBag, (void**) &pPropBag);
625 WCHAR* wszCatName = NULL;
626 WCHAR* wszCatClsid = NULL;
628 hr = IPropertyBag_Read(pPropBag, wszFriendlyName, &v, 0);
629 wszCatName = SysAllocString(V_BSTR(&v));
632 hr = IPropertyBag_Read(pPropBag, wszClsidName, &v, 0);
633 wszCatClsid = SysAllocString(V_BSTR(&v));
634 hr = CLSIDFromString(V_UNION(&v, bstrVal), &clsidCat);
638 hr = IPropertyBag_Read(pPropBag, wszMeritName, &v, 0);
639 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwMerit, &v);
644 IEnumMoniker* pEnum = NULL;
645 IMoniker* pMoniker = NULL;
646 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &clsidCat, &pEnum, 0);
647 TRACE("\tClassEnumerator for clsid(%s) pEnum(%p)\n", debugstr_guid(&clsidCat), pEnum);
648 if (FAILED(hr) || pEnum == NULL) {
649 goto class_enum_failed;
651 while (NULL != pEnum && S_OK == IEnumMoniker_Next(pEnum, 1, &pMoniker, NULL)) {
652 IPropertyBag* pPropFilterBag = NULL;
653 TRACE("\tIEnumMoniker_Next(%p, 1, %p)\n", pEnum, pMoniker);
654 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (void**) &pPropFilterBag);
657 DWORD dwNOutputs = 0;
661 IDxDiagContainer *pDShowSubCont = NULL;
662 IFilterMapper2 *pFileMapper = NULL;
663 IAMFilterData *pFilterData = NULL;
665 snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szIdFormat, i);
666 if (FAILED(DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDShowSubCont)) ||
667 FAILED(IDxDiagContainerImpl_AddChildContainer(pSubCont, bufferW, pDShowSubCont)))
669 IPropertyBag_Release(pPropFilterBag);
670 if (pDShowSubCont) IUnknown_Release(pDShowSubCont);
675 hr = IPropertyBag_Read(pPropFilterBag, wszFriendlyName, &v, 0);
676 hr = IDxDiagContainerImpl_AddProp(pDShowSubCont, szName, &v);
677 TRACE("\tName:%s\n", debugstr_w(V_BSTR(&v)));
680 hr = IPropertyBag_Read(pPropFilterBag, wszClsidName, &v, 0);
681 TRACE("\tClsid:%s\n", debugstr_w(V_BSTR(&v)));
682 hr = IDxDiagContainerImpl_AddProp(pDShowSubCont, ClsidFilterW, &v);
685 hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC, &IID_IFilterMapper2,
686 (LPVOID*)&pFileMapper);
688 SUCCEEDED(IFilterMapper2_QueryInterface(pFileMapper, &IID_IAMFilterData, (void **)&pFilterData)))
692 REGFILTER2 *pRF = NULL;
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, &tmp)))
702 pRF = ((REGFILTER2 **)tmp)[0];
704 snprintfW(bufferW, sizeof(bufferW)/sizeof(bufferW[0]), szVersionFormat, pRF->dwVersion);
705 if (pRF->dwVersion == 1)
707 for (j = 0; j < pRF->u.s.cPins; j++)
708 if (pRF->u.s.rgPins[j].bOutput)
713 else if (pRF->dwVersion == 2)
715 for (j = 0; j < pRF->u.s1.cPins2; j++)
716 if (pRF->u.s1.rgPins2[j].dwFlags & REG_PINFLAG_B_OUTPUT)
722 dwMerit = pRF->dwMerit;
726 SafeArrayUnaccessData(V_UNION(&v, parray));
729 IFilterMapper2_Release(pFilterData);
731 if (pFileMapper) IFilterMapper2_Release(pFileMapper);
733 add_prop_str(pDShowSubCont, szVersionW, bufferW);
734 add_prop_str(pDShowSubCont, szCatName, wszCatName);
735 add_prop_str(pDShowSubCont, ClsidCatW, wszCatClsid);
736 add_prop_ui4(pDShowSubCont, dwInputs, dwNInputs);
737 add_prop_ui4(pDShowSubCont, dwOutputs, dwNOutputs);
738 add_prop_ui4(pDShowSubCont, dwMeritW, dwMerit);
742 IPropertyBag_Release(pPropFilterBag); pPropFilterBag = NULL;
744 IEnumMoniker_Release(pEnum); pEnum = NULL;
747 SysFreeString(wszCatName);
748 SysFreeString(wszCatClsid);
749 IPropertyBag_Release(pPropBag); pPropBag = NULL;
751 IEnumMoniker_Release(pMCat); pMCat = NULL;
755 if (NULL != pEmCat) { IEnumMoniker_Release(pEmCat); pEmCat = NULL; }
756 if (NULL != pCreateDevEnum) { ICreateDevEnum_Release(pCreateDevEnum); pCreateDevEnum = NULL; }
760 static HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont) {
762 static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
763 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};
764 static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
765 static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
766 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};
767 static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
768 static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
769 static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
770 static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
771 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};
772 IDxDiagContainer* pSubCont = NULL;
774 TRACE("(%p)\n", pRootCont);
776 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
777 if (FAILED(hr)) { return hr; }
778 hr = DXDiag_InitDXDiagSystemInfoContainer(pSubCont);
779 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemInfo, pSubCont);
781 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
782 if (FAILED(hr)) { return hr; }
783 hr = DXDiag_InitDXDiagSystemDevicesContainer(pSubCont);
784 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemDevices, pSubCont);
786 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
787 if (FAILED(hr)) { return hr; }
788 hr = DXDiag_InitDXDiagLogicalDisksContainer(pSubCont);
789 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_LogicalDisks, pSubCont);
791 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
792 if (FAILED(hr)) { return hr; }
793 hr = DXDiag_InitDXDiagDirectXFilesContainer(pSubCont);
794 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectXFiles, pSubCont);
796 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
797 if (FAILED(hr)) { return hr; }
798 hr = DXDiag_InitDXDiagDisplayContainer(pSubCont);
799 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DisplayDevices, pSubCont);
801 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
802 if (FAILED(hr)) { return hr; }
803 hr = DXDiag_InitDXDiagDirectSoundContainer(pSubCont);
804 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectSound, pSubCont);
806 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
807 if (FAILED(hr)) { return hr; }
808 hr = DXDiag_InitDXDiagDirectMusicContainer(pSubCont);
809 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectMusic, pSubCont);
811 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
812 if (FAILED(hr)) { return hr; }
813 hr = DXDiag_InitDXDiagDirectInputContainer(pSubCont);
814 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectInput, pSubCont);
816 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
817 if (FAILED(hr)) { return hr; }
818 hr = DXDiag_InitDXDiagDirectPlayContainer(pSubCont);
819 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectPlay, pSubCont);
821 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
822 if (FAILED(hr)) { return hr; }
823 hr = DXDiag_InitDXDiagDirectShowFiltersContainer(pSubCont);
824 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectShowFilters, pSubCont);