mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 20:30:01 +00:00
rpcrt4: Use an iface instead of a vtbl pointer in RpcStreamImpl.
This commit is contained in:
parent
adbcfb7e5c
commit
c38d6fed39
@ -78,7 +78,7 @@ static HMODULE LoadCOM(void)
|
|||||||
* (which also implements the MInterfacePointer structure) */
|
* (which also implements the MInterfacePointer structure) */
|
||||||
typedef struct RpcStreamImpl
|
typedef struct RpcStreamImpl
|
||||||
{
|
{
|
||||||
const IStreamVtbl *lpVtbl;
|
IStream IStream_iface;
|
||||||
LONG RefCount;
|
LONG RefCount;
|
||||||
PMIDL_STUB_MESSAGE pMsg;
|
PMIDL_STUB_MESSAGE pMsg;
|
||||||
LPDWORD size;
|
LPDWORD size;
|
||||||
@ -86,11 +86,16 @@ typedef struct RpcStreamImpl
|
|||||||
DWORD pos;
|
DWORD pos;
|
||||||
} RpcStreamImpl;
|
} RpcStreamImpl;
|
||||||
|
|
||||||
|
static inline RpcStreamImpl *impl_from_IStream(IStream *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, RpcStreamImpl, IStream_iface);
|
||||||
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface,
|
static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface,
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
LPVOID *obj)
|
LPVOID *obj)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
if (IsEqualGUID(&IID_IUnknown, riid) ||
|
if (IsEqualGUID(&IID_IUnknown, riid) ||
|
||||||
IsEqualGUID(&IID_ISequentialStream, riid) ||
|
IsEqualGUID(&IID_ISequentialStream, riid) ||
|
||||||
IsEqualGUID(&IID_IStream, riid)) {
|
IsEqualGUID(&IID_IStream, riid)) {
|
||||||
@ -103,13 +108,13 @@ static HRESULT WINAPI RpcStream_QueryInterface(LPSTREAM iface,
|
|||||||
|
|
||||||
static ULONG WINAPI RpcStream_AddRef(LPSTREAM iface)
|
static ULONG WINAPI RpcStream_AddRef(LPSTREAM iface)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
return InterlockedIncrement( &This->RefCount );
|
return InterlockedIncrement( &This->RefCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
|
static ULONG WINAPI RpcStream_Release(LPSTREAM iface)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
ULONG ref = InterlockedDecrement( &This->RefCount );
|
ULONG ref = InterlockedDecrement( &This->RefCount );
|
||||||
if (!ref) {
|
if (!ref) {
|
||||||
TRACE("size=%d\n", *This->size);
|
TRACE("size=%d\n", *This->size);
|
||||||
@ -125,7 +130,7 @@ static HRESULT WINAPI RpcStream_Read(LPSTREAM iface,
|
|||||||
ULONG cb,
|
ULONG cb,
|
||||||
ULONG *pcbRead)
|
ULONG *pcbRead)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
if (This->pos + cb > *This->size)
|
if (This->pos + cb > *This->size)
|
||||||
{
|
{
|
||||||
@ -145,7 +150,7 @@ static HRESULT WINAPI RpcStream_Write(LPSTREAM iface,
|
|||||||
ULONG cb,
|
ULONG cb,
|
||||||
ULONG *pcbWritten)
|
ULONG *pcbWritten)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
if (This->data + cb > (unsigned char *)This->pMsg->RpcMsg->Buffer + This->pMsg->BufferLength)
|
if (This->data + cb > (unsigned char *)This->pMsg->RpcMsg->Buffer + This->pMsg->BufferLength)
|
||||||
return STG_E_MEDIUMFULL;
|
return STG_E_MEDIUMFULL;
|
||||||
memcpy(This->data + This->pos, pv, cb);
|
memcpy(This->data + This->pos, pv, cb);
|
||||||
@ -160,7 +165,7 @@ static HRESULT WINAPI RpcStream_Seek(LPSTREAM iface,
|
|||||||
DWORD origin,
|
DWORD origin,
|
||||||
ULARGE_INTEGER *newPos)
|
ULARGE_INTEGER *newPos)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case STREAM_SEEK_SET:
|
case STREAM_SEEK_SET:
|
||||||
This->pos = move.u.LowPart;
|
This->pos = move.u.LowPart;
|
||||||
@ -184,7 +189,7 @@ static HRESULT WINAPI RpcStream_Seek(LPSTREAM iface,
|
|||||||
static HRESULT WINAPI RpcStream_SetSize(LPSTREAM iface,
|
static HRESULT WINAPI RpcStream_SetSize(LPSTREAM iface,
|
||||||
ULARGE_INTEGER newSize)
|
ULARGE_INTEGER newSize)
|
||||||
{
|
{
|
||||||
RpcStreamImpl *This = (RpcStreamImpl *)iface;
|
RpcStreamImpl *This = impl_from_IStream(iface);
|
||||||
*This->size = newSize.u.LowPart;
|
*This->size = newSize.u.LowPart;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@ -212,7 +217,7 @@ static LPSTREAM RpcStream_Create(PMIDL_STUB_MESSAGE pStubMsg, BOOL init)
|
|||||||
RpcStreamImpl *This;
|
RpcStreamImpl *This;
|
||||||
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(RpcStreamImpl));
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(RpcStreamImpl));
|
||||||
if (!This) return NULL;
|
if (!This) return NULL;
|
||||||
This->lpVtbl = &RpcStream_Vtbl;
|
This->IStream_iface.lpVtbl = &RpcStream_Vtbl;
|
||||||
This->RefCount = 1;
|
This->RefCount = 1;
|
||||||
This->pMsg = pStubMsg;
|
This->pMsg = pStubMsg;
|
||||||
This->size = (LPDWORD)pStubMsg->Buffer;
|
This->size = (LPDWORD)pStubMsg->Buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user