ReactOS 0.4.16-dev-1946-g52006dd
ndr_contexthandle.c File Reference
#include <stdlib.h>
#include "ndr_misc.h"
#include "rpc_assoc.h"
#include "rpcndr.h"
#include "cguid.h"
#include "wine/debug.h"
#include "wine/list.h"
Include dependency graph for ndr_contexthandle.c:

Go to the source code of this file.

Classes

struct  ndr_context_handle
 
struct  context_handle_entry
 

Macros

#define NDR_CONTEXT_HANDLE_MAGIC   0x4352444e
 

Typedefs

typedef struct ndr_context_handle ndr_context_handle
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static struct context_handle_entryget_context_entry (NDR_CCONTEXT CContext)
 
static struct context_handle_entrycontext_entry_from_guid (LPCGUID uuid)
 
RPC_BINDING_HANDLE WINAPI NDRCContextBinding (NDR_CCONTEXT CContext)
 
void WINAPI NDRCContextMarshall (NDR_CCONTEXT CContext, void *pBuff)
 
RPC_STATUS WINAPI RpcSmDestroyClientContext (void **ContextHandle)
 
void WINAPI RpcSsDestroyClientContext (void **ContextHandle)
 
void WINAPI RpcSsDontSerializeContext (void)
 
static RPC_STATUS ndr_update_context_handle (NDR_CCONTEXT *CContext, RPC_BINDING_HANDLE hBinding, const ndr_context_handle *chi)
 
void WINAPI NDRCContextUnmarshall (NDR_CCONTEXT *CContext, RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation)
 
void WINAPI NDRSContextMarshall (NDR_SCONTEXT SContext, void *pBuff, NDR_RUNDOWN userRunDownIn)
 
void WINAPI NDRSContextMarshallEx (RPC_BINDING_HANDLE hBinding, NDR_SCONTEXT SContext, void *pBuff, NDR_RUNDOWN userRunDownIn)
 
void WINAPI NDRSContextMarshall2 (RPC_BINDING_HANDLE hBinding, NDR_SCONTEXT SContext, void *pBuff, NDR_RUNDOWN userRunDownIn, void *CtxGuard, ULONG Flags)
 
NDR_SCONTEXT WINAPI NDRSContextUnmarshall (void *pBuff, ULONG DataRepresentation)
 
NDR_SCONTEXT WINAPI NDRSContextUnmarshallEx (RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation)
 
NDR_SCONTEXT WINAPI NDRSContextUnmarshall2 (RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation, void *CtxGuard, ULONG Flags)
 

Variables

static struct list context_handle_list = LIST_INIT(context_handle_list)
 
static CRITICAL_SECTION ndr_context_cs = { &ndr_context_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG ndr_context_debug
 

Macro Definition Documentation

◆ NDR_CONTEXT_HANDLE_MAGIC

#define NDR_CONTEXT_HANDLE_MAGIC   0x4352444e

Definition at line 34 of file ndr_contexthandle.c.

Typedef Documentation

◆ ndr_context_handle

Function Documentation

◆ context_entry_from_guid()

static struct context_handle_entry * context_entry_from_guid ( LPCGUID  uuid)
static

Definition at line 70 of file ndr_contexthandle.c.

71{
72 struct context_handle_entry *che;
74 if (IsEqualGUID(&che->wire_data.uuid, uuid))
75 return che;
76 return NULL;
77}
#define NULL
Definition: types.h:112
Definition: msctf.idl:532
uint32_t entry
Definition: isohybrid.c:63
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
ndr_context_handle wire_data

Referenced by ndr_update_context_handle().

◆ get_context_entry()

static struct context_handle_entry * get_context_entry ( NDR_CCONTEXT  CContext)
static

Definition at line 61 of file ndr_contexthandle.c.

62{
63 struct context_handle_entry *che = CContext;
64
66 return NULL;
67 return che;
68}
#define NDR_CONTEXT_HANDLE_MAGIC
DWORD magic

Referenced by ndr_update_context_handle(), NDRCContextBinding(), NDRCContextMarshall(), and RpcSmDestroyClientContext().

◆ ndr_update_context_handle()

static RPC_STATUS ndr_update_context_handle ( NDR_CCONTEXT CContext,
RPC_BINDING_HANDLE  hBinding,
const ndr_context_handle chi 
)
static

Definition at line 169 of file ndr_contexthandle.c.

172{
173 struct context_handle_entry *che = NULL;
174
175 /* a null UUID means we should free the context handle */
176 if (IsEqualGUID(&chi->uuid, &GUID_NULL))
177 {
178 if (*CContext)
179 {
181 if (!che)
183 list_remove(&che->entry);
184 RpcBindingFree(&che->handle);
185 free(che);
186 che = NULL;
187 }
188 }
189 /* if there's no existing entry matching the GUID, allocate one */
190 else if (!(che = context_entry_from_guid(&chi->uuid)))
191 {
192 che = malloc(sizeof *che);
193 if (!che)
194 return RPC_X_NO_MEMORY;
198 che->wire_data = *chi;
199 }
200
201 *CContext = che;
202
203 return RPC_S_OK;
204}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
handle_t hBinding
Definition: ctx_c.c:54
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define GUID_NULL
Definition: ks.h:106
static struct context_handle_entry * get_context_entry(NDR_CCONTEXT CContext)
static struct context_handle_entry * context_entry_from_guid(LPCGUID uuid)
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:769
RPC_STATUS RPC_ENTRY RpcBindingCopy(RPC_BINDING_HANDLE SourceBinding, RPC_BINDING_HANDLE *DestinationBinding)
Definition: rpc_binding.c:971
#define RPC_X_SS_CONTEXT_MISMATCH
Definition: rpcnterr.h:39
#define RPC_X_NO_MEMORY
Definition: rpcnterr.h:35
#define RPC_S_OK
Definition: rpcnterr.h:22
struct list entry
RPC_BINDING_HANDLE handle

Referenced by NDRCContextUnmarshall().

◆ NDRCContextBinding()

RPC_BINDING_HANDLE WINAPI NDRCContextBinding ( NDR_CCONTEXT  CContext)

Definition at line 79 of file ndr_contexthandle.c.

80{
81 struct context_handle_entry *che;
83
84 TRACE("%p\n", CContext);
85
88 if (che)
89 handle = che->handle;
91
92 if (!handle)
93 {
94 ERR("invalid handle %p\n", CContext);
96 }
97 return handle;
98}
#define ERR(fmt,...)
Definition: precomp.h:57
static CRITICAL_SECTION ndr_context_cs
void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
Definition: rpcrt4_main.c:213
#define TRACE(s)
Definition: solgame.cpp:4
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by client_get_handle(), CtxClose(), CtxHello(), m_CtxClose(), m_CtxHello(), and main().

◆ NDRCContextMarshall()

void WINAPI NDRCContextMarshall ( NDR_CCONTEXT  CContext,
void pBuff 
)

Definition at line 100 of file ndr_contexthandle.c.

101{
102 struct context_handle_entry *che;
103
104 TRACE("%p %p\n", CContext, pBuff);
105
106 if (CContext)
107 {
110 memcpy(pBuff, &che->wire_data, sizeof (ndr_context_handle));
112 }
113 else
114 {
118 }
119}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by main(), and NdrClientContextMarshall().

◆ NDRCContextUnmarshall()

void WINAPI NDRCContextUnmarshall ( NDR_CCONTEXT CContext,
RPC_BINDING_HANDLE  hBinding,
void pBuff,
ULONG  DataRepresentation 
)

Definition at line 209 of file ndr_contexthandle.c.

212{
214
215 TRACE("*%p=(%p) %p %p %08lx\n",
216 CContext, *CContext, hBinding, pBuff, DataRepresentation);
217
221 if (status)
223}
static RPC_STATUS ndr_update_context_handle(NDR_CCONTEXT *CContext, RPC_BINDING_HANDLE hBinding, const ndr_context_handle *chi)
long RPC_STATUS
Definition: rpc.h:48
Definition: ps.c:97

Referenced by m_CtxOpen2(), and NdrClientContextUnmarshall().

◆ NDRSContextMarshall()

void WINAPI NDRSContextMarshall ( NDR_SCONTEXT  SContext,
void pBuff,
NDR_RUNDOWN  userRunDownIn 
)

Definition at line 228 of file ndr_contexthandle.c.

231{
232 TRACE("(%p %p %p)\n", SContext, pBuff, userRunDownIn);
234 userRunDownIn, NULL, RPC_CONTEXT_HANDLE_DEFAULT_FLAGS);
235}
void WINAPI NDRSContextMarshall2(RPC_BINDING_HANDLE hBinding, NDR_SCONTEXT SContext, void *pBuff, NDR_RUNDOWN userRunDownIn, void *CtxGuard, ULONG Flags)
RPC_BINDING_HANDLE WINAPI I_RpcGetCurrentCallHandle(void)
Definition: rpc_server.c:1743
#define RPC_CONTEXT_HANDLE_DEFAULT_FLAGS
Definition: rpcdcep.h:56

◆ NDRSContextMarshall2()

void WINAPI NDRSContextMarshall2 ( RPC_BINDING_HANDLE  hBinding,
NDR_SCONTEXT  SContext,
void pBuff,
NDR_RUNDOWN  userRunDownIn,
void CtxGuard,
ULONG  Flags 
)

Definition at line 253 of file ndr_contexthandle.c.

258{
261 ndr_context_handle *ndr = pBuff;
262
263 TRACE("(%p %p %p %p %p %lu)\n",
264 hBinding, SContext, pBuff, userRunDownIn, CtxGuard, Flags);
265
266 if (!binding->server || !binding->Assoc)
268
269 if (SContext->userContext)
270 {
271 status = RpcServerAssoc_UpdateContextHandle(binding->Assoc, SContext, CtxGuard, userRunDownIn);
272 if (status != RPC_S_OK)
274 ndr->attributes = 0;
275 RpcContextHandle_GetUuid(SContext, &ndr->uuid);
276
279 }
280 else
281 {
282 if (!RpcContextHandle_IsGuardCorrect(SContext, CtxGuard))
284 memset(ndr, 0, sizeof(*ndr));
285
287 /* Note: release the context handle twice in this case to release
288 * one ref being kept around for the data and one ref for the
289 * unmarshall/marshall sequence */
290 if (!RpcServerAssoc_ReleaseContextHandle(binding->Assoc, SContext, TRUE))
291 return; /* this is to cope with the case of the data not being valid
292 * before and so not having a further reference */
294 }
295}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static RPC_BINDING_HANDLE binding
Definition: server.c:166
void RpcContextHandle_GetUuid(NDR_SCONTEXT SContext, UUID *uuid)
Definition: rpc_assoc.c:542
RPC_STATUS RpcServerAssoc_UpdateContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, void *CtxGuard, NDR_RUNDOWN rundown_routine)
Definition: rpc_assoc.c:516
BOOL RpcContextHandle_IsGuardCorrect(NDR_SCONTEXT SContext, void *CtxGuard)
Definition: rpc_assoc.c:482
unsigned int RpcServerAssoc_ReleaseContextHandle(RpcAssoc *assoc, NDR_SCONTEXT SContext, BOOL release_lock)
Definition: rpc_assoc.c:565
void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext)
Definition: rpcrt4_main.c:1026
#define memset(x, y, z)
Definition: compat.h:39
void * userContext
Definition: rpcndr.h:112
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1369
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by NDRSContextMarshall(), NDRSContextMarshallEx(), NdrServerContextMarshall(), and NdrServerContextNewMarshall().

◆ NDRSContextMarshallEx()

void WINAPI NDRSContextMarshallEx ( RPC_BINDING_HANDLE  hBinding,
NDR_SCONTEXT  SContext,
void pBuff,
NDR_RUNDOWN  userRunDownIn 
)

Definition at line 240 of file ndr_contexthandle.c.

244{
245 TRACE("(%p %p %p %p)\n", hBinding, SContext, pBuff, userRunDownIn);
246 NDRSContextMarshall2(hBinding, SContext, pBuff, userRunDownIn, NULL,
248}

◆ NDRSContextUnmarshall()

NDR_SCONTEXT WINAPI NDRSContextUnmarshall ( void pBuff,
ULONG  DataRepresentation 
)

Definition at line 300 of file ndr_contexthandle.c.

302{
303 TRACE("(%p %08lx)\n", pBuff, DataRepresentation);
305 DataRepresentation, NULL,
307}
NDR_SCONTEXT WINAPI NDRSContextUnmarshall2(RPC_BINDING_HANDLE hBinding, void *pBuff, ULONG DataRepresentation, void *CtxGuard, ULONG Flags)

Referenced by hello_CtxOpen().

◆ NDRSContextUnmarshall2()

NDR_SCONTEXT WINAPI NDRSContextUnmarshall2 ( RPC_BINDING_HANDLE  hBinding,
void pBuff,
ULONG  DataRepresentation,
void CtxGuard,
ULONG  Flags 
)

Definition at line 324 of file ndr_contexthandle.c.

328{
330 NDR_SCONTEXT SContext;
332 const ndr_context_handle *context_ndr = pBuff;
333
334 TRACE("(%p %p %08lx %p %lu)\n",
335 hBinding, pBuff, DataRepresentation, CtxGuard, Flags);
336
337 if (!binding->server || !binding->Assoc)
339
340 if (!pBuff || (!context_ndr->attributes &&
341 UuidIsNil((UUID *)&context_ndr->uuid, &status)))
343 &SContext);
344 else
345 {
346 if (context_ndr->attributes)
347 {
348 ERR("non-null attributes 0x%lx\n", context_ndr->attributes);
350 }
351 else
353 &context_ndr->uuid,
354 CtxGuard, Flags,
355 &SContext);
356 }
357
358 if (status != RPC_S_OK)
360
362 return SContext;
363}
RPC_STATUS RpcServerAssoc_FindContextHandle(RpcAssoc *assoc, const UUID *uuid, void *CtxGuard, ULONG Flags, NDR_SCONTEXT *SContext)
Definition: rpc_assoc.c:488
RPC_STATUS RpcServerAssoc_AllocateContextHandle(RpcAssoc *assoc, void *CtxGuard, NDR_SCONTEXT *SContext)
Definition: rpc_assoc.c:456
void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext)
Definition: rpcrt4_main.c:1011
int WINAPI UuidIsNil(UUID *Uuid, RPC_STATUS *Status)
Definition: rpcrt4_main.c:293

Referenced by NdrContextHandleInitialize(), NDRSContextUnmarshall(), NDRSContextUnmarshallEx(), NdrServerContextNewUnmarshall(), and NdrServerContextUnmarshall().

◆ NDRSContextUnmarshallEx()

NDR_SCONTEXT WINAPI NDRSContextUnmarshallEx ( RPC_BINDING_HANDLE  hBinding,
void pBuff,
ULONG  DataRepresentation 
)

Definition at line 312 of file ndr_contexthandle.c.

315{
316 TRACE("(%p %p %08lx)\n", hBinding, pBuff, DataRepresentation);
317 return NDRSContextUnmarshall2(hBinding, pBuff, DataRepresentation, NULL,
319}

◆ RpcSmDestroyClientContext()

RPC_STATUS WINAPI RpcSmDestroyClientContext ( void **  ContextHandle)

Definition at line 124 of file ndr_contexthandle.c.

125{
127 struct context_handle_entry *che = NULL;
128
129 TRACE("(%p)\n", ContextHandle);
130
132 che = get_context_entry(*ContextHandle);
133 *ContextHandle = NULL;
134 if (che)
135 {
137 list_remove(&che->entry);
138 }
139
141
142 if (che)
143 {
144 RpcBindingFree(&che->handle);
145 free(che);
146 }
147
148 return status;
149}

Referenced by RpcSsDestroyClientContext().

◆ RpcSsDestroyClientContext()

void WINAPI RpcSsDestroyClientContext ( void **  ContextHandle)

Definition at line 154 of file ndr_contexthandle.c.

155{
157 if (status != RPC_S_OK)
159}
RPC_STATUS WINAPI RpcSmDestroyClientContext(void **ContextHandle)

◆ RpcSsDontSerializeContext()

void WINAPI RpcSsDontSerializeContext ( void  )

Definition at line 164 of file ndr_contexthandle.c.

165{
166 FIXME("stub\n");
167}
#define FIXME(fmt,...)
Definition: precomp.h:53

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ context_handle_list

◆ ndr_context_cs

static CRITICAL_SECTION ndr_context_cs = { &ndr_context_debug, -1, 0, 0, 0, 0 }
static

◆ ndr_context_debug

CRITICAL_SECTION_DEBUG ndr_context_debug
static
Initial value:
=
{
0, 0, { (DWORD_PTR)(__FILE__ ": ndr_context") }
}
static CRITICAL_SECTION_DEBUG ndr_context_debug
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 53 of file ndr_contexthandle.c.