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
23 #include "wine/debug.h"
26 #include "dxdiag_private.h"
27 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag
);
38 /* IDxDiagProvider IUnknown parts follow: */
39 static HRESULT WINAPI
IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface
, REFIID riid
, LPVOID
*ppobj
)
41 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
43 if (IsEqualGUID(riid
, &IID_IUnknown
)
44 || IsEqualGUID(riid
, &IID_IDxDiagProvider
)) {
45 IUnknown_AddRef(iface
);
50 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
54 static ULONG WINAPI
IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface
) {
55 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
56 ULONG refCount
= InterlockedIncrement(&This
->ref
);
58 TRACE("(%p)->(ref before=%u)\n", This
, refCount
- 1);
65 static ULONG WINAPI
IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface
) {
66 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
67 ULONG refCount
= InterlockedDecrement(&This
->ref
);
69 TRACE("(%p)->(ref before=%u)\n", This
, refCount
+ 1);
72 HeapFree(GetProcessHeap(), 0, This
);
75 DXDIAGN_UnlockModule();
80 /* IDxDiagProvider Interface follow: */
81 static HRESULT WINAPI
IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface
, DXDIAG_INIT_PARAMS
* pParams
) {
82 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
83 TRACE("(%p,%p)\n", iface
, pParams
);
85 if (NULL
== pParams
) {
88 if (pParams
->dwSize
!= sizeof(DXDIAG_INIT_PARAMS
)) {
93 memcpy(&This
->params
, pParams
, pParams
->dwSize
);
97 static HRESULT WINAPI
IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface
, IDxDiagContainer
** ppInstance
) {
99 IDxDiagProviderImpl
*This
= (IDxDiagProviderImpl
*)iface
;
100 TRACE("(%p,%p)\n", iface
, ppInstance
);
102 if (NULL
== ppInstance
) {
105 if (FALSE
== This
->init
) {
106 return E_INVALIDARG
; /* should be E_CO_UNINITIALIZED */
108 if (NULL
== This
->pRootContainer
) {
109 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &This
->pRootContainer
);
113 hr
= DXDiag_InitRootDXDiagContainer((PDXDIAGCONTAINER
)This
->pRootContainer
);
115 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER
)This
->pRootContainer
, &IID_IDxDiagContainer
, (void**) ppInstance
);
118 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl
=
120 IDxDiagProviderImpl_QueryInterface
,
121 IDxDiagProviderImpl_AddRef
,
122 IDxDiagProviderImpl_Release
,
123 IDxDiagProviderImpl_Initialize
,
124 IDxDiagProviderImpl_GetRootContainer
127 HRESULT
DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface
, LPUNKNOWN punkOuter
, REFIID riid
, LPVOID
*ppobj
) {
128 IDxDiagProviderImpl
* provider
;
130 TRACE("(%p, %s, %p)\n", punkOuter
, debugstr_guid(riid
), ppobj
);
132 provider
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDxDiagProviderImpl
));
133 if (NULL
== provider
) {
135 return E_OUTOFMEMORY
;
137 provider
->lpVtbl
= &DxDiagProvider_Vtbl
;
138 provider
->ref
= 0; /* will be inited with QueryInterface */
139 return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER
)provider
, riid
, ppobj
);
142 static inline HRESULT
add_prop_str( IDxDiagContainer
* cont
, LPCWSTR prop
, LPCWSTR str
)
147 V_VT( &var
) = VT_BSTR
;
148 V_BSTR( &var
) = SysAllocString( str
);
149 hr
= IDxDiagContainerImpl_AddProp( cont
, prop
, &var
);
150 VariantClear( &var
);
155 static inline HRESULT
add_prop_ui4( IDxDiagContainer
* cont
, LPCWSTR prop
, DWORD data
)
160 V_VT( &var
) = VT_UI4
;
161 V_UI4( &var
) = data
;
162 hr
= IDxDiagContainerImpl_AddProp( cont
, prop
, &var
);
163 VariantClear( &var
);
169 * @param szFilePath: usually GetSystemDirectoryW
170 * @param szFileName: name of the dll without path
172 static HRESULT
DXDiag_AddFileDescContainer(IDxDiagContainer
* pSubCont
, const WCHAR
* szFilePath
, const WCHAR
* szFileName
) {
175 static const WCHAR szSlashSep
[] = {'\\',0};
176 static const WCHAR szPath
[] = {'s','z','P','a','t','h',0};
177 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
178 static const WCHAR szVersion
[] = {'s','z','V','e','r','s','i','o','n',0};
179 static const WCHAR szAttributes
[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
180 static const WCHAR szLanguageEnglish
[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
181 static const WCHAR dwFileTimeHigh
[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
182 static const WCHAR dwFileTimeLow
[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
183 static const WCHAR bBeta
[] = {'b','B','e','t','a',0};
184 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
185 static const WCHAR bExists
[] = {'b','E','x','i','s','t','s',0};
187 static const WCHAR szFinal_Retail_v
[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
188 static const WCHAR szEnglish_v
[] = {'E','n','g','l','i','s','h',0};
189 static const WCHAR szVersionFormat
[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
193 WCHAR szVersion_v
[1024];
198 VS_FIXEDFILEINFO
* pFileInfo
;
200 FIXME("(%p,%s)\n", pSubCont
, debugstr_w(szFileName
));
202 lstrcpyW(szFile
, szFilePath
);
203 lstrcatW(szFile
, szSlashSep
);
204 lstrcatW(szFile
, szFileName
);
206 retval
= GetFileVersionInfoSizeW(szFile
, &hdl
);
207 pVersionInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, retval
);
208 hr
= GetFileVersionInfoW(szFile
, 0, retval
, pVersionInfo
);
209 boolret
= VerQueryValueW(pVersionInfo
, szSlashSep
, (LPVOID
) &pFileInfo
, &uiLength
);
211 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szFile
);
212 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szPath
, &v
);
214 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szFileName
);
215 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szName
, &v
);
217 V_VT(&v
) = VT_BOOL
; V_BOOL(&v
) = boolret
;
218 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, bExists
, &v
);
222 snprintfW(szVersion_v
, sizeof(szVersion_v
),
224 HIWORD(pFileInfo
->dwFileVersionMS
),
225 LOWORD(pFileInfo
->dwFileVersionMS
),
226 HIWORD(pFileInfo
->dwFileVersionLS
),
227 LOWORD(pFileInfo
->dwFileVersionLS
));
229 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v
));
231 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szVersion_v
);
232 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szVersion
, &v
);
234 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szFinal_Retail_v
);
235 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szAttributes
, &v
);
237 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szEnglish_v
);
238 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szLanguageEnglish
, &v
);
240 V_VT(&v
) = VT_UI4
; V_UI4(&v
) = pFileInfo
->dwFileDateMS
;
241 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwFileTimeHigh
, &v
);
243 V_VT(&v
) = VT_UI4
; V_UI4(&v
) = pFileInfo
->dwFileDateLS
;
244 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwFileTimeLow
, &v
);
246 V_VT(&v
) = VT_BOOL
; V_BOOL(&v
) = (0 != ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_PRERELEASE
));
247 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, bBeta
, &v
);
249 V_VT(&v
) = VT_BOOL
; V_BOOL(&v
) = (0 != ((pFileInfo
->dwFileFlags
& pFileInfo
->dwFileFlagsMask
) & VS_FF_DEBUG
));
250 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, bDebug
, &v
);
254 HeapFree(GetProcessHeap(), 0, pVersionInfo
);
259 static HRESULT
DXDiag_InitDXDiagSystemInfoContainer(IDxDiagContainer
* pSubCont
) {
261 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};
262 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};
263 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};
264 static const WCHAR szDirectXVersionLetter_v
[] = {'c',0};
265 static const WCHAR bDebug
[] = {'b','D','e','b','u','g',0};
266 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};
267 static const WCHAR szDirectXVersionEnglish_v
[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
268 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};
269 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};
270 /*static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};*/
273 /*"dwOSMajorVersion"*/
274 /*"dwOSMinorVersion"*/
275 /*"dwOSBuildNumber"*/
279 V_VT(&v
) = VT_UI4
; V_UI4(&v
) = 9;
280 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwDirectXVersionMajor
, &v
);
282 V_VT(&v
) = VT_UI4
; V_UI4(&v
) = 0;
283 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwDirectXVersionMinor
, &v
);
285 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szDirectXVersionLetter_v
);
286 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szDirectXVersionLetter
, &v
);
288 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szDirectXVersionEnglish_v
);
289 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szDirectXVersionEnglish
, &v
);
291 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(szDirectXVersionLongEnglish_v
);
292 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szDirectXVersionLongEnglish
, &v
);
294 V_VT(&v
) = VT_BOOL
; V_BOOL(&v
) = FALSE
;
295 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, bDebug
, &v
);
301 static HRESULT
DXDiag_InitDXDiagSystemDevicesContainer(IDxDiagContainer
* pSubCont
) {
304 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
305 static const WCHAR szDeviceID[] = {'s','z','D','e','v','i','c','e','I','D',0};
307 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
310 IDxDiagContainer* pDeviceSubCont = NULL;
311 IDxDiagContainer* pDriversCont = NULL;
313 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDeviceSubCont);
314 if (FAILED(hr)) { return hr; }
315 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
316 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDescription, &v);
318 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
319 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDeviceID, &v);
322 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "", pDeviceSubCont);
326 * Drivers Cont contains Files Desc Containers
329 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDriversCont);
330 if (FAILED(hr)) { return hr; }
331 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
337 static HRESULT
DXDiag_InitDXDiagLogicalDisksContainer(IDxDiagContainer
* pSubCont
) {
340 static const WCHAR szDriveLetter[] = {'s','z','D','r','i','v','e','L','e','t','t','e','r',0};
341 static const WCHAR szFreeSpace[] = {'s','z','F','r','e','e','S','p','a','c','e',0};
342 static const WCHAR szMaxSpace[] = {'s','z','M','a','x','S','p','a','c','e',0};
343 static const WCHAR szFileSystem[] = {'s','z','F','i','l','e','S','y','s','t','e','m',0};
344 static const WCHAR szModel[] = {'s','z','M','o','d','e','l',0};
345 static const WCHAR szPNPDeviceID[] = {'s','z','P','N','P','D','e','v','i','c','e','I','D',0};
346 static const WCHAR dwHardDriveIndex[] = {'d','w','H','a','r','d','D','r','i','v','e','I','n','d','e','x',0};
348 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
351 IDxDiagContainer* pDiskSubCont = NULL;
352 IDxDiagContainer* pDriversCont = NULL;
354 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDiskSubCont);
355 if (FAILED(hr)) { return hr; }
356 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "" , pDiskSubCont);
360 * Drivers Cont contains Files Desc Containers
363 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDriversCont);
364 if (FAILED(hr)) { return hr; }
365 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
369 static HRESULT
DXDiag_InitDXDiagDirectXFilesContainer(IDxDiagContainer
* pSubCont
) {
372 static const WCHAR ddraw_dll
[] = {'d','d','r','a','w','.','d','l','l',0};
373 static const WCHAR dplayx_dll
[] = {'d','p','l','a','y','x','.','d','l','l',0};
374 static const WCHAR dpnet_dll
[] = {'d','p','n','e','t','.','d','l','l',0};
375 static const WCHAR dinput_dll
[] = {'d','i','n','p','u','t','.','d','l','l',0};
376 static const WCHAR dinput8_dll
[] = {'d','i','n','p','u','t','8','.','d','l','l',0};
377 static const WCHAR dsound_dll
[] = {'d','s','o','u','n','d','.','d','l','l',0};
378 static const WCHAR dswave_dll
[] = {'d','s','w','a','v','e','.','d','l','l',0};
379 static const WCHAR d3d8_dll
[] = {'d','3','d','8','.','d','l','l',0};
380 static const WCHAR d3d9_dll
[] = {'d','3','d','9','.','d','l','l',0};
381 static const WCHAR dmband_dll
[] = {'d','m','b','a','n','d','.','d','l','l',0};
382 static const WCHAR dmcompos_dll
[] = {'d','m','c','o','m','p','o','s','.','d','l','l',0};
383 static const WCHAR dmime_dll
[] = {'d','m','i','m','e','.','d','l','l',0};
384 static const WCHAR dmloader_dll
[] = {'d','m','l','o','a','d','e','r','.','d','l','l',0};
385 static const WCHAR dmscript_dll
[] = {'d','m','s','c','r','i','p','t','.','d','l','l',0};
386 static const WCHAR dmstyle_dll
[] = {'d','m','s','t','y','l','e','.','d','l','l',0};
387 static const WCHAR dmsynth_dll
[] = {'d','m','s','y','n','t','h','.','d','l','l',0};
388 static const WCHAR dmusic_dll
[] = {'d','m','u','s','i','c','.','d','l','l',0};
389 static const WCHAR devenum_dll
[] = {'d','e','v','e','n','u','m','.','d','l','l',0};
390 static const WCHAR quartz_dll
[] = {'q','u','a','r','t','z','.','d','l','l',0};
391 WCHAR szFilePath
[512];
393 hr
= GetSystemDirectoryW(szFilePath
, MAX_PATH
);
394 if (FAILED(hr
)) { return hr
; }
395 szFilePath
[MAX_PATH
-1]=0;
397 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, ddraw_dll
);
398 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dplayx_dll
);
399 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dpnet_dll
);
400 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dinput_dll
);
401 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dinput8_dll
);
402 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dsound_dll
);
403 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dswave_dll
);
404 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, d3d8_dll
);
405 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, d3d9_dll
);
406 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmband_dll
);
407 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmcompos_dll
);
408 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmime_dll
);
409 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmloader_dll
);
410 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmscript_dll
);
411 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmstyle_dll
);
412 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmsynth_dll
);
413 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, dmusic_dll
);
414 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, devenum_dll
);
415 hr
= DXDiag_AddFileDescContainer(pSubCont
, szFilePath
, quartz_dll
);
419 static HRESULT
DXDiag_InitDXDiagDisplayContainer(IDxDiagContainer
* pSubCont
)
421 static const WCHAR szDescription
[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
422 static const WCHAR szDeviceName
[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
423 static const WCHAR szKeyDeviceID
[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
424 static const WCHAR szKeyDeviceKey
[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
425 static const WCHAR szVendorId
[] = {'s','z','V','e','n','d','o','r','I','d',0};
426 static const WCHAR szDeviceId
[] = {'s','z','D','e','v','i','c','e','I','d',0};
427 static const WCHAR dwWidth
[] = {'d','w','W','i','d','t','h',0};
428 static const WCHAR dwHeight
[] = {'d','w','H','e','i','g','h','t',0};
429 static const WCHAR dwBpp
[] = {'d','w','B','p','p',0};
430 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};
431 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};
433 static const WCHAR szAdapterID
[] = {'0',0};
434 static const WCHAR szEmpty
[] = {0};
437 IDxDiagContainer
*pDisplayAdapterSubCont
= NULL
;
439 IDirectDraw7
*pDirectDraw
;
441 DISPLAY_DEVICEW disp_dev
;
442 DDSURFACEDESC2 surface_descr
;
446 hr
= DXDiag_CreateDXDiagContainer( &IID_IDxDiagContainer
, (void**) &pDisplayAdapterSubCont
);
447 if (FAILED( hr
)) return hr
;
448 hr
= IDxDiagContainerImpl_AddChildContainer( pSubCont
, szAdapterID
, pDisplayAdapterSubCont
);
449 if (FAILED( hr
)) return hr
;
451 if (EnumDisplayDevicesW( NULL
, 0, &disp_dev
, 0 ))
453 add_prop_str( pDisplayAdapterSubCont
, szDeviceName
, disp_dev
.DeviceName
);
454 add_prop_str( pDisplayAdapterSubCont
, szDescription
, disp_dev
.DeviceString
);
457 hr
= DirectDrawCreateEx( NULL
, (LPVOID
*)&pDirectDraw
, &IID_IDirectDraw7
, NULL
);
458 if (FAILED( hr
)) return hr
;
460 dd_caps
.dwCaps
= DDSCAPS_LOCALVIDMEM
| DDSCAPS_VIDEOMEMORY
;
461 dd_caps
.dwCaps2
= dd_caps
.dwCaps3
= dd_caps
.dwCaps4
= 0;
462 hr
= IDirectDraw7_GetAvailableVidMem( pDirectDraw
, &dd_caps
, &tmp
, NULL
);
465 static const WCHAR mem_fmt
[] = {'%','.','1','f',' ','M','B',0};
467 snprintfW( buffer
, sizeof(buffer
), mem_fmt
, ((float)tmp
) / 1000000.0 );
468 add_prop_str( pDisplayAdapterSubCont
, szDisplayMemoryLocalized
, buffer
);
469 add_prop_str( pDisplayAdapterSubCont
, szDisplayMemoryEnglish
, buffer
);
472 surface_descr
.dwSize
= sizeof(surface_descr
);
473 hr
= IDirectDraw7_GetDisplayMode( pDirectDraw
, &surface_descr
);
476 if (surface_descr
.dwFlags
& DDSD_WIDTH
)
477 add_prop_ui4( pDisplayAdapterSubCont
, dwWidth
, surface_descr
.dwWidth
);
478 if (surface_descr
.dwFlags
& DDSD_HEIGHT
)
479 add_prop_ui4( pDisplayAdapterSubCont
, dwHeight
, surface_descr
.dwHeight
);
480 if (surface_descr
.dwFlags
& DDSD_PIXELFORMAT
)
481 add_prop_ui4( pDisplayAdapterSubCont
, dwBpp
, surface_descr
.ddpfPixelFormat
.dwRGBBitCount
);
484 add_prop_str( pDisplayAdapterSubCont
, szVendorId
, szEmpty
);
485 add_prop_str( pDisplayAdapterSubCont
, szDeviceId
, szEmpty
);
486 add_prop_str( pDisplayAdapterSubCont
, szKeyDeviceKey
, szEmpty
);
487 add_prop_str( pDisplayAdapterSubCont
, szKeyDeviceID
, szEmpty
);
489 IUnknown_Release( pDirectDraw
);
493 static HRESULT
DXDiag_InitDXDiagDirectSoundContainer(IDxDiagContainer
* pSubCont
) {
495 static const WCHAR DxDiag_SoundDevices
[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
496 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};
497 IDxDiagContainer
* pSubSubCont
= NULL
;
499 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubSubCont
);
500 if (FAILED(hr
)) { return hr
; }
501 hr
= IDxDiagContainerImpl_AddChildContainer(pSubCont
, DxDiag_SoundDevices
, pSubSubCont
);
503 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubSubCont
);
504 if (FAILED(hr
)) { return hr
; }
505 hr
= IDxDiagContainerImpl_AddChildContainer(pSubCont
, DxDiag_SoundCaptureDevices
, pSubSubCont
);
510 static HRESULT
DXDiag_InitDXDiagDirectMusicContainer(IDxDiagContainer
* pSubCont
) {
515 static HRESULT
DXDiag_InitDXDiagDirectInputContainer(IDxDiagContainer
* pSubCont
) {
520 static HRESULT
DXDiag_InitDXDiagDirectPlayContainer(IDxDiagContainer
* pSubCont
) {
532 BYTE signature
[4]; /* e.g. "0pi3" */
537 DWORD bCategory
; /* is there a category clsid? */
538 /* optional: dwOffsetCategoryClsid */
541 BYTE signature
[4]; /* e.g. "0ty3" */
547 static HRESULT
DXDiag_InitDXDiagDirectShowFiltersContainer(IDxDiagContainer
* pSubCont
) {
549 static const WCHAR szName
[] = {'s','z','N','a','m','e',0};
550 static const WCHAR szCatName
[] = {'s','z','C','a','t','N','a','m','e',0};
551 static const WCHAR szClsidCat
[] = {'s','z','C','l','s','i','d','C','a','t',0};
552 static const WCHAR szClsidFilter
[] = {'s','z','C','l','s','i','d','F','i','l','t','e','r',0};
553 static const WCHAR dwInputs
[] = {'d','w','I','n','p','u','t','s',0};
554 static const WCHAR dwOutputs
[] = {'d','w','O','u','t','p','u','t','s',0};
555 static const WCHAR dwMerit
[] = {'d','w','M','e','r','i','t',0};
557 static const WCHAR szFileName[] = {'s','z','F','i','l','e','N','a','m','e',0};
558 static const WCHAR szFileVersion[] = {'s','z','F','i','l','e','V','e','r','s','i','o','n',0};
562 static const WCHAR wszClsidName
[] = {'C','L','S','I','D',0};
563 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
564 static const WCHAR wszFilterDataName
[] = {'F','i','l','t','e','r','D','a','t','a',0};
565 /*static const WCHAR wszMeritName[] = {'M','e','r','i','t',0};*/
567 ICreateDevEnum
* pCreateDevEnum
= NULL
;
568 IEnumMoniker
* pEmCat
= NULL
;
569 IMoniker
* pMCat
= NULL
;
571 hr
= CoCreateInstance(&CLSID_SystemDeviceEnum
,
573 CLSCTX_INPROC_SERVER
,
575 (void**) &pCreateDevEnum
);
576 if (FAILED(hr
)) return hr
;
578 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &CLSID_ActiveMovieCategories
, &pEmCat
, 0);
579 if (FAILED(hr
)) goto out_show_filters
;
583 while (S_OK
== IEnumMoniker_Next(pEmCat
, 1, &pMCat
, NULL
)) {
584 IPropertyBag
* pPropBag
= NULL
;
586 hr
= IMoniker_BindToStorage(pMCat
, NULL
, NULL
, &IID_IPropertyBag
, (void**) &pPropBag
);
588 WCHAR
* wszCatName
= NULL
;
589 WCHAR
* wszCatClsid
= NULL
;
591 hr
= IPropertyBag_Read(pPropBag
, wszFriendlyName
, &v
, 0);
592 wszCatName
= SysAllocString(V_BSTR(&v
));
595 hr
= IPropertyBag_Read(pPropBag
, wszClsidName
, &v
, 0);
596 wszCatClsid
= SysAllocString(V_BSTR(&v
));
597 hr
= CLSIDFromString(V_UNION(&v
, bstrVal
), &clsidCat
);
601 hr = IPropertyBag_Read(pPropBag, wszMeritName, &v, 0);
602 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwMerit, &v);
607 IEnumMoniker
* pEnum
= NULL
;
608 IMoniker
* pMoniker
= NULL
;
609 hr
= ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum
, &clsidCat
, &pEnum
, 0);
610 FIXME("\tClassEnumerator for clsid(%s) pEnum(%p)\n", debugstr_guid(&clsidCat
), pEnum
);
611 if (FAILED(hr
) || pEnum
== NULL
) {
612 goto class_enum_failed
;
614 while (NULL
!= pEnum
&& S_OK
== IEnumMoniker_Next(pEnum
, 1, &pMoniker
, NULL
)) {
615 IPropertyBag
* pPropFilterBag
= NULL
;
616 FIXME("\tIEnumMoniker_Next(%p, 1, %p)\n", pEnum
, pMoniker
);
617 hr
= IMoniker_BindToStorage(pMoniker
, NULL
, NULL
, &IID_IPropertyBag
, (void**) &pPropFilterBag
);
620 LPBYTE pCurrent
= NULL
;
621 struct REG_RF
* prrf
= NULL
;
624 DWORD dwNOutputs
= 0;
627 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(wszCatName
);
628 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szCatName
, &v
);
631 V_VT(&v
) = VT_BSTR
; V_BSTR(&v
) = SysAllocString(wszCatClsid
);
632 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szClsidCat
, &v
);
635 hr
= IPropertyBag_Read(pPropFilterBag
, wszFriendlyName
, &v
, 0);
636 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szName
, &v
);
637 FIXME("\tName:%s\n", debugstr_w(V_BSTR(&v
)));
640 hr
= IPropertyBag_Read(pPropFilterBag
, wszClsidName
, &v
, 0);
641 FIXME("\tClsid:%s\n", debugstr_w(V_BSTR(&v
)));
642 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szClsidFilter
, &v
);
645 hr
= IPropertyBag_Read(pPropFilterBag
, wszFilterDataName
, &v
, NULL
);
646 hr
= SafeArrayAccessData(V_UNION(&v
, parray
), (LPVOID
*) &pData
);
647 prrf
= (struct REG_RF
*) pData
;
650 VariantInit(&v_data
);
651 V_VT(&v_data
) = VT_UI4
; V_UI4(&v_data
) = prrf
->dwVersion
;
652 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, szName
, &v_data
);
653 VariantClear(&v_data
);
654 V_VT(&v_data
) = VT_UI4
; V_UI4(&v_data
) = prrf
->dwMerit
;
655 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwMerit
, &v_data
);
656 VariantClear(&v_data
);
658 pCurrent
+= sizeof(struct REG_RF
);
659 for (it
= 0; it
< prrf
->dwPins
; ++it
) {
660 struct REG_RFP
* prrfp
= (struct REG_RFP
*) pCurrent
;
663 if (prrfp
->dwFlags
& REG_PINFLAG_B_OUTPUT
) ++dwNOutputs
;
666 pCurrent
+= sizeof(struct REG_RFP
);
667 if (prrfp
->bCategory
) {
668 pCurrent
+= sizeof(DWORD
);
670 for (j
= 0; j
< prrfp
->dwMediaTypes
; ++j
) {
671 struct REG_TYPE
* prt
= (struct REG_TYPE
*)pCurrent
;
672 pCurrent
+= sizeof(*prt
);
674 for (j
= 0; j
< prrfp
->dwMediums
; ++j
) {
675 DWORD dwOffset
= *(DWORD
*) pCurrent
;
676 pCurrent
+= sizeof(dwOffset
);
680 V_VT(&v_data
) = VT_UI4
; V_UI4(&v_data
) = dwNInputs
;
681 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwInputs
, &v_data
);
682 VariantClear(&v_data
);
683 V_VT(&v_data
) = VT_UI4
; V_UI4(&v_data
) = dwNOutputs
;
684 hr
= IDxDiagContainerImpl_AddProp(pSubCont
, dwOutputs
, &v_data
);
685 VariantClear(&v_data
);
687 SafeArrayUnaccessData(V_UNION(&v
, parray
));
690 IPropertyBag_Release(pPropFilterBag
); pPropFilterBag
= NULL
;
692 IEnumMoniker_Release(pEnum
); pEnum
= NULL
;
695 SysFreeString(wszCatName
);
696 SysFreeString(wszCatClsid
);
697 IPropertyBag_Release(pPropBag
); pPropBag
= NULL
;
699 IEnumMoniker_Release(pMCat
); pMCat
= NULL
;
703 if (NULL
!= pEmCat
) { IEnumMoniker_Release(pEmCat
); pEmCat
= NULL
; }
704 if (NULL
!= pCreateDevEnum
) { ICreateDevEnum_Release(pCreateDevEnum
); pCreateDevEnum
= NULL
; }
708 HRESULT
DXDiag_InitRootDXDiagContainer(IDxDiagContainer
* pRootCont
) {
710 static const WCHAR DxDiag_SystemInfo
[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
711 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};
712 static const WCHAR DxDiag_LogicalDisks
[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
713 static const WCHAR DxDiag_DirectXFiles
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
714 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};
715 static const WCHAR DxDiag_DirectSound
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
716 static const WCHAR DxDiag_DirectMusic
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
717 static const WCHAR DxDiag_DirectInput
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
718 static const WCHAR DxDiag_DirectPlay
[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
719 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};
720 IDxDiagContainer
* pSubCont
= NULL
;
722 TRACE("(%p)\n", pRootCont
);
724 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
725 if (FAILED(hr
)) { return hr
; }
726 hr
= DXDiag_InitDXDiagSystemInfoContainer(pSubCont
);
727 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_SystemInfo
, pSubCont
);
729 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
730 if (FAILED(hr
)) { return hr
; }
731 hr
= DXDiag_InitDXDiagSystemDevicesContainer(pSubCont
);
732 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_SystemDevices
, pSubCont
);
734 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
735 if (FAILED(hr
)) { return hr
; }
736 hr
= DXDiag_InitDXDiagLogicalDisksContainer(pSubCont
);
737 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_LogicalDisks
, pSubCont
);
739 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
740 if (FAILED(hr
)) { return hr
; }
741 hr
= DXDiag_InitDXDiagDirectXFilesContainer(pSubCont
);
742 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectXFiles
, pSubCont
);
744 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
745 if (FAILED(hr
)) { return hr
; }
746 hr
= DXDiag_InitDXDiagDisplayContainer(pSubCont
);
747 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DisplayDevices
, pSubCont
);
749 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
750 if (FAILED(hr
)) { return hr
; }
751 hr
= DXDiag_InitDXDiagDirectSoundContainer(pSubCont
);
752 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectSound
, pSubCont
);
754 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
755 if (FAILED(hr
)) { return hr
; }
756 hr
= DXDiag_InitDXDiagDirectMusicContainer(pSubCont
);
757 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectMusic
, pSubCont
);
759 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
760 if (FAILED(hr
)) { return hr
; }
761 hr
= DXDiag_InitDXDiagDirectInputContainer(pSubCont
);
762 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectInput
, pSubCont
);
764 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
765 if (FAILED(hr
)) { return hr
; }
766 hr
= DXDiag_InitDXDiagDirectPlayContainer(pSubCont
);
767 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectPlay
, pSubCont
);
769 hr
= DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer
, (void**) &pSubCont
);
770 if (FAILED(hr
)) { return hr
; }
771 hr
= DXDiag_InitDXDiagDirectShowFiltersContainer(pSubCont
);
772 hr
= IDxDiagContainerImpl_AddChildContainer(pRootCont
, DxDiag_DirectShowFilters
, pSubCont
);