ReactOS 0.4.16-dev-1946-g52006dd
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->fHasReturn = 0;
82 pStubMsg->fHasExtensions = 0;
83 pStubMsg->fHasNewCorrDesc = 0;
84 pStubMsg->fIsIn = 0;
85 pStubMsg->fIsOut = 0;
86 pStubMsg->fIsOicf = 0;
87 pStubMsg->fBufferValid = 0;
88 pStubMsg->fHasMemoryValidateCallback = 0;
89 pStubMsg->fInFree = 0;
90 pStubMsg->fNeedMCCP = 0;
91 pStubMsg->fUnused2 = 0;
92 pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
93 pStubMsg->pvDestContext = NULL;
94 pStubMsg->pRpcChannelBuffer = NULL;
95 pStubMsg->pArrayInfo = NULL;
96 pStubMsg->dwStubPhase = 0;
97 /* FIXME: LowStackMark */
98 pStubMsg->pAsyncMsg = NULL;
99 pStubMsg->pCorrInfo = NULL;
100 pStubMsg->pCorrMemory = NULL;
101 pStubMsg->pMemoryList = NULL;
102}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RPC_FLAGS_VALID_BIT
Definition: rpcdcep.h:52
#define NDR_LOCAL_DATA_REPRESENTATION
Definition: rpcndr.h:68
#define TRACE(s)
Definition: solgame.cpp:4
void * RpcInterfaceInformation
Definition: rpcndr.h:378
unsigned int fIsOicf
Definition: rpcndr.h:225
ULONG PointerLength
Definition: rpcndr.h:216
PNDR_CORRELATION_INFO pCorrInfo
Definition: rpcndr.h:245
unsigned char * StackTop
Definition: rpcndr.h:209
unsigned char CorrDespIncrement
Definition: rpcndr.h:201
unsigned int fIsIn
Definition: rpcndr.h:223
unsigned int fBufferValid
Definition: rpcndr.h:226
unsigned int fDontCallFreeInst
Definition: rpcndr.h:218
struct NDR_POINTER_QUEUE_STATE * pPointerQueueState
Definition: rpcndr.h:198
void * pvDestContext
Definition: rpcndr.h:233
DWORD dwStubPhase
Definition: rpcndr.h:242
unsigned int fNeedMCCP
Definition: rpcndr.h:229
ULONG FullPtrRefId
Definition: rpcndr.h:215
struct IRpcChannelBuffer * pRpcChannelBuffer
Definition: rpcndr.h:236
void * pMemoryList
Definition: rpcndr.h:247
PNDR_ASYNC_MESSAGE pAsyncMsg
Definition: rpcndr.h:244
unsigned int fHasReturn
Definition: rpcndr.h:220
unsigned int fHasExtensions
Definition: rpcndr.h:221
unsigned int fInFree
Definition: rpcndr.h:228
PARRAY_INFO pArrayInfo
Definition: rpcndr.h:237
ULONG BufferLength
Definition: rpcndr.h:190
int IgnoreEmbeddedPointers
Definition: rpcndr.h:199
unsigned char * BufferEnd
Definition: rpcndr.h:188
DWORD dwDestContext
Definition: rpcndr.h:232
unsigned int fHasMemoryValidateCallback
Definition: rpcndr.h:227
unsigned char * pCorrMemory
Definition: rpcndr.h:246
unsigned char uFlags
Definition: rpcndr.h:202
PRPC_MESSAGE RpcMsg
Definition: rpcndr.h:185
const struct _MIDL_STUB_DESC * StubDesc
Definition: rpcndr.h:213
unsigned char IsClient
Definition: rpcndr.h:193
unsigned char * BufferStart
Definition: rpcndr.h:187
unsigned int fHasNewCorrDesc
Definition: rpcndr.h:222
struct NDR_ALLOC_ALL_NODES_CONTEXT * pAllocAllNodesContext
Definition: rpcndr.h:197
unsigned char * PointerBufferMark
Definition: rpcndr.h:200
unsigned short UniquePtrCount
Definition: rpcndr.h:203
unsigned int fIsOut
Definition: rpcndr.h:224
unsigned int fInDontFree
Definition: rpcndr.h:217
unsigned int ProcNum
Definition: rpcdcep.h:42
void * RpcInterfaceInformation
Definition: rpcdcep.h:44
ULONG DataRepresentation
Definition: rpcdcep.h:39
void * ReservedForRuntime
Definition: rpcdcep.h:45
RPC_BINDING_HANDLE Handle
Definition: rpcdcep.h:38
ULONG RpcFlags
Definition: rpcdcep.h:48

Referenced by CtxClose(), CtxHello(), CtxOpen(), determine_pointer_marshalling_style(), do_ndr_async_client_call(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), 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 182 of file ndr_clientserver.c.

183{
184 TRACE("(pStubMsg == ^%p)\n", pStubMsg);
185 if (pStubMsg->fBufferValid)
186 {
187 I_RpcFreeBuffer(pStubMsg->RpcMsg);
188 pStubMsg->fBufferValid = FALSE;
189 }
190}
RPC_STATUS WINAPI I_RpcFreeBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1692

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

◆ NdrGetBuffer()

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

Definition at line 161 of file ndr_clientserver.c.

162{
164
165 TRACE("(stubmsg == ^%p, buflen == %lu, handle == %p)\n", stubmsg, buflen, handle);
166
167 stubmsg->RpcMsg->Handle = handle;
168 stubmsg->RpcMsg->BufferLength = buflen;
169
170 status = I_RpcGetBuffer(stubmsg->RpcMsg);
171 if (status != RPC_S_OK)
173
174 stubmsg->Buffer = stubmsg->RpcMsg->Buffer;
175 stubmsg->fBufferValid = TRUE;
176 stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
177 return stubmsg->Buffer;
178}
RPC_STATUS WINAPI I_RpcGetBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1634
#define RPC_S_OK
Definition: rpcnterr.h:22
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:213
long RPC_STATUS
Definition: rpc.h:48
unsigned char * Buffer
Definition: rpcndr.h:186
unsigned int BufferLength
Definition: rpcdcep.h:41
void * Buffer
Definition: rpcdcep.h:40
Definition: ps.c:97

Referenced by CtxClose(), CtxHello(), CtxOpen(), do_ndr_async_client_call(), m_CtxClose(), m_CtxHello(), m_CtxOpen(), m_CtxOpen2(), 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 229 of file ndr_clientserver.c.

233{
234 TRACE("(%p, %p, %p, %ld)\n", pStubMsg, pCommStatus, pFaultStatus, Status);
235
236 switch (Status)
237 {
240 case RPC_S_UNKNOWN_IF:
250 *pCommStatus = Status;
251 *pFaultStatus = 0;
252 break;
253 default:
254 *pCommStatus = 0;
255 *pFaultStatus = Status;
256 }
257
258 return RPC_S_OK;
259}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
Status
Definition: gdiplustypes.h:25
#define RPC_S_SERVER_TOO_BUSY
Definition: winerror.h:1390
#define RPC_S_CALL_FAILED_DNE
Definition: winerror.h:1394
#define EPT_S_NOT_REGISTERED
Definition: winerror.h:1418
#define RPC_S_UNSUPPORTED_TRANS_SYN
Definition: winerror.h:1397
#define RPC_S_UNSUPPORTED_TYPE
Definition: winerror.h:1398
#define RPC_S_UNKNOWN_IF
Definition: winerror.h:1384
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1395
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1389
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1369
#define RPC_S_COMM_FAILURE
Definition: winerror.h:1484
#define RPC_S_PROCNUM_OUT_OF_RANGE
Definition: winerror.h:1410

Referenced by NdrpClientCall2(), and test_NdrMapCommAndFaultStatus().

◆ NdrSendReceive()

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

Definition at line 195 of file ndr_clientserver.c.

196{
198
199 TRACE("(stubmsg == ^%p, buffer == ^%p)\n", stubmsg, buffer);
200
201 /* FIXME: how to handle errors? (raise exception?) */
202 if (!stubmsg) {
203 ERR("NULL stub message. No action taken.\n");
204 return NULL;
205 }
206 if (!stubmsg->RpcMsg) {
207 ERR("RPC Message not present in stub message. No action taken.\n");
208 return NULL;
209 }
210
211 /* avoid sending uninitialised parts of the buffer on the wire */
212 stubmsg->RpcMsg->BufferLength = buffer - (unsigned char *)stubmsg->RpcMsg->Buffer;
213 status = I_RpcSendReceive(stubmsg->RpcMsg);
214 if (status != RPC_S_OK)
216
217 stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
218 stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
219 stubmsg->BufferEnd = stubmsg->BufferStart + stubmsg->BufferLength;
220 stubmsg->Buffer = stubmsg->BufferStart;
221
222 /* FIXME: is this the right return value? */
223 return NULL;
224}
#define ERR(fmt,...)
Definition: precomp.h:57
GLuint buffer
Definition: glext.h:5915
RPC_STATUS WINAPI I_RpcSendReceive(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1914

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 107 of file ndr_clientserver.c.

109{
110 TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc);
111
112 pStubMsg->RpcMsg = pRpcMsg;
113 pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;
114 pStubMsg->BufferEnd = pStubMsg->Buffer + pRpcMsg->BufferLength;
115 pStubMsg->BufferLength = pRpcMsg->BufferLength;
116 pStubMsg->IsClient = FALSE;
117 pStubMsg->ReuseBuffer = FALSE;
118 pStubMsg->pAllocAllNodesContext = NULL;
119 pStubMsg->pPointerQueueState = NULL;
120 pStubMsg->IgnoreEmbeddedPointers = 0;
121 pStubMsg->PointerBufferMark = NULL;
122 pStubMsg->CorrDespIncrement = 0;
123 pStubMsg->uFlags = 0;
124 pStubMsg->UniquePtrCount = 0;
125 pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
126 pStubMsg->pfnFree = pStubDesc->pfnFree;
127 pStubMsg->StackTop = NULL;
128 pStubMsg->StubDesc = pStubDesc;
129 pStubMsg->FullPtrXlatTables = NULL;
130 pStubMsg->FullPtrRefId = 0;
131 pStubMsg->PointerLength = 0;
132 pStubMsg->fInDontFree = 0;
133 pStubMsg->fDontCallFreeInst = 0;
134 pStubMsg->fHasReturn = 0;
135 pStubMsg->fHasExtensions = 0;
136 pStubMsg->fHasNewCorrDesc = 0;
137 pStubMsg->fIsIn = 0;
138 pStubMsg->fIsOut = 0;
139 pStubMsg->fIsOicf = 0;
140 pStubMsg->fHasMemoryValidateCallback = 0;
141 pStubMsg->fInFree = 0;
142 pStubMsg->fNeedMCCP = 0;
143 pStubMsg->fUnused2 = 0;
144 pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
145 pStubMsg->pvDestContext = NULL;
146 pStubMsg->pRpcChannelBuffer = NULL;
147 pStubMsg->pArrayInfo = NULL;
148 pStubMsg->dwStubPhase = 0;
149 /* FIXME: LowStackMark */
150 pStubMsg->pAsyncMsg = NULL;
151 pStubMsg->pCorrInfo = NULL;
152 pStubMsg->pCorrMemory = NULL;
153 pStubMsg->pMemoryList = NULL;
154
155 return NULL;
156}
struct _FULL_PTR_XLAT_TABLES * FullPtrXlatTables
Definition: rpcndr.h:214

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

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( rpc  )