ReactOS  0.4.13-dev-92-gf251225
ndr_clientserver.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "objbase.h"
#include "rpcproxy.h"
#include "wine/debug.h"
#include "ndr_misc.h"
#include "rpcndr.h"
Include dependency graph for ndr_clientserver.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (rpc)
 
void WINAPI NdrClientInitializeNew (PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDesc, unsigned int ProcNum)
 
unsigned char *WINAPI NdrServerInitializeNew (PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg, PMIDL_STUB_DESC pStubDesc)
 
unsigned char *WINAPI NdrGetBuffer (PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC_BINDING_HANDLE handle)
 
void WINAPI NdrFreeBuffer (PMIDL_STUB_MESSAGE pStubMsg)
 
unsigned char *WINAPI NdrSendReceive (PMIDL_STUB_MESSAGE stubmsg, unsigned char *buffer)
 
RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus (PMIDL_STUB_MESSAGE pStubMsg, ULONG *pCommStatus, ULONG *pFaultStatus, RPC_STATUS Status)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 27 of file ndr_clientserver.c.

Function Documentation

◆ NdrClientInitializeNew()

void WINAPI NdrClientInitializeNew ( PRPC_MESSAGE  pRpcMessage,
PMIDL_STUB_MESSAGE  pStubMsg,
PMIDL_STUB_DESC  pStubDesc,
unsigned int  ProcNum 
)

Definition at line 47 of file ndr_clientserver.c.

49 {
50  TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n",
51  pRpcMessage, pStubMsg, pStubDesc, ProcNum);
52 
53  pRpcMessage->Handle = NULL;
54  pRpcMessage->ProcNum = ProcNum | RPC_FLAGS_VALID_BIT;
55  pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
56  pRpcMessage->RpcFlags = 0;
57  pRpcMessage->ReservedForRuntime = NULL;
59 
60  pStubMsg->RpcMsg = pRpcMessage;
61  pStubMsg->BufferStart = NULL;
62  pStubMsg->BufferEnd = NULL;
63  pStubMsg->BufferLength = 0;
64  pStubMsg->IsClient = TRUE;
65  pStubMsg->ReuseBuffer = FALSE;
66  pStubMsg->pAllocAllNodesContext = NULL;
67  pStubMsg->pPointerQueueState = NULL;
68  pStubMsg->IgnoreEmbeddedPointers = 0;
69  pStubMsg->PointerBufferMark = NULL;
70  pStubMsg->CorrDespIncrement = 0;
71  pStubMsg->uFlags = 0;
72  pStubMsg->UniquePtrCount = 0;
73  pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
74  pStubMsg->pfnFree = pStubDesc->pfnFree;
75  pStubMsg->StackTop = NULL;
76  pStubMsg->StubDesc = pStubDesc;
77  pStubMsg->FullPtrRefId = 0;
78  pStubMsg->PointerLength = 0;
79  pStubMsg->fInDontFree = 0;
80  pStubMsg->fDontCallFreeInst = 0;
81  pStubMsg->fInOnlyParam = 0;
82  pStubMsg->fHasReturn = 0;
83  pStubMsg->fHasExtensions = 0;
84  pStubMsg->fHasNewCorrDesc = 0;
85  pStubMsg->fIsIn = 0;
86  pStubMsg->fIsOut = 0;
87  pStubMsg->fIsOicf = 0;
88  pStubMsg->fBufferValid = 0;
89  pStubMsg->fHasMemoryValidateCallback = 0;
90  pStubMsg->fInFree = 0;
91  pStubMsg->fNeedMCCP = 0;
92  pStubMsg->fUnused = 0;
93  pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
94  pStubMsg->pvDestContext = NULL;
95  pStubMsg->pRpcChannelBuffer = NULL;
96  pStubMsg->pArrayInfo = NULL;
97  pStubMsg->dwStubPhase = 0;
98  /* FIXME: LowStackMark */
99  pStubMsg->pAsyncMsg = NULL;
100  pStubMsg->pCorrInfo = NULL;
101  pStubMsg->pCorrMemory = NULL;
102  pStubMsg->pMemoryList = NULL;
103 }
void * RpcInterfaceInformation
Definition: rpcdcep.h:44
void * RpcInterfaceInformation
Definition: rpcndr.h:362
unsigned int fInDontFree
Definition: rpcndr.h:234
#define TRUE
Definition: types.h:120
unsigned char * pCorrMemory
Definition: rpcndr.h:263
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned char * PointerBufferMark
Definition: rpcndr.h:217
unsigned short UniquePtrCount
Definition: rpcndr.h:220
PARRAY_INFO pArrayInfo
Definition: rpcndr.h:254
int IgnoreEmbeddedPointers
Definition: rpcndr.h:216
DWORD dwDestContext
Definition: rpcndr.h:249
struct NDR_POINTER_QUEUE_STATE * pPointerQueueState
Definition: rpcndr.h:215
unsigned int ProcNum
Definition: rpcdcep.h:42
smooth NULL
Definition: ftsmooth.c:416
unsigned int fHasNewCorrDesc
Definition: rpcndr.h:239
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwStubPhase
Definition: rpcndr.h:259
void * pvDestContext
Definition: rpcndr.h:250
ULONG RpcFlags
Definition: rpcdcep.h:48
void * ReservedForRuntime
Definition: rpcdcep.h:45
unsigned char * BufferStart
Definition: rpcndr.h:204
void * pMemoryList
Definition: rpcndr.h:264
ULONG BufferLength
Definition: rpcndr.h:207
unsigned char * BufferEnd
Definition: rpcndr.h:205
unsigned int fBufferValid
Definition: rpcndr.h:243
unsigned int fIsOut
Definition: rpcndr.h:241
unsigned int fNeedMCCP
Definition: rpcndr.h:246
PNDR_ASYNC_MESSAGE pAsyncMsg
Definition: rpcndr.h:261
unsigned int fIsOicf
Definition: rpcndr.h:242
unsigned int fIsIn
Definition: rpcndr.h:240
unsigned int fInFree
Definition: rpcndr.h:245
unsigned int fDontCallFreeInst
Definition: rpcndr.h:235
#define NDR_LOCAL_DATA_REPRESENTATION
Definition: rpcndr.h:107
PNDR_CORRELATION_INFO pCorrInfo
Definition: rpcndr.h:262
unsigned char IsClient
Definition: rpcndr.h:210
struct NDR_ALLOC_ALL_NODES_CONTEXT * pAllocAllNodesContext
Definition: rpcndr.h:214
unsigned char * StackTop
Definition: rpcndr.h:226
unsigned int fHasReturn
Definition: rpcndr.h:237
unsigned int fHasMemoryValidateCallback
Definition: rpcndr.h:244
#define RPC_FLAGS_VALID_BIT
Definition: rpcdcep.h:52
unsigned char CorrDespIncrement
Definition: rpcndr.h:218
unsigned int fInOnlyParam
Definition: rpcndr.h:236
unsigned char uFlags
Definition: rpcndr.h:219
ULONG DataRepresentation
Definition: rpcdcep.h:39
ULONG FullPtrRefId
Definition: rpcndr.h:232
RPC_BINDING_HANDLE Handle
Definition: rpcdcep.h:38
struct IRpcChannelBuffer * pRpcChannelBuffer
Definition: rpcndr.h:253
unsigned int fHasExtensions
Definition: rpcndr.h:238
ULONG PointerLength
Definition: rpcndr.h:233

Referenced by CtxClose(), CtxHello(), CtxOpen(), determine_pointer_marshalling_style(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), ndr_async_client_call(), ndr_client_call(), NdrProxyInitialize(), test_client_init(), test_conf_complex_array(), test_conf_complex_struct(), test_conformant_array(), test_conformant_string(), test_iface_ptr(), test_ndr_allocate(), test_ndr_buffer(), test_ndr_simple_type(), test_NdrMapCommAndFaultStatus(), test_nonconformant_string(), test_nontrivial_pointer_types(), test_pointer_marshal(), test_simple_struct_marshal(), and test_struct_align().

◆ NdrFreeBuffer()

void WINAPI NdrFreeBuffer ( PMIDL_STUB_MESSAGE  pStubMsg)

Definition at line 184 of file ndr_clientserver.c.

185 {
186  TRACE("(pStubMsg == ^%p)\n", pStubMsg);
187  if (pStubMsg->fBufferValid)
188  {
189  I_RpcFreeBuffer(pStubMsg->RpcMsg);
190  pStubMsg->fBufferValid = FALSE;
191  }
192 }
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1696
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int fBufferValid
Definition: rpcndr.h:243

Referenced by CtxClose(), CtxHello(), CtxOpen(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), ndr_client_call(), NdrpCompleteAsyncClientCall(), and test_ndr_buffer().

◆ NdrGetBuffer()

unsigned char* WINAPI NdrGetBuffer ( PMIDL_STUB_MESSAGE  stubmsg,
ULONG  buflen,
RPC_BINDING_HANDLE  handle 
)

Definition at line 163 of file ndr_clientserver.c.

164 {
166 
167  TRACE("(stubmsg == ^%p, buflen == %u, handle == %p)\n", stubmsg, buflen, handle);
168 
169  stubmsg->RpcMsg->Handle = handle;
170  stubmsg->RpcMsg->BufferLength = buflen;
171 
172  status = I_RpcGetBuffer(stubmsg->RpcMsg);
173  if (status != RPC_S_OK)
175 
176  stubmsg->Buffer = stubmsg->RpcMsg->Buffer;
177  stubmsg->fBufferValid = TRUE;
178  stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
179  return stubmsg->Buffer;
180 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
unsigned char * Buffer
Definition: rpcndr.h:203
RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1638
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned int BufferLength
Definition: rpcdcep.h:41
long RPC_STATUS
Definition: rpc.h:52
void * Buffer
Definition: rpcdcep.h:40
#define TRACE(s)
Definition: solgame.cpp:4
ULONG BufferLength
Definition: rpcndr.h:207
unsigned int fBufferValid
Definition: rpcndr.h:243
static SERVICE_STATUS status
Definition: service.c:31
RPC_BINDING_HANDLE Handle
Definition: rpcdcep.h:38
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by CtxClose(), CtxHello(), CtxOpen(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), ndr_async_client_call(), ndr_client_call(), and test_ndr_buffer().

◆ NdrMapCommAndFaultStatus()

RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus ( PMIDL_STUB_MESSAGE  pStubMsg,
ULONG pCommStatus,
ULONG pFaultStatus,
RPC_STATUS  Status 
)

Definition at line 231 of file ndr_clientserver.c.

235 {
236  TRACE("(%p, %p, %p, %d)\n", pStubMsg, pCommStatus, pFaultStatus, Status);
237 
238  switch (Status)
239  {
242  case RPC_S_UNKNOWN_IF:
251  case RPC_S_COMM_FAILURE:
252  *pCommStatus = Status;
253  *pFaultStatus = 0;
254  break;
255  default:
256  *pCommStatus = 0;
257  *pFaultStatus = Status;
258  }
259 
260  return RPC_S_OK;
261 }
#define RPC_S_UNKNOWN_IF
Definition: winerror.h:1028
#define RPC_S_UNSUPPORTED_TRANS_SYN
Definition: winerror.h:1040
#define RPC_S_PROCNUM_OUT_OF_RANGE
Definition: winerror.h:1053
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define RPC_S_CALL_FAILED_DNE
Definition: winerror.h:1038
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1013
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
#define RPC_S_UNSUPPORTED_TYPE
Definition: winerror.h:1041
#define TRACE(s)
Definition: solgame.cpp:4
#define RPC_S_COMM_FAILURE
Definition: winerror.h:1127
Status
Definition: gdiplustypes.h:24
#define RPC_S_SERVER_TOO_BUSY
Definition: winerror.h:1034
#define EPT_S_NOT_REGISTERED
Definition: winerror.h:1061
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by ndr_client_call(), and test_NdrMapCommAndFaultStatus().

◆ NdrSendReceive()

unsigned char* WINAPI NdrSendReceive ( PMIDL_STUB_MESSAGE  stubmsg,
unsigned char buffer 
)

Definition at line 197 of file ndr_clientserver.c.

198 {
200 
201  TRACE("(stubmsg == ^%p, buffer == ^%p)\n", stubmsg, buffer);
202 
203  /* FIXME: how to handle errors? (raise exception?) */
204  if (!stubmsg) {
205  ERR("NULL stub message. No action taken.\n");
206  return NULL;
207  }
208  if (!stubmsg->RpcMsg) {
209  ERR("RPC Message not present in stub message. No action taken.\n");
210  return NULL;
211  }
212 
213  /* avoid sending uninitialised parts of the buffer on the wire */
214  stubmsg->RpcMsg->BufferLength = buffer - (unsigned char *)stubmsg->RpcMsg->Buffer;
215  status = I_RpcSendReceive(stubmsg->RpcMsg);
216  if (status != RPC_S_OK)
218 
219  stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
220  stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
221  stubmsg->BufferEnd = stubmsg->BufferStart + stubmsg->BufferLength;
222  stubmsg->Buffer = stubmsg->BufferStart;
223 
224  /* FIXME: is this the right return value? */
225  return NULL;
226 }
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:189
unsigned char * Buffer
Definition: rpcndr.h:203
GLuint buffer
Definition: glext.h:5915
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned int BufferLength
Definition: rpcdcep.h:41
long RPC_STATUS
Definition: rpc.h:52
void * Buffer
Definition: rpcdcep.h:40
RPC_STATUS WINAPI I_RpcSendReceive(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1918
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char * BufferStart
Definition: rpcndr.h:204
ULONG BufferLength
Definition: rpcndr.h:207
unsigned char * BufferEnd
Definition: rpcndr.h:205
#define ERR(fmt,...)
Definition: debug.h:109
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by CtxClose(), CtxHello(), CtxOpen(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), and ndr_client_call().

◆ NdrServerInitializeNew()

unsigned char* WINAPI NdrServerInitializeNew ( PRPC_MESSAGE  pRpcMsg,
PMIDL_STUB_MESSAGE  pStubMsg,
PMIDL_STUB_DESC  pStubDesc 
)

Definition at line 108 of file ndr_clientserver.c.

110 {
111  TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc);
112 
113  pStubMsg->RpcMsg = pRpcMsg;
114  pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;
115  pStubMsg->BufferEnd = pStubMsg->Buffer + pRpcMsg->BufferLength;
116  pStubMsg->BufferLength = pRpcMsg->BufferLength;
117  pStubMsg->IsClient = FALSE;
118  pStubMsg->ReuseBuffer = FALSE;
119  pStubMsg->pAllocAllNodesContext = NULL;
120  pStubMsg->pPointerQueueState = NULL;
121  pStubMsg->IgnoreEmbeddedPointers = 0;
122  pStubMsg->PointerBufferMark = NULL;
123  pStubMsg->CorrDespIncrement = 0;
124  pStubMsg->uFlags = 0;
125  pStubMsg->UniquePtrCount = 0;
126  pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
127  pStubMsg->pfnFree = pStubDesc->pfnFree;
128  pStubMsg->StackTop = NULL;
129  pStubMsg->StubDesc = pStubDesc;
130  pStubMsg->FullPtrXlatTables = NULL;
131  pStubMsg->FullPtrRefId = 0;
132  pStubMsg->PointerLength = 0;
133  pStubMsg->fInDontFree = 0;
134  pStubMsg->fDontCallFreeInst = 0;
135  pStubMsg->fInOnlyParam = 0;
136  pStubMsg->fHasReturn = 0;
137  pStubMsg->fHasExtensions = 0;
138  pStubMsg->fHasNewCorrDesc = 0;
139  pStubMsg->fIsIn = 0;
140  pStubMsg->fIsOut = 0;
141  pStubMsg->fIsOicf = 0;
142  pStubMsg->fHasMemoryValidateCallback = 0;
143  pStubMsg->fInFree = 0;
144  pStubMsg->fNeedMCCP = 0;
145  pStubMsg->fUnused = 0;
146  pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
147  pStubMsg->pvDestContext = NULL;
148  pStubMsg->pRpcChannelBuffer = NULL;
149  pStubMsg->pArrayInfo = NULL;
150  pStubMsg->dwStubPhase = 0;
151  /* FIXME: LowStackMark */
152  pStubMsg->pAsyncMsg = NULL;
153  pStubMsg->pCorrInfo = NULL;
154  pStubMsg->pCorrMemory = NULL;
155  pStubMsg->pMemoryList = NULL;
156 
157  return NULL;
158 }
unsigned int fInDontFree
Definition: rpcndr.h:234
unsigned char * Buffer
Definition: rpcndr.h:203
unsigned char * pCorrMemory
Definition: rpcndr.h:263
struct _FULL_PTR_XLAT_TABLES * FullPtrXlatTables
Definition: rpcndr.h:231
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:230
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:202
unsigned char * PointerBufferMark
Definition: rpcndr.h:217
unsigned int BufferLength
Definition: rpcdcep.h:41
void * Buffer
Definition: rpcdcep.h:40
unsigned short UniquePtrCount
Definition: rpcndr.h:220
PARRAY_INFO pArrayInfo
Definition: rpcndr.h:254
int IgnoreEmbeddedPointers
Definition: rpcndr.h:216
DWORD dwDestContext
Definition: rpcndr.h:249
struct NDR_POINTER_QUEUE_STATE * pPointerQueueState
Definition: rpcndr.h:215
smooth NULL
Definition: ftsmooth.c:416
unsigned int fHasNewCorrDesc
Definition: rpcndr.h:239
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwStubPhase
Definition: rpcndr.h:259
void * pvDestContext
Definition: rpcndr.h:250
unsigned char * BufferStart
Definition: rpcndr.h:204
void * pMemoryList
Definition: rpcndr.h:264
ULONG BufferLength
Definition: rpcndr.h:207
unsigned char * BufferEnd
Definition: rpcndr.h:205
unsigned int fIsOut
Definition: rpcndr.h:241
unsigned int fNeedMCCP
Definition: rpcndr.h:246
PNDR_ASYNC_MESSAGE pAsyncMsg
Definition: rpcndr.h:261
unsigned int fIsOicf
Definition: rpcndr.h:242
unsigned int fIsIn
Definition: rpcndr.h:240
unsigned int fInFree
Definition: rpcndr.h:245
unsigned int fDontCallFreeInst
Definition: rpcndr.h:235
PNDR_CORRELATION_INFO pCorrInfo
Definition: rpcndr.h:262
unsigned char IsClient
Definition: rpcndr.h:210
struct NDR_ALLOC_ALL_NODES_CONTEXT * pAllocAllNodesContext
Definition: rpcndr.h:214
unsigned char * StackTop
Definition: rpcndr.h:226
unsigned int fHasReturn
Definition: rpcndr.h:237
unsigned int fHasMemoryValidateCallback
Definition: rpcndr.h:244
unsigned char CorrDespIncrement
Definition: rpcndr.h:218
unsigned int fInOnlyParam
Definition: rpcndr.h:236
unsigned char uFlags
Definition: rpcndr.h:219
ULONG FullPtrRefId
Definition: rpcndr.h:232
struct IRpcChannelBuffer * pRpcChannelBuffer
Definition: rpcndr.h:253
unsigned int fHasExtensions
Definition: rpcndr.h:238
ULONG PointerLength
Definition: rpcndr.h:233

Referenced by hello_CtxClose(), hello_CtxHello(), hello_CtxOpen(), NdrStubCall2(), NdrStubInitialize(), and test_server_init().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( rpc  )