2 * COM stub (CStdStubBuffer) implementation
4 * Copyright 2001 Ove Kåven, TransGaming Technologies
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
37 #define STUB_HEADER(This) (((CInterfaceStubHeader*)((This)->lpVtbl))[-1])
39 HRESULT WINAPI
CStdStubBuffer_Construct(REFIID riid
,
42 CInterfaceStubVtbl
*vtbl
,
43 LPPSFACTORYBUFFER pPSFactory
,
44 LPRPCSTUBBUFFER
*ppStub
)
48 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer
, vtbl
, pPSFactory
, ppStub
, name
);
49 TRACE("iid=%s\n", debugstr_guid(vtbl
->header
.piid
));
50 TRACE("vtbl=%p\n", &vtbl
->Vtbl
);
52 if (!IsEqualGUID(vtbl
->header
.piid
, riid
)) {
53 ERR("IID mismatch during stub creation\n");
54 return RPC_E_UNEXPECTED
;
57 This
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(CStdStubBuffer
));
58 if (!This
) return E_OUTOFMEMORY
;
60 This
->lpVtbl
= &vtbl
->Vtbl
;
62 This
->pvServerObject
= pUnkServer
;
63 This
->pPSFactory
= pPSFactory
;
64 *ppStub
= (LPRPCSTUBBUFFER
)This
;
66 IUnknown_AddRef(This
->pvServerObject
);
67 IPSFactoryBuffer_AddRef(pPSFactory
);
71 HRESULT WINAPI
CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface
,
75 ICOM_THIS(CStdStubBuffer
,iface
);
76 TRACE("(%p)->QueryInterface(%s,%p)\n",This
,debugstr_guid(riid
),obj
);
78 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
79 IsEqualGUID(&IID_IRpcStubBuffer
,riid
)) {
87 ULONG WINAPI
CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface
)
89 ICOM_THIS(CStdStubBuffer
,iface
);
90 TRACE("(%p)->AddRef()\n",This
);
91 return ++(This
->RefCount
);
94 ULONG WINAPI
NdrCStdStubBuffer_Release(LPRPCSTUBBUFFER iface
,
95 LPPSFACTORYBUFFER pPSF
)
97 ICOM_THIS(CStdStubBuffer
,iface
);
98 TRACE("(%p)->Release()\n",This
);
100 if (!--(This
->RefCount
)) {
101 if(This
->pvServerObject
)
102 IUnknown_Release(This
->pvServerObject
);
104 IPSFactoryBuffer_Release(This
->pPSFactory
);
105 HeapFree(GetProcessHeap(),0,This
);
108 return This
->RefCount
;
111 HRESULT WINAPI
CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface
,
112 LPUNKNOWN lpUnkServer
)
114 ICOM_THIS(CStdStubBuffer
,iface
);
115 TRACE("(%p)->Connect(%p)\n",This
,lpUnkServer
);
116 This
->pvServerObject
= lpUnkServer
;
120 void WINAPI
CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface
)
122 ICOM_THIS(CStdStubBuffer
,iface
);
123 TRACE("(%p)->Disconnect()\n",This
);
124 This
->pvServerObject
= NULL
;
127 HRESULT WINAPI
CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface
,
129 LPRPCCHANNELBUFFER pChannel
)
131 ICOM_THIS(CStdStubBuffer
,iface
);
132 DWORD dwPhase
= STUB_UNMARSHAL
;
133 TRACE("(%p)->Invoke(%p,%p)\n",This
,pMsg
,pChannel
);
135 STUB_HEADER(This
).pDispatchTable
[pMsg
->iMethod
](iface
, pChannel
, (PRPC_MESSAGE
)pMsg
, &dwPhase
);
139 LPRPCSTUBBUFFER WINAPI
CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface
,
142 ICOM_THIS(CStdStubBuffer
,iface
);
143 TRACE("(%p)->IsIIDSupported(%s)\n",This
,debugstr_guid(riid
));
144 return IsEqualGUID(STUB_HEADER(This
).piid
, riid
) ? iface
: NULL
;
147 ULONG WINAPI
CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface
)
149 ICOM_THIS(CStdStubBuffer
,iface
);
150 TRACE("(%p)->CountRefs()\n",This
);
151 return This
->RefCount
;
154 HRESULT WINAPI
CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface
,
157 ICOM_THIS(CStdStubBuffer
,iface
);
158 TRACE("(%p)->DebugServerQueryInterface(%p)\n",This
,ppv
);
162 void WINAPI
CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface
,
165 ICOM_THIS(CStdStubBuffer
,iface
);
166 TRACE("(%p)->DebugServerRelease(%p)\n",This
,pv
);