ntdll: move relocations from mapping into loader
[wine/kumbayo.git] / dlls / dmband / dmband_main.c
blob6a49f70beb593cc93e7efb4a21cef51cc8395e45
1 /* DirectMusicBand Main
3 * Copyright (C) 2003-2004 Rok Mandeljc
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dmband_private.h"
22 WINE_DEFAULT_DEBUG_CHANNEL(dmband);
24 LONG DMBAND_refCount = 0;
26 typedef struct {
27 const IClassFactoryVtbl *lpVtbl;
28 } IClassFactoryImpl;
30 /******************************************************************
31 * DirectMusicBand ClassFactory
34 static HRESULT WINAPI BandCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
35 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
37 if (ppobj == NULL) return E_POINTER;
39 return E_NOINTERFACE;
42 static ULONG WINAPI BandCF_AddRef(LPCLASSFACTORY iface) {
43 DMBAND_LockModule();
45 return 2; /* non-heap based object */
48 static ULONG WINAPI BandCF_Release(LPCLASSFACTORY iface) {
49 DMBAND_UnlockModule();
51 return 1; /* non-heap based object */
54 static HRESULT WINAPI BandCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
55 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
57 return DMUSIC_CreateDirectMusicBandImpl (riid, ppobj, pOuter);
60 static HRESULT WINAPI BandCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
61 TRACE("(%d)\n", dolock);
63 if (dolock)
64 DMBAND_LockModule();
65 else
66 DMBAND_UnlockModule();
68 return S_OK;
71 static const IClassFactoryVtbl BandCF_Vtbl = {
72 BandCF_QueryInterface,
73 BandCF_AddRef,
74 BandCF_Release,
75 BandCF_CreateInstance,
76 BandCF_LockServer
79 static IClassFactoryImpl Band_CF = {&BandCF_Vtbl};
82 /******************************************************************
83 * DirectMusicBandTrack ClassFactory
86 static HRESULT WINAPI BandTrackCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
87 FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
89 if (ppobj == NULL) return E_POINTER;
91 return E_NOINTERFACE;
94 static ULONG WINAPI BandTrackCF_AddRef(LPCLASSFACTORY iface) {
95 DMBAND_LockModule();
97 return 2; /* non-heap based object */
100 static ULONG WINAPI BandTrackCF_Release(LPCLASSFACTORY iface) {
101 DMBAND_UnlockModule();
103 return 1; /* non-heap based object */
106 static HRESULT WINAPI BandTrackCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj) {
107 TRACE ("(%p, %s, %p)\n", pOuter, debugstr_dmguid(riid), ppobj);
109 return DMUSIC_CreateDirectMusicBandTrack (riid, ppobj, pOuter);
112 static HRESULT WINAPI BandTrackCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
113 TRACE("(%d)\n", dolock);
115 if (dolock)
116 DMBAND_LockModule();
117 else
118 DMBAND_UnlockModule();
120 return S_OK;
123 static const IClassFactoryVtbl BandTrackCF_Vtbl = {
124 BandTrackCF_QueryInterface,
125 BandTrackCF_AddRef,
126 BandTrackCF_Release,
127 BandTrackCF_CreateInstance,
128 BandTrackCF_LockServer
131 static IClassFactoryImpl BandTrack_CF = {&BandTrackCF_Vtbl};
133 /******************************************************************
134 * DllMain
138 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
139 if (fdwReason == DLL_PROCESS_ATTACH) {
140 DisableThreadLibraryCalls(hinstDLL);
141 /* FIXME: Initialisation */
142 } else if (fdwReason == DLL_PROCESS_DETACH) {
143 /* FIXME: Cleanup */
146 return TRUE;
150 /******************************************************************
151 * DllCanUnloadNow (DMBAND.@)
155 HRESULT WINAPI DllCanUnloadNow(void)
157 return DMBAND_refCount != 0 ? S_FALSE : S_OK;
161 /******************************************************************
162 * DllGetClassObject (DMBAND.@)
166 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
168 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
170 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBand) && IsEqualIID (riid, &IID_IClassFactory)) {
171 *ppv = (LPVOID) &Band_CF;
172 IClassFactory_AddRef((IClassFactory*)*ppv);
173 return S_OK;
174 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicBandTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
175 *ppv = (LPVOID) &BandTrack_CF;
176 IClassFactory_AddRef((IClassFactory*)*ppv);
177 return S_OK;
180 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
181 return CLASS_E_CLASSNOTAVAILABLE;