2004-04-16 02:26:14 +02:00
|
|
|
/*
|
|
|
|
* IDxDiagProvider Implementation
|
|
|
|
*
|
|
|
|
* Copyright 2004 Raphael Junqueira
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "dxdiag_private.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
|
|
|
|
|
|
|
|
/* IDxDiagProvider IUnknown parts follow: */
|
|
|
|
HRESULT WINAPI IDxDiagProviderImpl_QueryInterface(PDXDIAGPROVIDER iface, REFIID riid, LPVOID *ppobj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
|
2004-04-16 02:26:14 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDxDiagProvider)) {
|
|
|
|
IDxDiagProviderImpl_AddRef(iface);
|
|
|
|
*ppobj = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IDxDiagProviderImpl_AddRef(PDXDIAGPROVIDER iface) {
|
2004-09-06 22:34:29 +02:00
|
|
|
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);
|
|
|
|
|
2005-02-01 15:21:37 +01:00
|
|
|
DXDIAGN_LockModule();
|
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IDxDiagProviderImpl_Release(PDXDIAGPROVIDER iface) {
|
2004-09-06 22:34:29 +02:00
|
|
|
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1);
|
|
|
|
|
|
|
|
if (!refCount) {
|
2004-04-16 02:26:14 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
2005-02-01 15:21:37 +01:00
|
|
|
|
|
|
|
DXDIAGN_UnlockModule();
|
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IDxDiagProvider Interface follow: */
|
|
|
|
HRESULT WINAPI IDxDiagProviderImpl_Initialize(PDXDIAGPROVIDER iface, DXDIAG_INIT_PARAMS* pParams) {
|
2004-09-06 22:34:29 +02:00
|
|
|
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
|
2004-04-19 04:57:09 +02:00
|
|
|
TRACE("(%p,%p)\n", iface, pParams);
|
|
|
|
|
|
|
|
if (NULL == pParams) {
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
if (pParams->dwSize != sizeof(DXDIAG_INIT_PARAMS)) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->init = TRUE;
|
|
|
|
memcpy(&This->params, pParams, pParams->dwSize);
|
|
|
|
return S_OK;
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IDxDiagProviderImpl_GetRootContainer(PDXDIAGPROVIDER iface, IDxDiagContainer** ppInstance) {
|
2004-04-19 04:57:09 +02:00
|
|
|
HRESULT hr = S_OK;
|
2004-09-06 22:34:29 +02:00
|
|
|
IDxDiagProviderImpl *This = (IDxDiagProviderImpl *)iface;
|
2004-04-19 04:57:09 +02:00
|
|
|
TRACE("(%p,%p)\n", iface, ppInstance);
|
|
|
|
|
|
|
|
if (NULL == ppInstance) {
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
if (FALSE == This->init) {
|
|
|
|
return E_INVALIDARG; /* should be E_CO_UNINITIALIZED */
|
|
|
|
}
|
|
|
|
if (NULL == This->pRootContainer) {
|
|
|
|
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &This->pRootContainer);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return hr;
|
|
|
|
}
|
2005-01-27 11:42:00 +01:00
|
|
|
hr = DXDiag_InitRootDXDiagContainer((PDXDIAGCONTAINER)This->pRootContainer);
|
2004-04-19 04:57:09 +02:00
|
|
|
}
|
|
|
|
return IDxDiagContainerImpl_QueryInterface((PDXDIAGCONTAINER)This->pRootContainer, &IID_IDxDiagContainer, (void**) ppInstance);
|
2004-04-16 02:26:14 +02:00
|
|
|
}
|
|
|
|
|
2005-06-01 21:57:42 +02:00
|
|
|
static const IDxDiagProviderVtbl DxDiagProvider_Vtbl =
|
2004-04-16 02:26:14 +02:00
|
|
|
{
|
|
|
|
IDxDiagProviderImpl_QueryInterface,
|
|
|
|
IDxDiagProviderImpl_AddRef,
|
|
|
|
IDxDiagProviderImpl_Release,
|
|
|
|
IDxDiagProviderImpl_Initialize,
|
|
|
|
IDxDiagProviderImpl_GetRootContainer
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT DXDiag_CreateDXDiagProvider(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
|
|
|
|
IDxDiagProviderImpl* provider;
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
|
|
|
|
|
|
|
|
provider = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDxDiagProviderImpl));
|
|
|
|
if (NULL == provider) {
|
|
|
|
*ppobj = NULL;
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
provider->lpVtbl = &DxDiagProvider_Vtbl;
|
|
|
|
provider->ref = 0; /* will be inited with QueryInterface */
|
|
|
|
return IDxDiagProviderImpl_QueryInterface ((PDXDIAGPROVIDER)provider, riid, ppobj);
|
|
|
|
}
|
2005-01-27 11:42:00 +01:00
|
|
|
|
|
|
|
HRESULT DXDiag_InitRootDXDiagContainer(IDxDiagContainer* pRootCont) {
|
|
|
|
static const WCHAR DxDiag_SystemInfo[] = {'D','x','D','i','a','g','_','S','y','s','t','e','m','I','n','f','o',0};
|
|
|
|
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};
|
|
|
|
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};
|
|
|
|
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};
|
|
|
|
static const WCHAR szDirectXVersionLetter_v[] = {'c',0};
|
|
|
|
|
|
|
|
IDxDiagContainer* pSubCont = NULL;
|
|
|
|
VARIANT v;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pRootCont);
|
|
|
|
|
|
|
|
hr = DXDiag_CreateDXDiagContainer(&IID_IDxDiagContainer, (void**) &pSubCont);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
V_VT(&v) = VT_UI4; V_UI4(&v) = 9;
|
|
|
|
hr = IDxDiagContainerImpl_AddProp(pSubCont, dwDirectXVersionMajor, &v);
|
|
|
|
V_VT(&v) = VT_UI4; V_UI4(&v) = 0;
|
|
|
|
hr = IDxDiagContainerImpl_AddProp(pSubCont, dwDirectXVersionMinor, &v);
|
|
|
|
V_VT(&v) = VT_BSTR; V_BSTR(&v) = SysAllocString(szDirectXVersionLetter_v);
|
|
|
|
hr = IDxDiagContainerImpl_AddProp(pSubCont, szDirectXVersionLetter, &v);
|
|
|
|
|
|
|
|
hr = IDxDiagContainerImpl_AddChildContainer(pRootCont, DxDiag_SystemInfo, pSubCont);
|
|
|
|
return hr;
|
|
|
|
}
|