ReactOS 0.4.15-dev-7953-g1f49173
cstub.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "excpt.h"
#include "objbase.h"
#include "rpcproxy.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "cpsf.h"
Include dependency graph for cstub.c:

Go to the source code of this file.

Classes

struct  ref_counted_vtbl
 
struct  vtbl_method_t
 

Macros

#define COBJMACROS
 
#define STUB_HEADER(This)   (((const CInterfaceStubHeader*)((This)->lpVtbl))[-1])
 
#define BLOCK_SIZE   1024
 
#define MAX_BLOCKS   64 /* 64k methods should be enough for anybody */
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static LONG WINAPI stub_filter (EXCEPTION_POINTERS *eptr)
 
static cstdstubbuffer_delegating_timpl_from_delegating (IRpcStubBuffer *iface)
 
HRESULT CStdStubBuffer_Construct (REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name, CInterfaceStubVtbl *vtbl, LPPSFACTORYBUFFER pPSFactory, LPRPCSTUBBUFFER *ppStub)
 
static HRESULT WINAPI delegating_QueryInterface (IUnknown *pUnk, REFIID iid, void **ppv)
 
static ULONG WINAPI delegating_AddRef (IUnknown *pUnk)
 
static ULONG WINAPI delegating_Release (IUnknown *pUnk)
 
static const vtbl_method_tallocate_block (unsigned int num)
 
static BOOL fill_delegated_stub_table (IUnknownVtbl *vtbl, DWORD num)
 
BOOL fill_delegated_proxy_table (IUnknownVtbl *vtbl, DWORD num)
 
IUnknownVtbl * get_delegating_vtbl (DWORD num_methods)
 
void release_delegating_vtbl (IUnknownVtbl *vtbl)
 
HRESULT CStdStubBuffer_Delegating_Construct (REFIID riid, LPUNKNOWN pUnkServer, PCInterfaceName name, CInterfaceStubVtbl *vtbl, REFIID delegating_iid, LPPSFACTORYBUFFER pPSFactory, LPRPCSTUBBUFFER *ppStub)
 
HRESULT WINAPI CStdStubBuffer_QueryInterface (LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *obj)
 
ULONG WINAPI CStdStubBuffer_AddRef (LPRPCSTUBBUFFER iface)
 
ULONG WINAPI NdrCStdStubBuffer_Release (LPRPCSTUBBUFFER iface, LPPSFACTORYBUFFER pPSF)
 
ULONG WINAPI NdrCStdStubBuffer2_Release (LPRPCSTUBBUFFER iface, LPPSFACTORYBUFFER pPSF)
 
HRESULT WINAPI CStdStubBuffer_Connect (LPRPCSTUBBUFFER iface, LPUNKNOWN lpUnkServer)
 
void WINAPI CStdStubBuffer_Disconnect (LPRPCSTUBBUFFER iface)
 
HRESULT WINAPI CStdStubBuffer_Invoke (LPRPCSTUBBUFFER iface, PRPCOLEMESSAGE pMsg, LPRPCCHANNELBUFFER pChannel)
 
LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported (LPRPCSTUBBUFFER iface, REFIID riid)
 
ULONG WINAPI CStdStubBuffer_CountRefs (LPRPCSTUBBUFFER iface)
 
HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface (LPRPCSTUBBUFFER iface, LPVOID *ppv)
 
void WINAPI CStdStubBuffer_DebugServerRelease (LPRPCSTUBBUFFER iface, LPVOID pv)
 
static HRESULT WINAPI CStdStubBuffer_Delegating_Connect (LPRPCSTUBBUFFER iface, LPUNKNOWN lpUnkServer)
 
static void WINAPI CStdStubBuffer_Delegating_Disconnect (LPRPCSTUBBUFFER iface)
 
static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs (LPRPCSTUBBUFFER iface)
 
const MIDL_SERVER_INFOCStdStubBuffer_GetServerInfo (IRpcStubBuffer *iface)
 
void __RPC_STUB NdrStubForwardingFunction (IRpcStubBuffer *iface, IRpcChannelBuffer *pChannel, PRPC_MESSAGE pMsg, DWORD *pdwStubPhase)
 
void WINAPI NdrStubInitialize (PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDescriptor, LPRPCCHANNELBUFFER pRpcChannelBuffer)
 
void WINAPI NdrStubGetBuffer (LPRPCSTUBBUFFER iface, LPRPCCHANNELBUFFER pRpcChannelBuffer, PMIDL_STUB_MESSAGE pStubMsg)
 

Variables

static CRITICAL_SECTION delegating_vtbl_section = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 
static ref_counted_vtblcurrent_vtbl
 
static const BYTE opcodes [1]
 
static const vtbl_method_tmethod_blocks [MAX_BLOCKS]
 
const IRpcStubBufferVtbl CStdStubBuffer_Vtbl
 
const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl
 

Macro Definition Documentation

◆ BLOCK_SIZE

#define BLOCK_SIZE   1024

Definition at line 214 of file cstub.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file cstub.c.

◆ MAX_BLOCKS

#define MAX_BLOCKS   64 /* 64k methods should be enough for anybody */

Definition at line 215 of file cstub.c.

◆ STUB_HEADER

#define STUB_HEADER (   This)    (((const CInterfaceStubHeader*)((This)->lpVtbl))[-1])

Definition at line 41 of file cstub.c.

Function Documentation

◆ allocate_block()

static const vtbl_method_t * allocate_block ( unsigned int  num)
static

Definition at line 219 of file cstub.c.

220{
221 unsigned int i;
222 vtbl_method_t *prev, *block;
223 DWORD oldprot;
224
225 block = VirtualAlloc( NULL, BLOCK_SIZE * sizeof(*block),
227 if (!block) return NULL;
228
229 for (i = 0; i < BLOCK_SIZE; i++)
230 {
231 memcpy( &block[i], opcodes, sizeof(opcodes) );
232 block[i].offset = (BLOCK_SIZE * num + i + 3) * sizeof(void *);
233 }
234 VirtualProtect( block, BLOCK_SIZE * sizeof(*block), PAGE_EXECUTE_READ, &oldprot );
236 if (prev) /* someone beat us to it */
237 {
239 block = prev;
240 }
241 return block;
242}
#define NULL
Definition: types.h:112
static const BYTE opcodes[1]
Definition: cstub.c:210
static const vtbl_method_t * method_blocks[MAX_BLOCKS]
Definition: cstub.c:217
#define BLOCK_SIZE
Definition: cstub.c:214
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
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 InterlockedCompareExchangePointer
Definition: interlocked.h:129
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
#define MEM_RESERVE
Definition: nt_native.h:1314
#define MEM_RELEASE
Definition: nt_native.h:1316
#define MEM_COMMIT
Definition: nt_native.h:1313
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
LPVOID NTAPI VirtualAlloc(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flAllocationType, IN DWORD flProtect)
Definition: virtmem.c:65
BOOL NTAPI VirtualProtect(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD flNewProtect, OUT PDWORD lpflOldProtect)
Definition: virtmem.c:135
BOOL NTAPI VirtualFree(IN LPVOID lpAddress, IN SIZE_T dwSize, IN DWORD dwFreeType)
Definition: virtmem.c:119
static unsigned int block
Definition: xmlmemory.c:101

Referenced by fill_delegated_proxy_table(), and fill_delegated_stub_table().

◆ CStdStubBuffer_AddRef()

ULONG WINAPI CStdStubBuffer_AddRef ( LPRPCSTUBBUFFER  iface)

Definition at line 410 of file cstub.c.

411{
413 TRACE("(%p)->AddRef()\n",This);
414 return InterlockedIncrement(&This->RefCount);
415}
#define InterlockedIncrement
Definition: armddk.h:53
#define TRACE(s)
Definition: solgame.cpp:4

◆ CStdStubBuffer_Connect()

HRESULT WINAPI CStdStubBuffer_Connect ( LPRPCSTUBBUFFER  iface,
LPUNKNOWN  lpUnkServer 
)

Definition at line 463 of file cstub.c.

465{
467 HRESULT r;
468 IUnknown *new = NULL;
469
470 TRACE("(%p)->Connect(%p)\n",This,lpUnkServer);
471
472 r = IUnknown_QueryInterface(lpUnkServer, STUB_HEADER(This).piid, (void**)&new);
473 new = InterlockedExchangePointer((void**)&This->pvServerObject, new);
474 if(new)
475 IUnknown_Release(new);
476 return r;
477}
#define STUB_HEADER(This)
Definition: cstub.c:41
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
GLdouble GLdouble GLdouble r
Definition: gl.h:2055

Referenced by CStdStubBuffer_Delegating_Connect().

◆ CStdStubBuffer_Construct()

HRESULT CStdStubBuffer_Construct ( REFIID  riid,
LPUNKNOWN  pUnkServer,
PCInterfaceName  name,
CInterfaceStubVtbl vtbl,
LPPSFACTORYBUFFER  pPSFactory,
LPRPCSTUBBUFFER ppStub 
)

Definition at line 55 of file cstub.c.

61{
63 IUnknown *pvServer;
64 HRESULT r;
65 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
66 TRACE("iid=%s\n", debugstr_guid(vtbl->header.piid));
67 TRACE("vtbl=%p\n", &vtbl->Vtbl);
68
69 if (!IsEqualGUID(vtbl->header.piid, riid)) {
70 ERR("IID mismatch during stub creation\n");
71 return RPC_E_UNEXPECTED;
72 }
73
74 r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
75 if(FAILED(r))
76 return r;
77
79 if (!This) {
80 IUnknown_Release(pvServer);
81 return E_OUTOFMEMORY;
82 }
83
84 This->lpVtbl = &vtbl->Vtbl;
85 This->RefCount = 1;
86 This->pvServerObject = pvServer;
87 This->pPSFactory = pPSFactory;
88 *ppStub = (LPRPCSTUBBUFFER)This;
89
90 IPSFactoryBuffer_AddRef(pPSFactory);
91 return S_OK;
92}
#define ERR(fmt,...)
Definition: debug.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
interface IRpcStubBuffer * LPRPCSTUBBUFFER
Definition: objfwd.h:41
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: name.c:39
const IID * piid
Definition: rpcproxy.h:96
CInterfaceStubHeader header
Definition: rpcproxy.h:104
IRpcStubBufferVtbl Vtbl
Definition: rpcproxy.h:105
#define RPC_E_UNEXPECTED
Definition: winerror.h:2509

Referenced by CStdPSFactory_CreateStub().

◆ CStdStubBuffer_CountRefs()

ULONG WINAPI CStdStubBuffer_CountRefs ( LPRPCSTUBBUFFER  iface)

Definition at line 530 of file cstub.c.

531{
533 TRACE("(%p)->CountRefs()\n",This);
534 return This->RefCount;
535}

Referenced by CStdStubBuffer_Delegating_CountRefs().

◆ CStdStubBuffer_DebugServerQueryInterface()

HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface ( LPRPCSTUBBUFFER  iface,
LPVOID ppv 
)

Definition at line 537 of file cstub.c.

539{
541 TRACE("(%p)->DebugServerQueryInterface(%p)\n",This,ppv);
542 return S_OK;
543}
REFIID LPVOID * ppv
Definition: atlbase.h:39

◆ CStdStubBuffer_DebugServerRelease()

void WINAPI CStdStubBuffer_DebugServerRelease ( LPRPCSTUBBUFFER  iface,
LPVOID  pv 
)

Definition at line 545 of file cstub.c.

547{
549 TRACE("(%p)->DebugServerRelease(%p)\n",This,pv);
550}

◆ CStdStubBuffer_Delegating_Connect()

static HRESULT WINAPI CStdStubBuffer_Delegating_Connect ( LPRPCSTUBBUFFER  iface,
LPUNKNOWN  lpUnkServer 
)
static

Definition at line 566 of file cstub.c.

568{
570 HRESULT r;
571 TRACE("(%p)->Connect(%p)\n", This, lpUnkServer);
572
573 r = CStdStubBuffer_Connect(iface, lpUnkServer);
574 if(SUCCEEDED(r))
575 r = IRpcStubBuffer_Connect(This->base_stub, (IUnknown*)&This->base_obj);
576
577 return r;
578}
static cstdstubbuffer_delegating_t * impl_from_delegating(IRpcStubBuffer *iface)
Definition: cstub.c:50
HRESULT WINAPI CStdStubBuffer_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN lpUnkServer)
Definition: cstub.c:463
#define SUCCEEDED(hr)
Definition: intsafe.h:50

◆ CStdStubBuffer_Delegating_Construct()

HRESULT CStdStubBuffer_Delegating_Construct ( REFIID  riid,
LPUNKNOWN  pUnkServer,
PCInterfaceName  name,
CInterfaceStubVtbl vtbl,
REFIID  delegating_iid,
LPPSFACTORYBUFFER  pPSFactory,
LPRPCSTUBBUFFER ppStub 
)

Definition at line 340 of file cstub.c.

347{
349 IUnknown *pvServer;
350 HRESULT r;
351
352 TRACE("(%p,%p,%p,%p) %s\n", pUnkServer, vtbl, pPSFactory, ppStub, name);
353 TRACE("iid=%s delegating to %s\n", debugstr_guid(vtbl->header.piid), debugstr_guid(delegating_iid));
354 TRACE("vtbl=%p\n", &vtbl->Vtbl);
355
356 if (!IsEqualGUID(vtbl->header.piid, riid))
357 {
358 ERR("IID mismatch during stub creation\n");
359 return RPC_E_UNEXPECTED;
360 }
361
362 r = IUnknown_QueryInterface(pUnkServer, riid, (void**)&pvServer);
363 if(FAILED(r)) return r;
364
366 if (!This)
367 {
368 IUnknown_Release(pvServer);
369 return E_OUTOFMEMORY;
370 }
371
373 r = create_stub(delegating_iid, (IUnknown*)&This->base_obj, &This->base_stub);
374 if(FAILED(r))
375 {
376 release_delegating_vtbl(This->base_obj);
378 IUnknown_Release(pvServer);
379 return r;
380 }
381
382 This->stub_buffer.lpVtbl = &vtbl->Vtbl;
383 This->stub_buffer.RefCount = 1;
384 This->stub_buffer.pvServerObject = pvServer;
385 This->stub_buffer.pPSFactory = pPSFactory;
386 *ppStub = (LPRPCSTUBBUFFER)&This->stub_buffer;
387
388 IPSFactoryBuffer_AddRef(pPSFactory);
389 return S_OK;
390}
HRESULT create_stub(REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub) DECLSPEC_HIDDEN
Definition: ndr_ole.c:466
#define HeapFree(x, y, z)
Definition: compat.h:735
void release_delegating_vtbl(IUnknownVtbl *vtbl)
Definition: cstub.c:325
IUnknownVtbl * get_delegating_vtbl(DWORD num_methods)
Definition: cstub.c:289

Referenced by CStdPSFactory_CreateStub().

◆ CStdStubBuffer_Delegating_CountRefs()

static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs ( LPRPCSTUBBUFFER  iface)
static

Definition at line 589 of file cstub.c.

590{
592 ULONG ret;
593 TRACE("(%p)->CountRefs()\n", This);
594
596 ret += IRpcStubBuffer_CountRefs(This->base_stub);
597
598 return ret;
599}
ULONG WINAPI CStdStubBuffer_CountRefs(LPRPCSTUBBUFFER iface)
Definition: cstub.c:530
uint32_t ULONG
Definition: typedefs.h:59
int ret

◆ CStdStubBuffer_Delegating_Disconnect()

static void WINAPI CStdStubBuffer_Delegating_Disconnect ( LPRPCSTUBBUFFER  iface)
static

Definition at line 580 of file cstub.c.

581{
583 TRACE("(%p)->Disconnect()\n", This);
584
585 IRpcStubBuffer_Disconnect(This->base_stub);
587}
void WINAPI CStdStubBuffer_Disconnect(LPRPCSTUBBUFFER iface)
Definition: cstub.c:479

◆ CStdStubBuffer_Disconnect()

void WINAPI CStdStubBuffer_Disconnect ( LPRPCSTUBBUFFER  iface)

Definition at line 479 of file cstub.c.

480{
482 IUnknown *old;
483 TRACE("(%p)->Disconnect()\n",This);
484
485 old = InterlockedExchangePointer((void**)&This->pvServerObject, NULL);
486
487 if(old)
488 IUnknown_Release(old);
489}

Referenced by CStdStubBuffer_Delegating_Disconnect().

◆ CStdStubBuffer_GetServerInfo()

const MIDL_SERVER_INFO * CStdStubBuffer_GetServerInfo ( IRpcStubBuffer iface)

Definition at line 615 of file cstub.c.

616{
618 return STUB_HEADER(This).pServerInfo;
619}

Referenced by NdrStubCall2().

◆ CStdStubBuffer_Invoke()

HRESULT WINAPI CStdStubBuffer_Invoke ( LPRPCSTUBBUFFER  iface,
PRPCOLEMESSAGE  pMsg,
LPRPCCHANNELBUFFER  pChannel 
)

Definition at line 491 of file cstub.c.

494{
496 DWORD dwPhase = STUB_UNMARSHAL;
497 HRESULT hr = S_OK;
498
499 TRACE("(%p)->Invoke(%p,%p)\n",This,pMsg,pChannel);
500
501 __TRY
502 {
503 if (STUB_HEADER(This).pDispatchTable)
504 STUB_HEADER(This).pDispatchTable[pMsg->iMethod](iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
505 else /* pure interpreted */
506 NdrStubCall2(iface, pChannel, (PRPC_MESSAGE)pMsg, &dwPhase);
507 }
509 {
510 DWORD dwExceptionCode = GetExceptionCode();
511 WARN("a stub call failed with exception 0x%08x (%d)\n", dwExceptionCode, dwExceptionCode);
512 if (FAILED(dwExceptionCode))
513 hr = dwExceptionCode;
514 else
515 hr = HRESULT_FROM_WIN32(dwExceptionCode);
516 }
518
519 return hr;
520}
#define WARN(fmt,...)
Definition: debug.h:112
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
static LONG WINAPI stub_filter(EXCEPTION_POINTERS *eptr)
Definition: cstub.c:43
LONG WINAPI NdrStubCall2(struct IRpcStubBuffer *pThis, struct IRpcChannelBuffer *pChannel, PRPC_MESSAGE pRpcMsg, DWORD *pdwStubPhase)
#define __EXCEPT(func)
Definition: exception.h:84
struct _RPC_MESSAGE * PRPC_MESSAGE
@ STUB_UNMARSHAL
Definition: rpcndr.h:448
#define GetExceptionCode()
Definition: seh.h:27
HRESULT hr
Definition: shlfolder.c:183
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92

◆ CStdStubBuffer_IsIIDSupported()

LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported ( LPRPCSTUBBUFFER  iface,
REFIID  riid 
)

Definition at line 522 of file cstub.c.

524{
526 TRACE("(%p)->IsIIDSupported(%s)\n",This,debugstr_guid(riid));
527 return IsEqualGUID(STUB_HEADER(This).piid, riid) ? iface : NULL;
528}

◆ CStdStubBuffer_QueryInterface()

HRESULT WINAPI CStdStubBuffer_QueryInterface ( LPRPCSTUBBUFFER  iface,
REFIID  riid,
LPVOID obj 
)

Definition at line 392 of file cstub.c.

395{
397 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(riid),obj);
398
400 IsEqualIID(&IID_IRpcStubBuffer, riid))
401 {
402 IRpcStubBuffer_AddRef(iface);
403 *obj = iface;
404 return S_OK;
405 }
406 *obj = NULL;
407 return E_NOINTERFACE;
408}
const GUID IID_IUnknown
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ delegating_AddRef()

static ULONG WINAPI delegating_AddRef ( IUnknown pUnk)
static

Definition at line 120 of file cstub.c.

121{
122 return 1;
123}

Referenced by fill_delegated_stub_table().

◆ delegating_QueryInterface()

static HRESULT WINAPI delegating_QueryInterface ( IUnknown pUnk,
REFIID  iid,
void **  ppv 
)
static

Definition at line 114 of file cstub.c.

115{
116 *ppv = pUnk;
117 return S_OK;
118}
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by fill_delegated_stub_table().

◆ delegating_Release()

static ULONG WINAPI delegating_Release ( IUnknown pUnk)
static

Definition at line 125 of file cstub.c.

126{
127 return 1;
128}

Referenced by fill_delegated_stub_table().

◆ fill_delegated_proxy_table()

BOOL fill_delegated_proxy_table ( IUnknownVtbl *  vtbl,
DWORD  num 
)

Definition at line 266 of file cstub.c.

267{
268 const void **entry = (const void **)(vtbl + 1);
269 DWORD i, j;
270
271 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
272 {
273 FIXME( "%u methods not supported\n", num );
274 return FALSE;
275 }
276 vtbl->QueryInterface = IUnknown_QueryInterface_Proxy;
278 vtbl->Release = IUnknown_Release_Proxy;
279 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
280 {
282 if (!block && !(block = allocate_block( i ))) return FALSE;
283 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++, entry++)
284 if (!*entry) *entry = &block[j];
285 }
286 return TRUE;
287}
#define FIXME(fmt,...)
Definition: debug.h:111
ULONG WINAPI IUnknown_AddRef_Proxy(LPUNKNOWN iface)
Definition: cproxy.c:478
ULONG WINAPI IUnknown_Release_Proxy(LPUNKNOWN iface)
Definition: cproxy.c:485
HRESULT WINAPI IUnknown_QueryInterface_Proxy(LPUNKNOWN iface, REFIID riid, LPVOID *ppvObj)
Definition: cproxy.c:469
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const vtbl_method_t * allocate_block(unsigned int num)
Definition: cstub.c:219
#define MAX_BLOCKS
Definition: cstub.c:215
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 GLint GLint j
Definition: glfuncs.h:250
ULONG AddRef()
uint32_t entry
Definition: isohybrid.c:63

Referenced by CreateProxyFromTypeInfo(), and init_psfactory().

◆ fill_delegated_stub_table()

static BOOL fill_delegated_stub_table ( IUnknownVtbl *  vtbl,
DWORD  num 
)
static

Definition at line 244 of file cstub.c.

245{
246 const void **entry = (const void **)(vtbl + 1);
247 DWORD i, j;
248
249 if (num - 3 > BLOCK_SIZE * MAX_BLOCKS)
250 {
251 FIXME( "%u methods not supported\n", num );
252 return FALSE;
253 }
254 vtbl->QueryInterface = delegating_QueryInterface;
256 vtbl->Release = delegating_Release;
257 for (i = 0; i < (num - 3 + BLOCK_SIZE - 1) / BLOCK_SIZE; i++)
258 {
260 if (!block && !(block = allocate_block( i ))) return FALSE;
261 for (j = 0; j < BLOCK_SIZE && j < num - 3 - i * BLOCK_SIZE; j++) *entry++ = &block[j];
262 }
263 return TRUE;
264}
static HRESULT WINAPI delegating_QueryInterface(IUnknown *pUnk, REFIID iid, void **ppv)
Definition: cstub.c:114
static ULONG WINAPI delegating_Release(IUnknown *pUnk)
Definition: cstub.c:125
static ULONG WINAPI delegating_AddRef(IUnknown *pUnk)
Definition: cstub.c:120

Referenced by get_delegating_vtbl().

◆ get_delegating_vtbl()

IUnknownVtbl * get_delegating_vtbl ( DWORD  num_methods)

Definition at line 289 of file cstub.c.

290{
291 IUnknownVtbl *ret;
292
293 if (num_methods < 256) num_methods = 256; /* avoid frequent reallocations */
294
296
297 if(!current_vtbl || num_methods > current_vtbl->size)
298 {
300 FIELD_OFFSET(ref_counted_vtbl, vtbl) + num_methods * sizeof(void*));
301 if (!table)
302 {
304 return NULL;
305 }
306
307 table->ref = 0;
308 table->size = num_methods;
309 fill_delegated_stub_table(&table->vtbl, num_methods);
310
311 if (current_vtbl && current_vtbl->ref == 0)
312 {
313 TRACE("freeing old table\n");
315 }
317 }
318
319 current_vtbl->ref++;
322 return ret;
323}
static CRITICAL_SECTION delegating_vtbl_section
Definition: cstub.c:94
static BOOL fill_delegated_stub_table(IUnknownVtbl *vtbl, DWORD num)
Definition: cstub.c:244
static ref_counted_vtbl * current_vtbl
Definition: cstub.c:111
DWORD size
Definition: cstub.c:106
IUnknownVtbl vtbl
Definition: cstub.c:107
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by CStdStubBuffer_Delegating_Construct(), and typelib_stub_init().

◆ impl_from_delegating()

static cstdstubbuffer_delegating_t * impl_from_delegating ( IRpcStubBuffer iface)
inlinestatic

Definition at line 50 of file cstub.c.

51{
52 return CONTAINING_RECORD((void *)iface, cstdstubbuffer_delegating_t, stub_buffer);
53}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by CStdStubBuffer_Delegating_Connect(), CStdStubBuffer_Delegating_CountRefs(), CStdStubBuffer_Delegating_Disconnect(), NdrCStdStubBuffer2_Release(), and NdrStubForwardingFunction().

◆ NdrCStdStubBuffer2_Release()

ULONG WINAPI NdrCStdStubBuffer2_Release ( LPRPCSTUBBUFFER  iface,
LPPSFACTORYBUFFER  pPSF 
)

Definition at line 438 of file cstub.c.

440{
442 ULONG refs;
443
444 TRACE("(%p)->Release()\n", This);
445
446 refs = InterlockedDecrement(&This->stub_buffer.RefCount);
447 if (!refs)
448 {
449 /* Just like NdrCStdStubBuffer_Release, we shouldn't call
450 Disconnect here */
451 IRpcStubBuffer_Disconnect((IRpcStubBuffer *)&This->stub_buffer);
452
453 IRpcStubBuffer_Release(This->base_stub);
454 release_delegating_vtbl(This->base_obj);
455
456 IPSFactoryBuffer_Release(pPSF);
458 }
459
460 return refs;
461}
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by test_CStdStubBuffer2_Release().

◆ NdrCStdStubBuffer_Release()

ULONG WINAPI NdrCStdStubBuffer_Release ( LPRPCSTUBBUFFER  iface,
LPPSFACTORYBUFFER  pPSF 
)

Definition at line 417 of file cstub.c.

419{
421 ULONG refs;
422
423 TRACE("(%p)->Release()\n",This);
424
425 refs = InterlockedDecrement(&This->RefCount);
426 if (!refs)
427 {
428 /* test_Release shows that native doesn't call Disconnect here.
429 We'll leave it in for the time being. */
430 IRpcStubBuffer_Disconnect(iface);
431
432 IPSFactoryBuffer_Release(pPSF);
434 }
435 return refs;
436}

Referenced by test_CStdStubBuffer_Release(), and test_Release().

◆ NdrStubForwardingFunction()

void __RPC_STUB NdrStubForwardingFunction ( IRpcStubBuffer iface,
IRpcChannelBuffer pChannel,
PRPC_MESSAGE  pMsg,
DWORD pdwStubPhase 
)

Definition at line 624 of file cstub.c.

626{
627 /* Note pMsg is passed intact since RPCOLEMESSAGE is basically a RPC_MESSAGE. */
628
630 HRESULT r = IRpcStubBuffer_Invoke(This->base_stub, (RPCOLEMESSAGE*)pMsg, pChannel);
632 return;
633}
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:188

Referenced by CreateStubFromTypeInfo(), and test_NdrStubForwardingFunction().

◆ NdrStubGetBuffer()

void WINAPI NdrStubGetBuffer ( LPRPCSTUBBUFFER  iface,
LPRPCCHANNELBUFFER  pRpcChannelBuffer,
PMIDL_STUB_MESSAGE  pStubMsg 
)

Definition at line 654 of file cstub.c.

657{
659 HRESULT hr;
660
661 TRACE("(%p, %p, %p)\n", This, pRpcChannelBuffer, pStubMsg);
662
663 pStubMsg->RpcMsg->BufferLength = pStubMsg->BufferLength;
664 hr = IRpcChannelBuffer_GetBuffer(pRpcChannelBuffer,
665 (RPCOLEMESSAGE *)pStubMsg->RpcMsg, STUB_HEADER(This).piid);
666 if (FAILED(hr))
667 {
669 return;
670 }
671
672 pStubMsg->Buffer = pStubMsg->RpcMsg->Buffer;
673}
unsigned char * Buffer
Definition: rpcndr.h:203
ULONG BufferLength
Definition: rpcndr.h:207
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned int BufferLength
Definition: rpcdcep.h:41
void * Buffer
Definition: rpcdcep.h:40

Referenced by NdrStubCall2().

◆ NdrStubInitialize()

void WINAPI NdrStubInitialize ( PRPC_MESSAGE  pRpcMsg,
PMIDL_STUB_MESSAGE  pStubMsg,
PMIDL_STUB_DESC  pStubDescriptor,
LPRPCCHANNELBUFFER  pRpcChannelBuffer 
)

Definition at line 638 of file cstub.c.

642{
643 TRACE("(%p,%p,%p,%p)\n", pRpcMsg, pStubMsg, pStubDescriptor, pRpcChannelBuffer);
644 NdrServerInitializeNew(pRpcMsg, pStubMsg, pStubDescriptor);
645 pStubMsg->pRpcChannelBuffer = pRpcChannelBuffer;
646 IRpcChannelBuffer_GetDestCtx(pStubMsg->pRpcChannelBuffer,
647 &pStubMsg->dwDestContext,
648 &pStubMsg->pvDestContext);
649}
unsigned char *WINAPI NdrServerInitializeNew(PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDesc)
void * pvDestContext
Definition: rpcndr.h:250
struct IRpcChannelBuffer * pRpcChannelBuffer
Definition: rpcndr.h:253
DWORD dwDestContext
Definition: rpcndr.h:249

Referenced by NdrStubCall2().

◆ release_delegating_vtbl()

void release_delegating_vtbl ( IUnknownVtbl *  vtbl)

Definition at line 325 of file cstub.c.

326{
327 ref_counted_vtbl *table = (ref_counted_vtbl*)((DWORD *)vtbl - 1);
328
330 table->ref--;
331 TRACE("ref now %d\n", table->ref);
332 if(table->ref == 0 && table != current_vtbl)
333 {
334 TRACE("... and we're not current so free'ing\n");
336 }
338}

Referenced by CStdStubBuffer_Delegating_Construct(), NdrCStdStubBuffer2_Release(), typelib_stub_init(), and typelib_stub_Release().

◆ stub_filter()

static LONG WINAPI stub_filter ( EXCEPTION_POINTERS eptr)
static

Definition at line 43 of file cstub.c.

44{
48}
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
PEXCEPTION_RECORD ExceptionRecord
Definition: rtltypes.h:200
DWORD ExceptionFlags
Definition: compat.h:209
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23

Referenced by CStdStubBuffer_Invoke().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, { (DWORD_PTR)(__FILE__ ": delegating_vtbl_section") }
}
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: cstub.c:95
LIST_ENTRY ProcessLocksList
Definition: winbase.h:883
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 95 of file cstub.c.

◆ CStdStubBuffer_Delegating_Vtbl

const IRpcStubBufferVtbl CStdStubBuffer_Delegating_Vtbl
Initial value:
=
{
}
static void WINAPI CStdStubBuffer_Delegating_Disconnect(LPRPCSTUBBUFFER iface)
Definition: cstub.c:580
void WINAPI CStdStubBuffer_DebugServerRelease(LPRPCSTUBBUFFER iface, LPVOID pv)
Definition: cstub.c:545
HRESULT WINAPI CStdStubBuffer_QueryInterface(LPRPCSTUBBUFFER iface, REFIID riid, LPVOID *obj)
Definition: cstub.c:392
ULONG WINAPI CStdStubBuffer_AddRef(LPRPCSTUBBUFFER iface)
Definition: cstub.c:410
static ULONG WINAPI CStdStubBuffer_Delegating_CountRefs(LPRPCSTUBBUFFER iface)
Definition: cstub.c:589
static HRESULT WINAPI CStdStubBuffer_Delegating_Connect(LPRPCSTUBBUFFER iface, LPUNKNOWN lpUnkServer)
Definition: cstub.c:566
LPRPCSTUBBUFFER WINAPI CStdStubBuffer_IsIIDSupported(LPRPCSTUBBUFFER iface, REFIID riid)
Definition: cstub.c:522
HRESULT WINAPI CStdStubBuffer_Invoke(LPRPCSTUBBUFFER iface, PRPCOLEMESSAGE pMsg, LPRPCCHANNELBUFFER pChannel)
Definition: cstub.c:491
HRESULT WINAPI CStdStubBuffer_DebugServerQueryInterface(LPRPCSTUBBUFFER iface, LPVOID *ppv)
Definition: cstub.c:537

Definition at line 601 of file cstub.c.

Referenced by CreateStubFromTypeInfo(), and init_psfactory().

◆ CStdStubBuffer_Vtbl

◆ current_vtbl

ref_counted_vtbl* current_vtbl
static

Definition at line 111 of file cstub.c.

Referenced by get_delegating_vtbl(), and release_delegating_vtbl().

◆ delegating_vtbl_section

static CRITICAL_SECTION delegating_vtbl_section = { &critsect_debug, -1, 0, 0, 0, 0 }
static

Definition at line 94 of file cstub.c.

Referenced by get_delegating_vtbl(), and release_delegating_vtbl().

◆ method_blocks

const vtbl_method_t* method_blocks[MAX_BLOCKS]
static

Definition at line 217 of file cstub.c.

Referenced by allocate_block(), fill_delegated_proxy_table(), and fill_delegated_stub_table().

◆ opcodes

const BYTE opcodes[1]
static

Definition at line 210 of file cstub.c.

Referenced by allocate_block().