ReactOS  0.4.14-dev-1252-g782ff23
main.c
Go to the documentation of this file.
1 /* DirectShow Editing Services (qedit.dll)
2  *
3  * Copyright 2008 Google (Lei Zhang)
4  *
5  * This library 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.
9  *
10  * This library 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.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #include "qedit_private.h"
21 #include "rpcproxy.h"
22 #include "wine/debug.h"
23 
25 
27 
28 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
29 {
30  switch(fdwReason) {
31  case DLL_PROCESS_ATTACH:
32  instance = hInstDLL;
33  DisableThreadLibraryCalls(hInstDLL);
34  break;
35  }
36  return TRUE;
37 }
38 
39 /******************************************************************************
40  * DirectShow ClassFactory
41  */
42 typedef struct {
43  IClassFactory IClassFactory_iface;
44  LONG ref;
45  HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
47 
49 {
50  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
51 }
52 
54 {
55  const CLSID *clsid;
56  HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
57 };
58 
59 static const struct object_creation_info object_creation[] =
60 {
61  { &CLSID_AMTimeline, AMTimeline_create },
62  { &CLSID_MediaDet, MediaDet_create },
63  { &CLSID_SampleGrabber, SampleGrabber_create },
64 };
65 
67 {
70  {
71  IClassFactory_AddRef(iface);
72  *ppobj = iface;
73  return S_OK;
74  }
75 
76  *ppobj = NULL;
77  WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
78  return E_NOINTERFACE;
79 }
80 
82 {
84  return InterlockedIncrement(&This->ref);
85 }
86 
88 {
91 
92  if (ref == 0)
94 
95  return ref;
96 }
97 
99  void **ppobj)
100 {
102  HRESULT hres;
103  LPUNKNOWN punk;
104 
105  TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
106 
107  *ppobj = NULL;
108  if (pOuter && !IsEqualGUID(&IID_IUnknown, riid))
109  return E_INVALIDARG;
110 
111  hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
112  if (SUCCEEDED(hres)) {
113  hres = IUnknown_QueryInterface(punk, riid, ppobj);
114  IUnknown_Release(punk);
115  }
116  return hres;
117 }
118 
120 {
122  FIXME("(%p)->(%d),stub!\n",This,dolock);
123  return S_OK;
124 }
125 
126 static const IClassFactoryVtbl DSCF_Vtbl =
127 {
129  DSCF_AddRef,
130  DSCF_Release,
133 };
134 
135 
136 /***********************************************************************
137  * DllCanUnloadNow (QEDIT.@)
138  */
140 {
141  return S_FALSE;
142 }
143 
144 /*******************************************************************************
145  * DllGetClassObject [QEDIT.@]
146  * Retrieves class object from a DLL object
147  *
148  * PARAMS
149  * rclsid [I] CLSID for the class object
150  * riid [I] Reference to identifier of interface for class object
151  * ppv [O] Address of variable to receive interface pointer for riid
152  *
153  * RETURNS
154  * Success: S_OK
155  * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
156  * E_UNEXPECTED, E_NOINTERFACE
157  */
158 
160 {
161  unsigned int i;
163 
164  TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
165 
167  && ! IsEqualGUID( &IID_IUnknown, riid) )
168  return E_NOINTERFACE;
169 
170  for (i = 0; i < ARRAY_SIZE(object_creation); i++)
171  {
172  if (IsEqualGUID(object_creation[i].clsid, rclsid))
173  break;
174  }
175 
176  if (i == ARRAY_SIZE(object_creation))
177  {
178  FIXME("%s: no class found.\n", debugstr_guid(rclsid));
180  }
181 
182  factory = CoTaskMemAlloc(sizeof(*factory));
183  if (factory == NULL) return E_OUTOFMEMORY;
184 
186  factory->ref = 1;
187 
188  factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
189 
191  return S_OK;
192 }
193 
194 /***********************************************************************
195  * DllRegisterServer (QEDIT.@)
196  */
198 {
200 }
201 
202 /***********************************************************************
203  * DllUnregisterServer (QEDIT.@)
204  */
206 {
208 }
HRESULT AMTimeline_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN
Definition: timeline.c:424
static HRESULT WINAPI DSCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: main.c:66
#define HRESULT
Definition: msvc.h:7
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
WINE_DEFAULT_DEBUG_CHANNEL(wmic)
static ULONG WINAPI DSCF_Release(IClassFactory *iface)
Definition: main.c:87
static HINSTANCE instance
Definition: main.c:26
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
#define WARN(fmt,...)
Definition: debug.h:111
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static HRESULT WINAPI DSCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: main.c:98
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:48
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
const CLSID * clsid
Definition: main.c:70
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
Definition: send.c:47
struct tagIClassFactoryImpl IClassFactoryImpl
HRESULT(* pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI DllRegisterServer(void)
Definition: main.c:212
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:438
static LPUNKNOWN
Definition: ndr_ole.c:49
HRESULT WINAPI DllUnregisterServer(void)
Definition: main.c:220
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static const struct object_creation_info object_creation[]
Definition: main.c:59
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static const IClassFactoryVtbl DSCF_Vtbl
Definition: main.c:126
static ULONG WINAPI DSCF_AddRef(IClassFactory *iface)
Definition: main.c:81
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:78
const GUID IID_IUnknown
static HRESULT WINAPI DSCF_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:119
HRESULT MediaDet_create(IUnknown *pUnkOuter, LPVOID *ppv)
Definition: mediadet.c:639
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
REFCLSID clsid
Definition: msctf.c:82
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
HRESULT SampleGrabber_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define ARRAY_SIZE(a)
Definition: main.h:24
HRESULT WINAPI DllCanUnloadNow(void)
Definition: main.c:204
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
unsigned int ULONG
Definition: retypes.h:1
static ClassFactoryImpl factory
Definition: ole_server.c:234
const GUID IID_IClassFactory
IClassFactory IClassFactory_iface
Definition: main.c:440
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:404
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: main.c:166
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26