makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / dxdiagn / dxdiag_main.c
blob719984f4e7dbeb1b6a14971bd89bdb19b033317a
1 /*
2 * DXDiag
3 *
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
22 #define COBJMACROS
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "objbase.h"
29 #include "oleauto.h"
30 #include "oleidl.h"
31 #include "rpcproxy.h"
32 #include "initguid.h"
33 #include "dxdiag_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dxdiag);
38 HINSTANCE dxdiagn_instance = 0;
40 LONG DXDIAGN_refCount = 0;
42 /* At process attach */
43 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
45 TRACE("%p,%x,%p\n", hInstDLL, fdwReason, lpvReserved);
46 if (fdwReason == DLL_PROCESS_ATTACH) {
47 dxdiagn_instance = hInstDLL;
48 DisableThreadLibraryCalls(hInstDLL);
50 return TRUE;
53 /*******************************************************************************
54 * DXDiag ClassFactory
56 typedef struct {
57 IClassFactory IClassFactory_iface;
58 } IClassFactoryImpl;
60 static HRESULT WINAPI DXDiagCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
62 if (ppv == NULL)
63 return E_POINTER;
65 if (IsEqualGUID(&IID_IUnknown, riid))
66 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
67 else if (IsEqualGUID(&IID_IClassFactory, riid))
68 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
69 else if (IsEqualGUID(&IID_IExternalConnection, riid) ||
70 IsEqualGUID(&IID_IMarshal, riid)) {
71 TRACE("(%p)->(%s) ignoring\n", iface, debugstr_guid(riid));
72 *ppv = NULL;
73 return E_NOINTERFACE;
75 else {
76 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
77 *ppv = NULL;
78 return E_NOINTERFACE;
81 *ppv = iface;
82 IClassFactory_AddRef(iface);
83 return S_OK;
86 static ULONG WINAPI DXDiagCF_AddRef(IClassFactory *iface)
88 DXDIAGN_LockModule();
90 return 2; /* non-heap based object */
93 static ULONG WINAPI DXDiagCF_Release(IClassFactory * iface)
95 DXDIAGN_UnlockModule();
97 return 1; /* non-heap based object */
100 static HRESULT WINAPI DXDiagCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid,
101 void **ppv)
103 TRACE("(%p)->(%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid), ppv);
105 return DXDiag_CreateDXDiagProvider(iface, pOuter, riid, ppv);
108 static HRESULT WINAPI DXDiagCF_LockServer(IClassFactory *iface, BOOL dolock)
110 TRACE("(%d)\n", dolock);
112 if (dolock)
113 DXDIAGN_LockModule();
114 else
115 DXDIAGN_UnlockModule();
117 return S_OK;
120 static const IClassFactoryVtbl DXDiagCF_Vtbl = {
121 DXDiagCF_QueryInterface,
122 DXDiagCF_AddRef,
123 DXDiagCF_Release,
124 DXDiagCF_CreateInstance,
125 DXDiagCF_LockServer
128 static IClassFactoryImpl DXDiag_CF = { { &DXDiagCF_Vtbl } };
130 /***********************************************************************
131 * DllCanUnloadNow (DXDIAGN.@)
133 HRESULT WINAPI DllCanUnloadNow(void)
135 return DXDIAGN_refCount != 0 ? S_FALSE : S_OK;
138 /***********************************************************************
139 * DllGetClassObject (DXDIAGN.@)
141 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
143 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
145 if (IsEqualGUID(rclsid, &CLSID_DxDiagProvider)) {
146 IClassFactory_AddRef(&DXDiag_CF.IClassFactory_iface);
147 *ppv = &DXDiag_CF.IClassFactory_iface;
148 return S_OK;
151 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
152 return CLASS_E_CLASSNOTAVAILABLE;
155 /***********************************************************************
156 * DllRegisterServer (DXDIAGN.@)
158 HRESULT WINAPI DllRegisterServer(void)
160 return __wine_register_resources( dxdiagn_instance );
163 /***********************************************************************
164 * DllUnregisterServer (DXDIAGN.@)
166 HRESULT WINAPI DllUnregisterServer(void)
168 return __wine_unregister_resources( dxdiagn_instance );