No longer directly accessing debuggee memory.
[wine] / dlls / dplayx / dpclassfactory.c
1
2 #include "wine/obj_base.h"
3 #include "winerror.h"
4 #include "debugtools.h"
5 #include "dpinit.h"
6
7 DEFAULT_DEBUG_CHANNEL(dplay)
8
9
10 /*******************************************************************************
11  * DirectPlayLobby ClassFactory
12  */
13
14 typedef struct
15 {
16     /* IUnknown fields */
17     ICOM_VFIELD(IClassFactory);
18     DWORD                       ref;
19 } IClassFactoryImpl;
20
21 static HRESULT WINAPI
22 DP_and_DPL_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
23         ICOM_THIS(IClassFactoryImpl,iface);
24
25         FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
26
27         return E_NOINTERFACE;
28 }
29
30 static ULONG WINAPI
31 DP_and_DPL_AddRef(LPCLASSFACTORY iface) {
32         ICOM_THIS(IClassFactoryImpl,iface);
33         return ++(This->ref);
34 }
35
36 static ULONG WINAPI DP_and_DPL_Release(LPCLASSFACTORY iface) {
37         ICOM_THIS(IClassFactoryImpl,iface);
38         /* static class (reference starts @ 1), won't ever be freed */
39         return --(This->ref);
40 }
41
42 /* Not the most efficient implementation, but it's simple */
43 static HRESULT WINAPI DP_and_DPL_CreateInstance(
44         LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
45 ) {
46         ICOM_THIS(IClassFactoryImpl,iface);
47
48         TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
49
50         /* FIXME: reuse already created DP/DPL object if present? */
51         if ( directPlayLobby_QueryInterface( riid, ppobj ) == S_OK )
52         {
53            return S_OK;
54         }
55         else if ( directPlay_QueryInterface( riid, ppobj ) == S_OK )
56         {
57            return S_OK;
58         }
59
60         return E_NOINTERFACE;
61 }
62
63 static HRESULT WINAPI DP_and_DPL_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
64         ICOM_THIS(IClassFactoryImpl,iface);
65         FIXME("(%p)->(%d),stub!\n",This,dolock);
66         return S_OK;
67 }
68
69 static ICOM_VTABLE(IClassFactory) DP_and_DPL_Vtbl = {
70         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
71         DP_and_DPL_QueryInterface,
72         DP_and_DPL_AddRef,
73         DP_and_DPL_Release,
74         DP_and_DPL_CreateInstance,
75         DP_and_DPL_LockServer
76 };
77
78 static IClassFactoryImpl DP_and_DPL_CF = {&DP_and_DPL_Vtbl, 1 };
79
80
81 /*******************************************************************************
82  * DllGetClassObject [DPLAYX.?]
83  * Retrieves DP or DPL class object from a DLL object
84  *
85  * NOTES
86  *    Docs say returns STDAPI
87  *
88  * PARAMS
89  *    rclsid [I] CLSID for the class object
90  *    riid   [I] Reference to identifier of interface for class object
91  *    ppv    [O] Address of variable to receive interface pointer for riid
92  *
93  * RETURNS
94  *    Success: S_OK
95  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
96  *             E_UNEXPECTED
97  */
98 DWORD WINAPI DP_and_DPL_DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID *ppv)
99 {
100     TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
101
102     if ( IsEqualCLSID( riid, &IID_IClassFactory ) )
103     {
104         *ppv = (LPVOID)&DP_and_DPL_CF;
105         IClassFactory_AddRef( (IClassFactory*)*ppv );
106
107         return S_OK;
108     }
109
110     ERR("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
111     return CLASS_E_CLASSNOTAVAILABLE;
112 }
113