4 * Copyright 2004 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
34 #include "dxdiag_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag
);
39 HINSTANCE dxdiagn_instance
= 0;
41 LONG DXDIAGN_refCount
= 0;
43 /* At process attach */
44 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
46 TRACE("%p,%x,%p\n", hInstDLL
, fdwReason
, lpvReserved
);
47 if (fdwReason
== DLL_PROCESS_ATTACH
) {
48 dxdiagn_instance
= hInstDLL
;
49 DisableThreadLibraryCalls(hInstDLL
);
54 /*******************************************************************************
58 IClassFactory IClassFactory_iface
;
61 static HRESULT WINAPI
DXDiagCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
66 if (IsEqualGUID(&IID_IUnknown
, riid
))
67 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
68 else if (IsEqualGUID(&IID_IClassFactory
, riid
))
69 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
70 else if (IsEqualGUID(&IID_IExternalConnection
, riid
) ||
71 IsEqualGUID(&IID_IMarshal
, riid
)) {
72 TRACE("(%p)->(%s) ignoring\n", iface
, debugstr_guid(riid
));
77 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
83 IClassFactory_AddRef(iface
);
87 static ULONG WINAPI
DXDiagCF_AddRef(IClassFactory
*iface
)
91 return 2; /* non-heap based object */
94 static ULONG WINAPI
DXDiagCF_Release(IClassFactory
* iface
)
96 DXDIAGN_UnlockModule();
98 return 1; /* non-heap based object */
101 static HRESULT WINAPI
DXDiagCF_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
, REFIID riid
,
104 TRACE("(%p)->(%p,%s,%p)\n", iface
, pOuter
, debugstr_guid(riid
), ppv
);
106 return DXDiag_CreateDXDiagProvider(iface
, pOuter
, riid
, ppv
);
109 static HRESULT WINAPI
DXDiagCF_LockServer(IClassFactory
*iface
, BOOL dolock
)
111 TRACE("(%d)\n", dolock
);
114 DXDIAGN_LockModule();
116 DXDIAGN_UnlockModule();
121 static const IClassFactoryVtbl DXDiagCF_Vtbl
= {
122 DXDiagCF_QueryInterface
,
125 DXDiagCF_CreateInstance
,
129 static IClassFactoryImpl DXDiag_CF
= { { &DXDiagCF_Vtbl
} };
131 /***********************************************************************
132 * DllCanUnloadNow (DXDIAGN.@)
134 HRESULT WINAPI
DllCanUnloadNow(void)
136 return DXDIAGN_refCount
!= 0 ? S_FALSE
: S_OK
;
139 /***********************************************************************
140 * DllGetClassObject (DXDIAGN.@)
142 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
144 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
146 if (IsEqualGUID(rclsid
, &CLSID_DxDiagProvider
)) {
147 IClassFactory_AddRef(&DXDiag_CF
.IClassFactory_iface
);
148 *ppv
= &DXDiag_CF
.IClassFactory_iface
;
152 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
153 return CLASS_E_CLASSNOTAVAILABLE
;
156 /***********************************************************************
157 * DllRegisterServer (DXDIAGN.@)
159 HRESULT WINAPI
DllRegisterServer(void)
161 return __wine_register_resources( dxdiagn_instance
);
164 /***********************************************************************
165 * DllUnregisterServer (DXDIAGN.@)
167 HRESULT WINAPI
DllUnregisterServer(void)
169 return __wine_unregister_resources( dxdiagn_instance
);