ReactOS  0.4.13-dev-464-g6b95727
ndr_ole.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "objbase.h"
#include "ndr_misc.h"
#include "rpcndr.h"
#include "ndrtypes.h"
#include "rpcproxy.h"
#include "cpsf.h"
#include "wine/debug.h"
Include dependency graph for ndr_ole.c:

Go to the source code of this file.

Classes

struct  RpcStreamImpl
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 

Typedefs

typedef struct RpcStreamImpl RpcStreamImpl
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static HRESULT (WINAPI *COM_GetMarshalSizeMax)(ULONG *
 
static COSERVERINFO LPVOID *static CLSID *static LPVOID (WINAPI *COM_MemAlloc)(ULONG)
 
static void (WINAPI *COM_MemFree)(LPVOID)
 
static HMODULE LoadCOM (void)
 
static RpcStreamImplimpl_from_IStream (IStream *iface)
 
static HRESULT WINAPI RpcStream_QueryInterface (LPSTREAM iface, REFIID riid, LPVOID *obj)
 
static ULONG WINAPI RpcStream_AddRef (LPSTREAM iface)
 
static ULONG WINAPI RpcStream_Release (LPSTREAM iface)
 
static HRESULT WINAPI RpcStream_Read (LPSTREAM iface, void *pv, ULONG cb, ULONG *pcbRead)
 
static HRESULT WINAPI RpcStream_Write (LPSTREAM iface, const void *pv, ULONG cb, ULONG *pcbWritten)
 
static HRESULT WINAPI RpcStream_Seek (LPSTREAM iface, LARGE_INTEGER move, DWORD origin, ULARGE_INTEGER *newPos)
 
static HRESULT WINAPI RpcStream_SetSize (LPSTREAM iface, ULARGE_INTEGER newSize)
 
static HRESULT WINAPI RpcStream_CopyTo (IStream *iface, IStream *dest, ULARGE_INTEGER len, ULARGE_INTEGER *read, ULARGE_INTEGER *written)
 
static HRESULT WINAPI RpcStream_Commit (IStream *iface, DWORD flags)
 
static HRESULT WINAPI RpcStream_Revert (IStream *iface)
 
static HRESULT WINAPI RpcStream_LockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
 
static HRESULT WINAPI RpcStream_UnlockRegion (IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
 
static HRESULT WINAPI RpcStream_Stat (IStream *iface, STATSTG *stat, DWORD flag)
 
static HRESULT WINAPI RpcStream_Clone (IStream *iface, IStream **cloned)
 
static HRESULT RpcStream_Create (PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *size, IStream **stream)
 
static const IIDget_ip_iid (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrInterfacePointerMarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
unsigned char *WINAPI NdrInterfacePointerUnmarshall (PMIDL_STUB_MESSAGE pStubMsg, unsigned char **ppMemory, PFORMAT_STRING pFormat, unsigned char fMustAlloc)
 
void WINAPI NdrInterfacePointerBufferSize (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
ULONG WINAPI NdrInterfacePointerMemorySize (PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat)
 
void WINAPI NdrInterfacePointerFree (PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
 
void *WINAPI NdrOleAllocate (SIZE_T Size)
 
void WINAPI NdrOleFree (void *NodeToFree)
 
HRESULT create_proxy (REFIID iid, IUnknown *pUnkOuter, IRpcProxyBuffer **pproxy, void **ppv)
 
HRESULT create_stub (REFIID iid, IUnknown *pUnk, IRpcStubBuffer **ppstub)
 

Variables

static HMODULE hOLE
 
static REFIID
 
static LPUNKNOWN =NULL
 
static DWORD
 
static LPVOID
 
static const IStreamVtbl RpcStream_Vtbl
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 28 of file ndr_ole.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 29 of file ndr_ole.c.

Typedef Documentation

◆ RpcStreamImpl

Function Documentation

◆ create_proxy()

HRESULT create_proxy ( REFIID  iid,
IUnknown pUnkOuter,
IRpcProxyBuffer **  pproxy,
void **  ppv 
)

Definition at line 442 of file ndr_ole.c.

443 {
444  CLSID clsid;
445  IPSFactoryBuffer *psfac;
446  HRESULT r;
447 
448  if(!LoadCOM()) return E_FAIL;
449 
450  r = COM_GetPSClsid( iid, &clsid );
451  if(FAILED(r)) return r;
452 
453  r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac );
454  if(FAILED(r)) return r;
455 
456  r = IPSFactoryBuffer_CreateProxy(psfac, pUnkOuter, iid, pproxy, ppv);
457 
458  IPSFactoryBuffer_Release(psfac);
459  return r;
460 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58

Referenced by StdProxy_Construct(), and typelib_proxy_init().

◆ create_stub()

HRESULT create_stub ( REFIID  iid,
IUnknown pUnk,
IRpcStubBuffer **  ppstub 
)

Definition at line 466 of file ndr_ole.c.

467 {
468  CLSID clsid;
469  IPSFactoryBuffer *psfac;
470  HRESULT r;
471 
472  if(!LoadCOM()) return E_FAIL;
473 
474  r = COM_GetPSClsid( iid, &clsid );
475  if(FAILED(r)) return r;
476 
477  r = COM_GetClassObject( &clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IPSFactoryBuffer, (void**)&psfac );
478  if(FAILED(r)) return r;
479 
480  r = IPSFactoryBuffer_CreateStub(psfac, iid, pUnk, ppstub);
481 
482  IPSFactoryBuffer_Release(psfac);
483  return r;
484 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define E_FAIL
Definition: ddrawi.h:102
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
REFCLSID clsid
Definition: msctf.c:84
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by typelib_stub_init().

◆ get_ip_iid()

static const IID* get_ip_iid ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)
static

Definition at line 286 of file ndr_ole.c.

287 {
288  const IID *riid;
289  if (!pFormat) return &IID_IUnknown;
290  TRACE("format=%02x %02x\n", pFormat[0], pFormat[1]);
291  if (pFormat[0] != FC_IP) FIXME("format=%d\n", pFormat[0]);
292  if (pFormat[1] == FC_CONSTANT_IID) {
293  riid = (const IID *)&pFormat[2];
294  } else {
295  ComputeConformance(pStubMsg, pMemory, pFormat+2, 0);
296  riid = (const IID *)pStubMsg->MaxCount;
297  }
298  if (!riid) riid = &IID_IUnknown;
299  TRACE("got %s\n", debugstr_guid(riid));
300  return riid;
301 }
static PFORMAT_STRING ComputeConformance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat, ULONG def)
Definition: ndr_misc.h:37
REFIID riid
Definition: precomp.h:44
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
ULONG_PTR MaxCount
Definition: rpcndr.h:221
const GUID IID_IUnknown

Referenced by NdrInterfacePointerBufferSize(), and NdrInterfacePointerMarshall().

◆ HRESULT()

static HRESULT ( WINAPI COM_GetMarshalSizeMax)
static

◆ impl_from_IStream()

static RpcStreamImpl* impl_from_IStream ( IStream iface)
inlinestatic

Definition at line 87 of file ndr_ole.c.

88 {
89  return CONTAINING_RECORD(iface, RpcStreamImpl, IStream_iface);
90 }
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

Referenced by RpcStream_AddRef(), RpcStream_Clone(), RpcStream_Commit(), RpcStream_CopyTo(), RpcStream_LockRegion(), RpcStream_Read(), RpcStream_Release(), RpcStream_Revert(), RpcStream_Seek(), RpcStream_SetSize(), RpcStream_Stat(), RpcStream_UnlockRegion(), and RpcStream_Write().

◆ LoadCOM()

static HMODULE LoadCOM ( void  )
static

Definition at line 58 of file ndr_ole.c.

59 {
60  if (hOLE) return hOLE;
61  hOLE = LoadLibraryA("OLE32.DLL");
62  if (!hOLE) return 0;
63  COM_GetMarshalSizeMax = (LPVOID)GetProcAddress(hOLE, "CoGetMarshalSizeMax");
64  COM_MarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoMarshalInterface");
65  COM_UnmarshalInterface = (LPVOID)GetProcAddress(hOLE, "CoUnmarshalInterface");
66  COM_ReleaseMarshalData = (LPVOID)GetProcAddress(hOLE, "CoReleaseMarshalData");
67  COM_GetClassObject = (LPVOID)GetProcAddress(hOLE, "CoGetClassObject");
68  COM_GetPSClsid = (LPVOID)GetProcAddress(hOLE, "CoGetPSClsid");
69  COM_MemAlloc = (LPVOID)GetProcAddress(hOLE, "CoTaskMemAlloc");
70  COM_MemFree = (LPVOID)GetProcAddress(hOLE, "CoTaskMemFree");
71  return hOLE;
72 }
static HMODULE hOLE
Definition: ndr_ole.c:47
static LPVOID
Definition: ndr_ole.c:49
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by create_proxy(), create_stub(), NdrInterfacePointerBufferSize(), NdrInterfacePointerMarshall(), NdrInterfacePointerUnmarshall(), NdrOleAllocate(), and NdrOleFree().

◆ LPVOID()

static COSERVERINFO LPVOID* static CLSID* static LPVOID ( WINAPI COM_MemAlloc)
static

◆ NdrInterfacePointerBufferSize()

void WINAPI NdrInterfacePointerBufferSize ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 373 of file ndr_ole.c.

376 {
377  const IID *riid = get_ip_iid(pStubMsg, pMemory, pFormat);
378  ULONG size = 0;
379 
380  TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
381  if (!LoadCOM()) return;
382  COM_GetMarshalSizeMax(&size, riid, (LPUNKNOWN)pMemory,
383  pStubMsg->dwDestContext, pStubMsg->pvDestContext,
384  MSHLFLAGS_NORMAL);
385  TRACE("size=%d\n", size);
386  pStubMsg->BufferLength += sizeof(DWORD) + size;
387 }
static DWORD
Definition: ndr_ole.c:49
REFIID riid
Definition: precomp.h:44
static const IID * get_ip_iid(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
Definition: ndr_ole.c:286
static LPUNKNOWN
Definition: ndr_ole.c:49
DWORD dwDestContext
Definition: rpcndr.h:249
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
void * pvDestContext
Definition: rpcndr.h:250
ULONG BufferLength
Definition: rpcndr.h:207
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58
unsigned int ULONG
Definition: retypes.h:1

Referenced by test_iface_ptr().

◆ NdrInterfacePointerFree()

void WINAPI NdrInterfacePointerFree ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 411 of file ndr_ole.c.

414 {
415  LPUNKNOWN pUnk = (LPUNKNOWN)pMemory;
416  TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
417  if (pUnk) IUnknown_Release(pUnk);
418 }
static LPUNKNOWN
Definition: ndr_ole.c:49
#define TRACE(s)
Definition: solgame.cpp:4
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30

Referenced by test_iface_ptr().

◆ NdrInterfacePointerMarshall()

unsigned char* WINAPI NdrInterfacePointerMarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char pMemory,
PFORMAT_STRING  pFormat 
)

Definition at line 306 of file ndr_ole.c.

309 {
310  const IID *riid = get_ip_iid(pStubMsg, pMemory, pFormat);
312  HRESULT hr;
313 
314  TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
315  pStubMsg->MaxCount = 0;
316  if (!LoadCOM()) return NULL;
317  if (pStubMsg->Buffer + sizeof(DWORD) <= (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) {
318  hr = RpcStream_Create(pStubMsg, TRUE, NULL, &stream);
319  if (hr == S_OK) {
320  if (pMemory)
321  hr = COM_MarshalInterface(stream, riid, (LPUNKNOWN)pMemory,
322  pStubMsg->dwDestContext, pStubMsg->pvDestContext,
323  MSHLFLAGS_NORMAL);
324  IStream_Release(stream);
325  }
326 
327  if (FAILED(hr))
329  }
330  return NULL;
331 }
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
REFIID riid
Definition: precomp.h:44
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
unsigned char * Buffer
Definition: rpcndr.h:203
interface IStream * LPSTREAM
Definition: objfwd.h:10
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
static const IID * get_ip_iid(PMIDL_STUB_MESSAGE pStubMsg, unsigned char *pMemory, PFORMAT_STRING pFormat)
Definition: ndr_ole.c:286
void * Buffer
Definition: rpcdcep.h:40
static LPUNKNOWN
Definition: ndr_ole.c:49
DWORD dwDestContext
Definition: rpcndr.h:249
smooth NULL
Definition: ftsmooth.c:416
static HRESULT RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *size, IStream **stream)
Definition: ndr_ole.c:265
#define TRACE(s)
Definition: solgame.cpp:4
ULONG_PTR MaxCount
Definition: rpcndr.h:221
void * pvDestContext
Definition: rpcndr.h:250
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG BufferLength
Definition: rpcndr.h:207
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define S_OK
Definition: intsafe.h:59
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58

Referenced by test_iface_ptr().

◆ NdrInterfacePointerMemorySize()

ULONG WINAPI NdrInterfacePointerMemorySize ( PMIDL_STUB_MESSAGE  pStubMsg,
PFORMAT_STRING  pFormat 
)

Definition at line 392 of file ndr_ole.c.

394 {
395  ULONG size;
396 
397  TRACE("(%p,%p)\n", pStubMsg, pFormat);
398 
399  size = *(ULONG *)pStubMsg->Buffer;
400  pStubMsg->Buffer += 4;
401  pStubMsg->MemorySize += 4;
402 
403  pStubMsg->Buffer += size;
404 
405  return pStubMsg->MemorySize;
406 }
ULONG MemorySize
Definition: rpcndr.h:208
unsigned char * Buffer
Definition: rpcndr.h:203
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned int ULONG
Definition: retypes.h:1

◆ NdrInterfacePointerUnmarshall()

unsigned char* WINAPI NdrInterfacePointerUnmarshall ( PMIDL_STUB_MESSAGE  pStubMsg,
unsigned char **  ppMemory,
PFORMAT_STRING  pFormat,
unsigned char  fMustAlloc 
)

Definition at line 336 of file ndr_ole.c.

340 {
341  IUnknown **unk = (IUnknown **)ppMemory;
343  HRESULT hr;
344 
345  TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
346  if (!LoadCOM()) return NULL;
347 
348  /* Avoid reference leaks for [in, out] pointers. */
349  if (pStubMsg->IsClient && *unk)
350  IUnknown_Release(*unk);
351 
352  *unk = NULL;
353  if (pStubMsg->Buffer + sizeof(DWORD) < (unsigned char *)pStubMsg->RpcMsg->Buffer + pStubMsg->BufferLength) {
354  ULONG size;
355 
356  hr = RpcStream_Create(pStubMsg, FALSE, &size, &stream);
357  if (hr == S_OK) {
358  if (size != 0)
359  hr = COM_UnmarshalInterface(stream, &IID_NULL, (void **)unk);
360 
361  IStream_Release(stream);
362  }
363 
364  if (FAILED(hr))
366  }
367  return NULL;
368 }
HRESULT hr
Definition: shlfolder.c:183
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
unsigned char * Buffer
Definition: rpcndr.h:203
interface IStream * LPSTREAM
Definition: objfwd.h:10
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
void * Buffer
Definition: rpcdcep.h:40
smooth NULL
Definition: ftsmooth.c:416
static HRESULT RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init, ULONG *size, IStream **stream)
Definition: ndr_ole.c:265
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG BufferLength
Definition: rpcndr.h:207
#define IID_NULL
Definition: guiddef.h:93
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
#define S_OK
Definition: intsafe.h:59
unsigned char IsClient
Definition: rpcndr.h:210
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58
unsigned int ULONG
Definition: retypes.h:1

Referenced by test_iface_ptr().

◆ NdrOleAllocate()

void* WINAPI NdrOleAllocate ( SIZE_T  Size)

Definition at line 423 of file ndr_ole.c.

424 {
425  if (!LoadCOM()) return NULL;
426  return COM_MemAlloc(Size);
427 }
smooth NULL
Definition: ftsmooth.c:416
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58

Referenced by init_stub_desc(), and my_alloc().

◆ NdrOleFree()

void WINAPI NdrOleFree ( void NodeToFree)

Definition at line 432 of file ndr_ole.c.

433 {
434  if (!LoadCOM()) return;
435  COM_MemFree(NodeToFree);
436 }
static HMODULE LoadCOM(void)
Definition: ndr_ole.c:58

Referenced by init_stub_desc(), my_free(), and test_nonconformant_string().

◆ RpcStream_AddRef()

static ULONG WINAPI RpcStream_AddRef ( LPSTREAM  iface)
static

Definition at line 108 of file ndr_ole.c.

109 {
111  return InterlockedIncrement( &This->RefCount );
112 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define InterlockedIncrement
Definition: armddk.h:53

◆ RpcStream_Clone()

static HRESULT WINAPI RpcStream_Clone ( IStream iface,
IStream **  cloned 
)
static

Definition at line 240 of file ndr_ole.c.

241 {
243  FIXME("(%p): stub\n", This);
244  return E_NOTIMPL;
245 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_Commit()

static HRESULT WINAPI RpcStream_Commit ( IStream iface,
DWORD  flags 
)
static

Definition at line 203 of file ndr_ole.c.

204 {
206  FIXME("(%p)->(0x%08x): stub\n", This, flags);
207  return E_NOTIMPL;
208 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
GLbitfield flags
Definition: glext.h:7161
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_CopyTo()

static HRESULT WINAPI RpcStream_CopyTo ( IStream iface,
IStream dest,
ULARGE_INTEGER  len,
ULARGE_INTEGER read,
ULARGE_INTEGER written 
)
static

Definition at line 195 of file ndr_ole.c.

197 {
199  FIXME("(%p): stub\n", This);
200  return E_NOTIMPL;
201 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_Create()

static HRESULT RpcStream_Create ( PMIDL_STUB_MESSAGE  pStubMsg,
BOOL  init,
ULONG size,
IStream **  stream 
)
static

Definition at line 265 of file ndr_ole.c.

266 {
268 
269  *stream = NULL;
270  This = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcStreamImpl));
271  if (!This) return E_OUTOFMEMORY;
272  This->IStream_iface.lpVtbl = &RpcStream_Vtbl;
273  This->RefCount = 1;
274  This->pMsg = pStubMsg;
275  This->size = (LPDWORD)pStubMsg->Buffer;
276  This->data = pStubMsg->Buffer + sizeof(DWORD);
277  This->pos = 0;
278  if (init) *This->size = 0;
279  TRACE("init size=%d\n", *This->size);
280 
281  if (size) *size = *This->size;
282  *stream = &This->IStream_iface;
283  return S_OK;
284 }
unsigned char * Buffer
Definition: rpcndr.h:203
static int init
Definition: wintirpc.c:33
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LPDWORD
Definition: nt_native.h:46
Definition: parse.h:22
static const IStreamVtbl RpcStream_Vtbl
Definition: ndr_ole.c:247
#define S_OK
Definition: intsafe.h:59

Referenced by NdrInterfacePointerMarshall(), and NdrInterfacePointerUnmarshall().

◆ RpcStream_LockRegion()

static HRESULT WINAPI RpcStream_LockRegion ( IStream iface,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  len,
DWORD  locktype 
)
static

Definition at line 217 of file ndr_ole.c.

219 {
221  FIXME("(%p): stub\n", This);
222  return E_NOTIMPL;
223 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_QueryInterface()

static HRESULT WINAPI RpcStream_QueryInterface ( LPSTREAM  iface,
REFIID  riid,
LPVOID obj 
)
static

Definition at line 92 of file ndr_ole.c.

95 {
96  if (IsEqualGUID(&IID_IUnknown, riid) ||
97  IsEqualGUID(&IID_ISequentialStream, riid) ||
98  IsEqualGUID(&IID_IStream, riid)) {
99  *obj = iface;
100  IStream_AddRef(iface);
101  return S_OK;
102  }
103 
104  *obj = NULL;
105  return E_NOINTERFACE;
106 }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021

◆ RpcStream_Read()

static HRESULT WINAPI RpcStream_Read ( LPSTREAM  iface,
void pv,
ULONG  cb,
ULONG pcbRead 
)
static

Definition at line 126 of file ndr_ole.c.

130 {
132  HRESULT hr = S_OK;
133  if (This->pos + cb > *This->size)
134  {
135  cb = *This->size - This->pos;
136  hr = S_FALSE;
137  }
138  if (cb) {
139  memcpy(pv, This->data + This->pos, cb);
140  This->pos += cb;
141  }
142  if (pcbRead) *pcbRead = cb;
143  return hr;
144 }
HRESULT hr
Definition: shlfolder.c:183
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define S_FALSE
Definition: winerror.h:2357
LONG HRESULT
Definition: typedefs.h:77
static DWORD cb
Definition: integrity.c:41
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59

◆ RpcStream_Release()

static ULONG WINAPI RpcStream_Release ( LPSTREAM  iface)
static

Definition at line 114 of file ndr_ole.c.

115 {
117  ULONG ref = InterlockedDecrement( &This->RefCount );
118  if (!ref) {
119  TRACE("size=%d\n", *This->size);
120  This->pMsg->Buffer = This->data + *This->size;
122  }
123  return ref;
124 }
Definition: send.c:47
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
GLenum GLint ref
Definition: glext.h:6028
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394

◆ RpcStream_Revert()

static HRESULT WINAPI RpcStream_Revert ( IStream iface)
static

Definition at line 210 of file ndr_ole.c.

211 {
213  FIXME("(%p): stub\n", This);
214  return E_NOTIMPL;
215 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_Seek()

static HRESULT WINAPI RpcStream_Seek ( LPSTREAM  iface,
LARGE_INTEGER  move,
DWORD  origin,
ULARGE_INTEGER newPos 
)
static

Definition at line 161 of file ndr_ole.c.

165 {
167  switch (origin) {
168  case STREAM_SEEK_SET:
169  This->pos = move.u.LowPart;
170  break;
171  case STREAM_SEEK_CUR:
172  This->pos = This->pos + move.u.LowPart;
173  break;
174  case STREAM_SEEK_END:
175  This->pos = *This->size + move.u.LowPart;
176  break;
177  default:
178  return STG_E_INVALIDFUNCTION;
179  }
180  if (newPos) {
181  newPos->u.LowPart = This->pos;
182  newPos->u.HighPart = 0;
183  }
184  return S_OK;
185 }
struct _ULARGE_INTEGER::@3741 u
voidpf uLong int origin
Definition: ioapi.h:142
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define STG_E_INVALIDFUNCTION
Definition: winerror.h:2564
#define S_OK
Definition: intsafe.h:59
struct _LARGE_INTEGER::@2196 u

◆ RpcStream_SetSize()

static HRESULT WINAPI RpcStream_SetSize ( LPSTREAM  iface,
ULARGE_INTEGER  newSize 
)
static

Definition at line 187 of file ndr_ole.c.

189 {
191  *This->size = newSize.u.LowPart;
192  return S_OK;
193 }
struct _ULARGE_INTEGER::@3741 u
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define S_OK
Definition: intsafe.h:59

◆ RpcStream_Stat()

static HRESULT WINAPI RpcStream_Stat ( IStream iface,
STATSTG *  stat,
DWORD  flag 
)
static

Definition at line 233 of file ndr_ole.c.

234 {
236  FIXME("(%p): stub\n", This);
237  return E_NOTIMPL;
238 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_UnlockRegion()

static HRESULT WINAPI RpcStream_UnlockRegion ( IStream iface,
ULARGE_INTEGER  offset,
ULARGE_INTEGER  len,
DWORD  locktype 
)
static

Definition at line 225 of file ndr_ole.c.

227 {
229  FIXME("(%p): stub\n", This);
230  return E_NOTIMPL;
231 }
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
#define FIXME(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ RpcStream_Write()

static HRESULT WINAPI RpcStream_Write ( LPSTREAM  iface,
const void pv,
ULONG  cb,
ULONG pcbWritten 
)
static

Definition at line 146 of file ndr_ole.c.

150 {
152  if (This->data + cb > (unsigned char *)This->pMsg->RpcMsg->Buffer + This->pMsg->BufferLength)
153  return STG_E_MEDIUMFULL;
154  memcpy(This->data + This->pos, pv, cb);
155  This->pos += cb;
156  if (This->pos > *This->size) *This->size = This->pos;
157  if (pcbWritten) *pcbWritten = cb;
158  return S_OK;
159 }
#define STG_E_MEDIUMFULL
Definition: winerror.h:2581
static RpcStreamImpl * impl_from_IStream(IStream *iface)
Definition: ndr_ole.c:87
static DWORD cb
Definition: integrity.c:41
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define S_OK
Definition: intsafe.h:59

◆ void()

static void ( WINAPI COM_MemFree)
static

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ DWORD

Definition at line 49 of file ndr_ole.c.

Referenced by NdrInterfacePointerBufferSize().

◆ hOLE

HMODULE hOLE
static

Definition at line 47 of file ndr_ole.c.

Referenced by LoadCOM().

◆ LPUNKNOWN

◆ LPVOID

Definition at line 49 of file ndr_ole.c.

Referenced by LoadCOM().

◆ REFIID

COSERVERINFO REFIID

Definition at line 49 of file ndr_ole.c.

◆ RpcStream_Vtbl

const IStreamVtbl RpcStream_Vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI RpcStream_CopyTo(IStream *iface, IStream *dest, ULARGE_INTEGER len, ULARGE_INTEGER *read, ULARGE_INTEGER *written)
Definition: ndr_ole.c:195
static ULONG WINAPI RpcStream_AddRef(LPSTREAM iface)
Definition: ndr_ole.c:108
static HRESULT WINAPI RpcStream_Revert(IStream *iface)
Definition: ndr_ole.c:210
static HRESULT WINAPI RpcStream_UnlockRegion(IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
Definition: ndr_ole.c:225
static HRESULT WINAPI RpcStream_Write(LPSTREAM iface, const void *pv, ULONG cb, ULONG *pcbWritten)
Definition: ndr_ole.c:146
static HRESULT WINAPI RpcStream_Commit(IStream *iface, DWORD flags)
Definition: ndr_ole.c:203
static HRESULT WINAPI RpcStream_Read(LPSTREAM iface, void *pv, ULONG cb, ULONG *pcbRead)
Definition: ndr_ole.c:126
static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface, REFIID riid, LPVOID *obj)
Definition: ndr_ole.c:92
static HRESULT WINAPI RpcStream_Stat(IStream *iface, STATSTG *stat, DWORD flag)
Definition: ndr_ole.c:233
static HRESULT WINAPI RpcStream_Clone(IStream *iface, IStream **cloned)
Definition: ndr_ole.c:240
static HRESULT WINAPI RpcStream_SetSize(LPSTREAM iface, ULARGE_INTEGER newSize)
Definition: ndr_ole.c:187
static HRESULT WINAPI RpcStream_LockRegion(IStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER len, DWORD locktype)
Definition: ndr_ole.c:217
static HRESULT WINAPI RpcStream_Seek(LPSTREAM iface, LARGE_INTEGER move, DWORD origin, ULARGE_INTEGER *newPos)
Definition: ndr_ole.c:161
static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
Definition: ndr_ole.c:114

Definition at line 247 of file ndr_ole.c.

Referenced by RpcStream_Create().