kernelbase: Let GetModuleBaseName succeed on 64bit modules in wow64.
[wine.git] / dlls / dmscript / dmscript_main.c
blobf6785176aec169fd4423efb4c09bd7f988990998
1 /* DirectMusicScript 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
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winnt.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winreg.h"
31 #include "objbase.h"
32 #include "rpcproxy.h"
33 #include "initguid.h"
34 #include "dmusici.h"
36 #include "dmscript_private.h"
37 #include "dmobject.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(dmscript);
41 LONG DMSCRIPT_refCount = 0;
43 typedef struct {
44 IClassFactory IClassFactory_iface;
45 HRESULT (*fnCreateInstance)(REFIID riid, void **ppv, IUnknown *pUnkOuter);
46 } IClassFactoryImpl;
48 static HRESULT create_unimpl_instance(REFIID riid, void **ppv, IUnknown *pUnkOuter)
50 FIXME("(%p, %s, %p) stub\n", pUnkOuter, debugstr_dmguid(riid), ppv);
52 return CLASS_E_CLASSNOTAVAILABLE;
55 /******************************************************************
56 * IClassFactory implementation
58 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
60 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
63 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
65 if (ppv == NULL)
66 return E_POINTER;
68 if (IsEqualGUID(&IID_IUnknown, riid))
69 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
70 else if (IsEqualGUID(&IID_IClassFactory, riid))
71 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
72 else {
73 FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
74 *ppv = NULL;
75 return E_NOINTERFACE;
78 *ppv = iface;
79 IUnknown_AddRef((IUnknown*)*ppv);
80 return S_OK;
83 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
85 DMSCRIPT_LockModule();
87 return 2; /* non-heap based object */
90 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
92 DMSCRIPT_UnlockModule();
94 return 1; /* non-heap based object */
97 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
98 REFIID riid, void **ppv)
100 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
102 TRACE ("(%p, %s, %p)\n", pUnkOuter, debugstr_dmguid(riid), ppv);
104 return This->fnCreateInstance(riid, ppv, pUnkOuter);
107 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
109 TRACE("(%d)\n", dolock);
111 if (dolock)
112 DMSCRIPT_LockModule();
113 else
114 DMSCRIPT_UnlockModule();
116 return S_OK;
119 static const IClassFactoryVtbl classfactory_vtbl = {
120 ClassFactory_QueryInterface,
121 ClassFactory_AddRef,
122 ClassFactory_Release,
123 ClassFactory_CreateInstance,
124 ClassFactory_LockServer
127 static IClassFactoryImpl ScriptAutoImplSegment_CF = {{&classfactory_vtbl}, create_unimpl_instance};
128 static IClassFactoryImpl ScriptTrack_CF = {{&classfactory_vtbl},
129 DMUSIC_CreateDirectMusicScriptTrack};
130 static IClassFactoryImpl AudioVBScript_CF = {{&classfactory_vtbl}, create_unimpl_instance};
131 static IClassFactoryImpl Script_CF = {{&classfactory_vtbl}, DMUSIC_CreateDirectMusicScriptImpl};
132 static IClassFactoryImpl ScriptAutoImplPerformance_CF = {{&classfactory_vtbl},
133 create_unimpl_instance};
134 static IClassFactoryImpl ScriptSourceCodeLoader_CF = {{&classfactory_vtbl}, create_unimpl_instance};
135 static IClassFactoryImpl ScriptAutoImplSegmentState_CF = {{&classfactory_vtbl},
136 create_unimpl_instance};
137 static IClassFactoryImpl ScriptAutoImplAudioPathConfig_CF = {{&classfactory_vtbl},
138 create_unimpl_instance};
139 static IClassFactoryImpl ScriptAutoImplAudioPath_CF = {{&classfactory_vtbl},
140 create_unimpl_instance};
141 static IClassFactoryImpl ScriptAutoImplSong_CF = {{&classfactory_vtbl}, create_unimpl_instance};
143 /******************************************************************
144 * DllCanUnloadNow (DMSCRIPT.@)
148 HRESULT WINAPI DllCanUnloadNow(void)
150 return DMSCRIPT_refCount != 0 ? S_FALSE : S_OK;
154 /******************************************************************
155 * DllGetClassObject (DMSCRIPT.@)
159 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
161 TRACE("(%s, %s, %p)\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
162 if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSegment) && IsEqualIID (riid, &IID_IClassFactory)) {
163 *ppv = &ScriptAutoImplSegment_CF;
164 IClassFactory_AddRef((IClassFactory*)*ppv);
165 return S_OK;
166 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptTrack) && IsEqualIID (riid, &IID_IClassFactory)) {
167 *ppv = &ScriptTrack_CF;
168 IClassFactory_AddRef((IClassFactory*)*ppv);
169 return S_OK;
170 } else if (IsEqualCLSID (rclsid, &CLSID_AudioVBScript) && IsEqualIID (riid, &IID_IClassFactory)) {
171 *ppv = &AudioVBScript_CF;
172 IClassFactory_AddRef((IClassFactory*)*ppv);
173 return S_OK;
174 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScript) && IsEqualIID (riid, &IID_IClassFactory)) {
175 *ppv = &Script_CF;
176 IClassFactory_AddRef((IClassFactory*)*ppv);
177 return S_OK;
178 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpPerformance) && IsEqualIID (riid, &IID_IClassFactory)) {
179 *ppv = &ScriptAutoImplPerformance_CF;
180 IClassFactory_AddRef((IClassFactory*)*ppv);
181 return S_OK;
182 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptSourceCodeLoader) && IsEqualIID (riid, &IID_IClassFactory)) {
183 *ppv = &ScriptSourceCodeLoader_CF;
184 IClassFactory_AddRef((IClassFactory*)*ppv);
185 return S_OK;
186 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSegmentState) && IsEqualIID (riid, &IID_IClassFactory)) {
187 *ppv = &ScriptAutoImplSegmentState_CF;
188 IClassFactory_AddRef((IClassFactory*)*ppv);
189 return S_OK;
190 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpAudioPathConfig) && IsEqualIID (riid, &IID_IClassFactory)) {
191 *ppv = &ScriptAutoImplAudioPathConfig_CF;
192 IClassFactory_AddRef((IClassFactory*)*ppv);
193 return S_OK;
194 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpAudioPath) && IsEqualIID (riid, &IID_IClassFactory)) {
195 *ppv = &ScriptAutoImplAudioPath_CF;
196 IClassFactory_AddRef((IClassFactory*)*ppv);
197 return S_OK;
198 } else if (IsEqualCLSID (rclsid, &CLSID_DirectMusicScriptAutoImpSong) && IsEqualIID (riid, &IID_IClassFactory)) {
199 *ppv = &ScriptAutoImplSong_CF;
200 IClassFactory_AddRef((IClassFactory*)*ppv);
201 return S_OK;
204 WARN("(%s, %s, %p): no interface found.\n", debugstr_dmguid(rclsid), debugstr_dmguid(riid), ppv);
205 return CLASS_E_CLASSNOTAVAILABLE;