Call DisableThreadLibraryCalls for DLLs that don't need thread
[wine/hacks.git] / dlls / dxdiagn / provider.c
blob3b049ff1b8c2cbab47d740baa4d5078b6474099d
1 /*
2 * IDxDiagProvider Implementation
3 *
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "wine/debug.h"
25 #define COBJMACROS
26 #include "dxdiag_private.h"
27 #include "wine/unicode.h"
28 #include "winver.h"
29 #include "objidl.h"
30 #include "dshow.h"
31 #include "strmif.h"
32 #include "vfw.h"
33 #include "mmddk.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
37 /* IDxDiagProvider IUnknown parts follow: */
38 HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID riid, LPVOID *ppobj)
40 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
42 if (IsEqualGUID(riid, &IID_IUnknown)
43 || IsEqualGUID(riid, &IID_IDxDiagProvider)) {
44 IDxDiagProviderImpl_AddRef(iface);
45 *ppobj = This;
46 return S_OK;
49 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
50 return E_NOINTERFACE;
53 ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) {
54 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
55 ULONG refCount = InterlockedIncrement(&This->ref);
57 TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
59 DXDIAGN_LockModule();
61 return refCount;
64 ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) {
65 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
66 ULONG refCount = InterlockedDecrement(&This->ref);
68 TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1);
70 if (!refCount) {
71 HeapFree(GetProcessHeap(), 0, This);
74 DXDIAGN_UnlockModule();
76 return refCount;
79 /* IDxDiagProvider Interface follow: */
80 HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS* pParams) {
81 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
82 TRACE("(%p,%p)\n", iface, pParams);
84 if (NULL == pParams) {
85 return E_POINTER;
87 if (pParams->dwSize != sizeof(DXDIAG_INIT_PARAMS)) {
88 return E_INVALIDARG;
91 This->init = TRUE;
92 memcpy(&This->params, pParams, pParams->dwSize);
93 return S_OK;
96 HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
97 HRESULT hr = S_OK;
98 IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
99 TRACE("(%p,%p)\n", iface, ppInstance);
101 if (NULL == ppInstance) {
102 return E_INVALIDARG;
104 if (FALSE == This->init) {
105 return E_INVALIDARG; /* should be E_CO_UNINITIALIZED */
107 if (NULL == This->pRootContainer) {
108 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &This->pRootContainer);
109 if (FAILED(hr)) {
110 return hr;
112 hr = DXDiag_InitRootDXDiagContainer((PDXDIAGCONTAINER)This->pRootContainer);
114 return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance);
117 static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
119 IDxDiagProviderImpl_QueryInterface,
120 IDxDiagProviderImpl_AddRef,
121 IDxDiagProviderImpl_Release,
122 IDxDiagProviderImpl_Initialize,
123 IDxDiagProviderImpl_GetRootContainer
126 HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
127 IDxDiagProviderImpl* provider;
129 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
131 provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
132 if (NULL == provider) {
133 *ppobj = NULL;
134 return E_OUTOFMEMORY;
136 provider->lpVtbl = &DxDiagProvider_Vtbl;
137 provider->ref = 0; /* will be inited with QueryInterface */
138 return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER)provider, riid, ppobj);
142 * @param szFilePath: usually GetSystemDirectoryW
143 * @param szFileName: name of the dll without path
145 HRESULT DXDiag_AddFileDescContainer(IDxDiagContainer* pSubCont, const WCHAR* szFilePath, const WCHAR* szFileName) {
146 HRESULT hr = S_OK;
147 /**/
148 static const WCHAR szSlashSep[] = {'\\',0};
149 static const WCHAR szPath[] = {'s','z','P','a','t','h',0};
150 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
151 static const WCHAR szVersion[] = {'s','z','V','e','r','s','i','o','n',0};
152 static const WCHAR szAttributes[] = {'s','z','A','t','t','r','i','b','u','t','e','s',0};
153 static const WCHAR szLanguageEnglish[] = {'s','z','L','a','n','g','u','a','g','e','E','n','g','l','i','s','h',0};
154 static const WCHAR dwFileTimeHigh[] = {'d','w','F','i','l','e','T','i','m','e','H','i','g','h',0};
155 static const WCHAR dwFileTimeLow[] = {'d','w','F','i','l','e','T','i','m','e','L','o','w',0};
156 static const WCHAR bBeta[] = {'b','B','e','t','a',0};
157 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
158 static const WCHAR bExists[] = {'b','E','x','i','s','t','s',0};
159 /** values */
160 static const WCHAR szFinal_Retail_v[] = {'F','i','n','a','l',' ','R','e','t','a','i','l',0};
161 static const WCHAR szEnglish_v[] = {'E','n','g','l','i','s','h',0};
162 static const WCHAR szVersionFormat[] = {'%','u','.','%','0','2','u','.','%','0','4','u','.','%','0','4','u',0};
163 VARIANT v;
165 WCHAR szFile[512];
166 WCHAR szVersion_v[1024];
167 DWORD retval, hdl;
168 LPVOID pVersionInfo;
169 BOOL boolret;
170 UINT uiLength;
171 VS_FIXEDFILEINFO* pFileInfo;
173 FIXME("(%p,%s)\n", pSubCont, debugstr_w(szFileName));
175 lstrcpyW(szFile, szFilePath);
176 lstrcatW(szFile, szSlashSep);
177 lstrcatW(szFile, szFileName);
179 retval = GetFileVersionInfoSizeW(szFile, &hdl);
180 pVersionInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, retval);
181 hr = GetFileVersionInfoW(szFile, 0, retval, pVersionInfo);
182 boolret = VerQueryValueW(pVersionInfo, (LPWSTR) szSlashSep, (LPVOID) &pFileInfo, &uiLength);
184 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szFile);
185 hr = IDxDiagContainerImpl_AddProp(pSubCont, szPath, &v);
186 VariantClear(&v);
187 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szFileName);
188 hr = IDxDiagContainerImpl_AddProp(pSubCont, szName, &v);
189 VariantClear(&v);
190 V_VT(&v) = VT_BOOL; V_BOOL(&v) = boolret;
191 hr = IDxDiagContainerImpl_AddProp(pSubCont, bExists, &v);
192 VariantClear(&v);
194 if (boolret) {
195 snprintfW(szVersion_v, sizeof(szVersion_v),
196 szVersionFormat,
197 HIWORD(pFileInfo->dwFileVersionMS),
198 LOWORD(pFileInfo->dwFileVersionMS),
199 HIWORD(pFileInfo->dwFileVersionLS),
200 LOWORD(pFileInfo->dwFileVersionLS));
202 TRACE("Found version as (%s)\n", debugstr_w(szVersion_v));
204 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szVersion_v);
205 hr = IDxDiagContainerImpl_AddProp(pSubCont, szVersion, &v);
206 VariantClear(&v);
207 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szFinal_Retail_v);
208 hr = IDxDiagContainerImpl_AddProp(pSubCont, szAttributes, &v);
209 VariantClear(&v);
210 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szEnglish_v);
211 hr = IDxDiagContainerImpl_AddProp(pSubCont, szLanguageEnglish, &v);
212 VariantClear(&v);
213 V_VT(&v) = VT_UI4; V_UI4(&v) = pFileInfo->dwFileDateMS;
214 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwFileTimeHigh, &v);
215 VariantClear(&v);
216 V_VT(&v) = VT_UI4; V_UI4(&v) = pFileInfo->dwFileDateLS;
217 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwFileTimeLow, &v);
218 VariantClear(&v);
219 V_VT(&v) = VT_BOOL; V_BOOL(&v) = (0 != ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_PRERELEASE));
220 hr = IDxDiagContainerImpl_AddProp(pSubCont, bBeta, &v);
221 VariantClear(&v);
222 V_VT(&v) = VT_BOOL; V_BOOL(&v) = (0 != ((pFileInfo->dwFileFlags & pFileInfo->dwFileFlagsMask) & VS_FF_DEBUG));
223 hr = IDxDiagContainerImpl_AddProp(pSubCont, bDebug, &v);
224 VariantClear(&v);
227 HeapFree(GetProcessHeap(), 0, pVersionInfo);
229 return hr;
232 HRESULT DXDiag_InitDXDiagSystemInfoContainer(IDxDiagContainer* pSubCont) {
233 HRESULT hr = S_OK;
234 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};
235 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};
236 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};
237 static const WCHAR szDirectXVersionLetter_v[] = {'c',0};
238 static const WCHAR bDebug[] = {'b','D','e','b','u','g',0};
239 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};
240 static const WCHAR szDirectXVersionEnglish_v[] = {'4','.','0','9','.','0','0','0','0','.','0','9','0','4',0};
241 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};
242 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};
243 /*static const WCHAR szDxDiagVersion[] = {'s','z','D','x','D','i','a','g','V','e','r','s','i','o','n',0};*/
244 /*szWindowsDir*/
245 /*szWindowsDir*/
246 /*"dwOSMajorVersion"*/
247 /*"dwOSMinorVersion"*/
248 /*"dwOSBuildNumber"*/
249 /*"dwOSPlatformID"*/
250 VARIANT v;
252 V_VT(&v) = VT_UI4; V_UI4(&v) = 9;
253 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwDirectXVersionMajor, &v);
254 VariantClear(&v);
255 V_VT(&v) = VT_UI4; V_UI4(&v) = 0;
256 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwDirectXVersionMinor, &v);
257 VariantClear(&v);
258 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szDirectXVersionLetter_v);
259 hr = IDxDiagContainerImpl_AddProp(pSubCont, szDirectXVersionLetter, &v);
260 VariantClear(&v);
261 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szDirectXVersionEnglish_v);
262 hr = IDxDiagContainerImpl_AddProp(pSubCont, szDirectXVersionEnglish, &v);
263 VariantClear(&v);
264 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szDirectXVersionLongEnglish_v);
265 hr = IDxDiagContainerImpl_AddProp(pSubCont, szDirectXVersionLongEnglish, &v);
266 VariantClear(&v);
267 V_VT(&v) = VT_BOOL; V_BOOL(&v) = FALSE;
268 hr = IDxDiagContainerImpl_AddProp(pSubCont, bDebug, &v);
269 VariantClear(&v);
271 return hr;
274 HRESULT DXDiag_InitDXDiagSystemDevicesContainer(IDxDiagContainer* pSubCont) {
275 HRESULT hr = S_OK;
277 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
278 static const WCHAR szDeviceID[] = {'s','z','D','e','v','i','c','e','I','D',0};
280 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
282 VARIANT v;
283 IDxDiagContainer* pDeviceSubCont = NULL;
284 IDxDiagContainer* pDriversCont = NULL;
286 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDeviceSubCont);
287 if (FAILED(hr)) { return hr; }
288 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
289 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDescription, &v);
290 VariantClear(&v);
291 V_VT(pvarProp) = VT_BSTR; V_BSTR(pvarProp) = SysAllocString(property->psz);
292 hr = IDxDiagContainerImpl_AddProp(pDeviceSubCont, szDeviceID, &v);
293 VariantClear(&v);
295 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "", pDeviceSubCont);
299 * Drivers Cont contains Files Desc Containers
302 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDriversCont);
303 if (FAILED(hr)) { return hr; }
304 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
307 return hr;
310 HRESULT DXDiag_InitDXDiagLogicalDisksContainer(IDxDiagContainer* pSubCont) {
311 HRESULT hr = S_OK;
313 static const WCHAR szDriveLetter[] = {'s','z','D','r','i','v','e','L','e','t','t','e','r',0};
314 static const WCHAR szFreeSpace[] = {'s','z','F','r','e','e','S','p','a','c','e',0};
315 static const WCHAR szMaxSpace[] = {'s','z','M','a','x','S','p','a','c','e',0};
316 static const WCHAR szFileSystem[] = {'s','z','F','i','l','e','S','y','s','t','e','m',0};
317 static const WCHAR szModel[] = {'s','z','M','o','d','e','l',0};
318 static const WCHAR szPNPDeviceID[] = {'s','z','P','N','P','D','e','v','i','c','e','I','D',0};
319 static const WCHAR dwHardDriveIndex[] = {'d','w','H','a','r','d','D','r','i','v','e','I','n','d','e','x',0};
321 static const WCHAR szDrivers[] = {'s','z','D','r','i','v','e','r','s',0};
323 VARIANT v;
324 IDxDiagContainer* pDiskSubCont = NULL;
325 IDxDiagContainer* pDriversCont = NULL;
327 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDiskSubCont);
328 if (FAILED(hr)) { return hr; }
329 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, "" , pDiskSubCont);
333 * Drivers Cont contains Files Desc Containers
336 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDriversCont);
337 if (FAILED(hr)) { return hr; }
338 hr = IDxDiagContainerImpl_AddChildContainer(pDeviceSubCont, szDrivers, pDriversCont);
340 return hr;
342 HRESULT DXDiag_InitDXDiagDirectXFilesContainer(IDxDiagContainer* pSubCont) {
343 HRESULT hr = S_OK;
344 /**/
345 static const WCHAR ddraw_dll[] = {'d','d','r','a','w','.','d','l','l',0};
346 static const WCHAR dplayx_dll[] = {'d','p','l','a','y','x','.','d','l','l',0};
347 static const WCHAR dpnet_dll[] = {'d','p','n','e','t','.','d','l','l',0};
348 static const WCHAR dinput_dll[] = {'d','i','n','p','u','t','.','d','l','l',0};
349 static const WCHAR dinput8_dll[] = {'d','i','n','p','u','t','8','.','d','l','l',0};
350 static const WCHAR dsound_dll[] = {'d','s','o','u','n','d','.','d','l','l',0};
351 static const WCHAR dswave_dll[] = {'d','s','w','a','v','e','.','d','l','l',0};
352 static const WCHAR d3d8_dll[] = {'d','3','d','8','.','d','l','l',0};
353 static const WCHAR d3d9_dll[] = {'d','3','d','9','.','d','l','l',0};
354 static const WCHAR dmband_dll[] = {'d','m','b','a','n','d','.','d','l','l',0};
355 static const WCHAR dmcompos_dll[] = {'d','m','c','o','m','p','o','s','.','d','l','l',0};
356 static const WCHAR dmime_dll[] = {'d','m','i','m','e','.','d','l','l',0};
357 static const WCHAR dmloader_dll[] = {'d','m','l','o','a','d','e','r','.','d','l','l',0};
358 static const WCHAR dmscript_dll[] = {'d','m','s','c','r','i','p','t','.','d','l','l',0};
359 static const WCHAR dmstyle_dll[] = {'d','m','s','t','y','l','e','.','d','l','l',0};
360 static const WCHAR dmsynth_dll[] = {'d','m','s','y','n','t','h','.','d','l','l',0};
361 static const WCHAR dmusic_dll[] = {'d','m','u','s','i','c','.','d','l','l',0};
362 static const WCHAR devenum_dll[] = {'d','e','v','e','n','u','m','.','d','l','l',0};
363 static const WCHAR quartz_dll[] = {'q','u','a','r','t','z','.','d','l','l',0};
364 WCHAR szFilePath[512];
366 hr = GetSystemDirectoryW(szFilePath, MAX_PATH);
367 if (FAILED(hr)) { return hr; }
368 szFilePath[MAX_PATH-1]=0;
370 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, ddraw_dll);
371 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dplayx_dll);
372 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dpnet_dll);
373 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dinput_dll);
374 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dinput8_dll);
375 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dsound_dll);
376 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dswave_dll);
377 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, d3d8_dll);
378 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, d3d9_dll);
379 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmband_dll);
380 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmcompos_dll);
381 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmime_dll);
382 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmloader_dll);
383 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmscript_dll);
384 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmstyle_dll);
385 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmsynth_dll);
386 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, dmusic_dll);
387 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, devenum_dll);
388 hr = DXDiag_AddFileDescContainer(pSubCont, szFilePath, quartz_dll);
389 return hr;
392 HRESULT DXDiag_InitDXDiagDisplayContainer(IDxDiagContainer* pSubCont) {
393 HRESULT hr = S_OK;
395 static const WCHAR szDescription[] = {'s','z','D','e','s','c','r','i','p','t','i','o','n',0};
396 static const WCHAR szDeviceName[] = {'s','z','D','e','v','i','c','e','N','a','m','e',0};
397 static const WCHAR szKeyDeviceID[] = {'s','z','K','e','y','D','e','v','i','c','e','I','D',0};
398 static const WCHAR szKeyDeviceKey[] = {'s','z','K','e','y','D','e','v','i','c','e','K','e','y',0};
399 WCHAR szAdapterName[512];
400 VARIANT v;
401 IDxDiagContainer* pDisplayAdapterSubCont = NULL;
402 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pDisplayAdapterSubCont);
403 if (FAILED(hr)) { return hr; }
404 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, szAdapterName, pDisplayAdapterSubCont);
406 return hr;
409 HRESULT DXDiag_InitDXDiagDirectSoundContainer(IDxDiagContainer* pSubCont) {
410 HRESULT hr = S_OK;
411 static const WCHAR DxDiag_SoundDevices[] = {'D','x','D','i','a','g','_','S','o','u','n','d','D','e','v','i','c','e','s',0};
412 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};
413 IDxDiagContainer* pSubSubCont = NULL;
415 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubSubCont);
416 if (FAILED(hr)) { return hr; }
417 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, DxDiag_SoundDevices, pSubSubCont);
419 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubSubCont);
420 if (FAILED(hr)) { return hr; }
421 hr = IDxDiagContainerImpl_AddChildContainer(pSubCont, DxDiag_SoundCaptureDevices, pSubSubCont);
423 return hr;
426 HRESULT DXDiag_InitDXDiagDirectMusicContainer(IDxDiagContainer* pSubCont) {
427 HRESULT hr = S_OK;
428 return hr;
430 HRESULT DXDiag_InitDXDiagDirectInputContainer(IDxDiagContainer* pSubCont) {
431 HRESULT hr = S_OK;
432 return hr;
434 HRESULT DXDiag_InitDXDiagDirectPlayContainer(IDxDiagContainer* pSubCont) {
435 HRESULT hr = S_OK;
436 return hr;
439 struct REG_RF {
440 DWORD dwVersion;
441 DWORD dwMerit;
442 DWORD dwPins;
443 DWORD dwUnused;
445 struct REG_RFP {
446 BYTE signature[4]; /* e.g. "0pi3" */
447 DWORD dwFlags;
448 DWORD dwInstances;
449 DWORD dwMediaTypes;
450 DWORD dwMediums;
451 DWORD bCategory; /* is there a category clsid? */
452 /* optional: dwOffsetCategoryClsid */
454 struct REG_TYPE {
455 BYTE signature[4]; /* e.g. "0ty3" */
456 DWORD dwUnused;
457 DWORD dwOffsetMajor;
458 DWORD dwOffsetMinor;
461 HRESULT DXDiag_InitDXDiagDirectShowFiltersContainer(IDxDiagContainer* pSubCont) {
462 HRESULT hr = S_OK;
463 static const WCHAR szName[] = {'s','z','N','a','m','e',0};
464 static const WCHAR szCatName[] = {'s','z','C','a','t','N','a','m','e',0};
465 static const WCHAR szClsidCat[] = {'s','z','C','l','s','i','d','C','a','t',0};
466 static const WCHAR szClsidFilter[] = {'s','z','C','l','s','i','d','F','i','l','t','e','r',0};
467 static const WCHAR dwInputs[] = {'d','w','I','n','p','u','t','s',0};
468 static const WCHAR dwOutputs[] = {'d','w','O','u','t','p','u','t','s',0};
469 static const WCHAR dwMerit[] = {'d','w','M','e','r','i','t',0};
471 static const WCHAR szFileName[] = {'s','z','F','i','l','e','N','a','m','e',0};
472 static const WCHAR szFileVersion[] = {'s','z','F','i','l','e','V','e','r','s','i','o','n',0};
474 VARIANT v;
476 static const WCHAR wszClsidName[] = {'C','L','S','I','D',0};
477 static const WCHAR wszFriendlyName[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
478 static const WCHAR wszFilterDataName[] = {'F','i','l','t','e','r','D','a','t','a',0};
479 /*static const WCHAR wszMeritName[] = {'M','e','r','i','t',0};*/
481 ICreateDevEnum* pCreateDevEnum = NULL;
482 IEnumMoniker* pEmCat = NULL;
483 IMoniker* pMCat = NULL;
484 /** */
485 hr = CoCreateInstance(&CLSID_SystemDeviceEnum,
486 NULL,
487 CLSCTX_INPROC_SERVER,
488 &IID_ICreateDevEnum,
489 (void**) &pCreateDevEnum);
490 if (FAILED(hr)) return hr;
492 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &CLSID_ActiveMovieCategories, &pEmCat, 0);
493 if (FAILED(hr)) goto out_show_filters;
495 VariantInit(&v);
497 while (S_OK == IEnumMoniker_Next(pEmCat, 1, &pMCat, NULL)) {
498 IPropertyBag* pPropBag = NULL;
499 CLSID clsidCat;
500 hr = IMoniker_BindToStorage(pMCat, NULL, NULL, &IID_IPropertyBag, (void**) &pPropBag);
501 if (SUCCEEDED(hr)) {
502 WCHAR* wszCatName = NULL;
503 WCHAR* wszCatClsid = NULL;
505 hr = IPropertyBag_Read(pPropBag, wszFriendlyName, &v, 0);
506 wszCatName = SysAllocString(V_BSTR(&v));
507 VariantClear(&v);
509 hr = IPropertyBag_Read(pPropBag, wszClsidName, &v, 0);
510 wszCatClsid = SysAllocString(V_BSTR(&v));
511 hr = CLSIDFromString(V_UNION(&v, bstrVal), &clsidCat);
512 VariantClear(&v);
515 hr = IPropertyBag_Read(pPropBag, wszMeritName, &v, 0);
516 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwMerit, &v);
517 VariantClear(&v);
520 if (SUCCEEDED(hr)) {
521 IEnumMoniker* pEnum = NULL;
522 IMoniker* pMoniker = NULL;
523 hr = ICreateDevEnum_CreateClassEnumerator(pCreateDevEnum, &clsidCat, &pEnum, 0);
524 FIXME("\tClassEnumerator for clsid(%s) pEnum(%p)\n", debugstr_guid(&clsidCat), pEnum);
525 if (FAILED(hr) || pEnum == NULL) {
526 goto class_enum_failed;
528 while (NULL != pEnum && S_OK == IEnumMoniker_Next(pEnum, 1, &pMoniker, NULL)) {
529 IPropertyBag* pPropFilterBag = NULL;
530 FIXME("\tIEnumMoniker_Next(%p, 1, %p)\n", pEnum, pMoniker);
531 hr = IMoniker_BindToStorage(pMoniker, NULL, NULL, &IID_IPropertyBag, (void**) &pPropFilterBag);
532 if (SUCCEEDED(hr)) {
533 LPBYTE pData = NULL;
534 LPBYTE pCurrent = NULL;
535 struct REG_RF* prrf = NULL;
536 VARIANT v_data;
537 DWORD it;
538 DWORD dwNOutputs = 0;
539 DWORD dwNInputs = 0;
541 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(wszCatName);
542 hr = IDxDiagContainerImpl_AddProp(pSubCont, szCatName, &v);
543 VariantClear(&v);
545 V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(wszCatClsid);
546 hr = IDxDiagContainerImpl_AddProp(pSubCont, szClsidCat, &v);
547 VariantClear(&v);
549 hr = IPropertyBag_Read(pPropFilterBag, wszFriendlyName, &v, 0);
550 hr = IDxDiagContainerImpl_AddProp(pSubCont, szName, &v);
551 FIXME("\tName:%s\n", debugstr_w(V_BSTR(&v)));
552 VariantClear(&v);
554 hr = IPropertyBag_Read(pPropFilterBag, wszClsidName, &v, 0);
555 FIXME("\tClsid:%s\n", debugstr_w(V_BSTR(&v)));
556 hr = IDxDiagContainerImpl_AddProp(pSubCont, szClsidFilter, &v);
557 VariantClear(&v);
559 hr = IPropertyBag_Read(pPropFilterBag, wszFilterDataName, &v, NULL);
560 hr = SafeArrayAccessData(V_UNION(&v, parray), (LPVOID*) &pData);
561 prrf = (struct REG_RF*) pData;
562 pCurrent = pData;
564 VariantInit(&v_data);
565 V_VT(&v_data) = VT_UI4; V_UI4(&v_data) = prrf->dwVersion;
566 hr = IDxDiagContainerImpl_AddProp(pSubCont, szName, &v_data);
567 VariantClear(&v_data);
568 V_VT(&v_data) = VT_UI4; V_UI4(&v_data) = prrf->dwMerit;
569 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwMerit, &v_data);
570 VariantClear(&v_data);
572 pCurrent += sizeof(struct REG_RF);
573 for (it = 0; it < prrf->dwPins; ++it) {
574 struct REG_RFP* prrfp = (struct REG_RFP*) pCurrent;
575 UINT j;
577 if (prrfp->dwFlags & REG_PINFLAG_B_OUTPUT) ++dwNOutputs;
578 else ++dwNInputs;
580 pCurrent += sizeof(struct REG_RFP);
581 if (prrfp->bCategory) {
582 pCurrent += sizeof(DWORD);
584 for (j = 0; j < prrfp->dwMediaTypes; ++j) {
585 struct REG_TYPE* prt = (struct REG_TYPE *)pCurrent;
586 pCurrent += sizeof(*prt);
588 for (j = 0; j < prrfp->dwMediums; ++j) {
589 DWORD dwOffset = *(DWORD*) pCurrent;
590 pCurrent += sizeof(dwOffset);
594 V_VT(&v_data) = VT_UI4; V_UI4(&v_data) = dwNInputs;
595 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwInputs, &v_data);
596 VariantClear(&v_data);
597 V_VT(&v_data) = VT_UI4; V_UI4(&v_data) = dwNOutputs;
598 hr = IDxDiagContainerImpl_AddProp(pSubCont, dwOutputs, &v_data);
599 VariantClear(&v_data);
601 SafeArrayUnaccessData(V_UNION(&v, parray));
602 VariantClear(&v);
604 IPropertyBag_Release(pPropFilterBag); pPropFilterBag = NULL;
606 IEnumMoniker_Release(pEnum); pEnum = NULL;
608 class_enum_failed:
609 SysFreeString(wszCatName);
610 SysFreeString(wszCatClsid);
611 IPropertyBag_Release(pPropBag); pPropBag = NULL;
613 IEnumMoniker_Release(pMCat); pMCat = NULL;
616 out_show_filters:
617 if (NULL != pEmCat) { IEnumMoniker_Release(pEmCat); pEmCat = NULL; }
618 if (NULL != pCreateDevEnum) { ICreateDevEnum_Release(pCreateDevEnum); pCreateDevEnum = NULL; }
619 return hr;
622 HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont) {
623 HRESULT hr = S_OK;
624 static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
625 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};
626 static const WCHAR DxDiag_LogicalDisks[] = {'D','x','D','i','a','g','_','L','o','g','i','c','a','l','D','i','s','k','s',0};
627 static const WCHAR DxDiag_DirectXFiles[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','X','F','i','l','e','s',0};
628 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};
629 static const WCHAR DxDiag_DirectSound[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','S','o','u','n','d',0};
630 static const WCHAR DxDiag_DirectMusic[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','M','u','s','i','c',0};
631 static const WCHAR DxDiag_DirectInput[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','I','n','p','u','t',0};
632 static const WCHAR DxDiag_DirectPlay[] = {'D','x','D','i','a','g','_','D','i','r','e','c','t','P','l','a','y',0};
633 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};
634 IDxDiagContainer* pSubCont = NULL;
636 TRACE("(%p)\n", pRootCont);
638 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
639 if (FAILED(hr)) { return hr; }
640 hr = DXDiag_InitDXDiagSystemInfoContainer(pSubCont);
641 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemInfo, pSubCont);
643 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
644 if (FAILED(hr)) { return hr; }
645 hr = DXDiag_InitDXDiagSystemDevicesContainer(pSubCont);
646 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemDevices, pSubCont);
648 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
649 if (FAILED(hr)) { return hr; }
650 hr = DXDiag_InitDXDiagLogicalDisksContainer(pSubCont);
651 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_LogicalDisks, pSubCont);
653 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
654 if (FAILED(hr)) { return hr; }
655 hr = DXDiag_InitDXDiagDirectXFilesContainer(pSubCont);
656 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectXFiles, pSubCont);
658 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
659 if (FAILED(hr)) { return hr; }
660 hr = DXDiag_InitDXDiagDisplayContainer(pSubCont);
661 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DisplayDevices, pSubCont);
663 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
664 if (FAILED(hr)) { return hr; }
665 hr = DXDiag_InitDXDiagDirectSoundContainer(pSubCont);
666 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectSound, pSubCont);
668 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
669 if (FAILED(hr)) { return hr; }
670 hr = DXDiag_InitDXDiagDirectMusicContainer(pSubCont);
671 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectMusic, pSubCont);
673 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
674 if (FAILED(hr)) { return hr; }
675 hr = DXDiag_InitDXDiagDirectInputContainer(pSubCont);
676 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectInput, pSubCont);
678 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
679 if (FAILED(hr)) { return hr; }
680 hr = DXDiag_InitDXDiagDirectPlayContainer(pSubCont);
681 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectPlay, pSubCont);
683 hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
684 if (FAILED(hr)) { return hr; }
685 hr = DXDiag_InitDXDiagDirectShowFiltersContainer(pSubCont);
686 hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_DirectShowFilters, pSubCont);
688 return hr;