ReactOS 0.4.16-dev-297-gc569aee
rpc_epmap.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winsvc.h"
#include "rpc.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "rpc_binding.h"
#include "epm_c.h"
#include "epm_towers.h"
Include dependency graph for rpc_epmap.c:

Go to the source code of this file.

Classes

struct  epm_endpoints
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static BOOL start_rpcss (void)
 
static BOOL is_epm_destination_local (RPC_BINDING_HANDLE handle)
 
static RPC_STATUS get_epm_handle_client (RPC_BINDING_HANDLE handle, RPC_BINDING_HANDLE *epm_handle)
 
static RPC_STATUS get_epm_handle_server (RPC_BINDING_HANDLE *epm_handle)
 
static LONG WINAPI rpc_filter (EXCEPTION_POINTERS *__eptr)
 
static RPC_STATUS epm_register (RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector, RPC_CSTR Annotation, BOOL replace)
 
RPC_STATUS WINAPI RpcEpRegisterA (RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector, RPC_CSTR Annotation)
 
RPC_STATUS WINAPI RpcEpRegisterNoReplaceA (RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector, RPC_CSTR Annotation)
 
RPC_STATUS WINAPI RpcEpRegisterW (RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector, RPC_WSTR Annotation)
 
RPC_STATUS WINAPI RpcEpRegisterNoReplaceW (RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector, RPC_WSTR Annotation)
 
RPC_STATUS WINAPI RpcEpUnregister (RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector)
 
RPC_STATUS WINAPI RpcEpResolveBinding (RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec)
 
RPC_STATUS WINAPI TowerExplode (const twr_t *tower, PRPC_SYNTAX_IDENTIFIER object, PRPC_SYNTAX_IDENTIFIER syntax, char **protseq, char **endpoint, char **address)
 
RPC_STATUS WINAPI TowerConstruct (const RPC_SYNTAX_IDENTIFIER *object, const RPC_SYNTAX_IDENTIFIER *syntax, const char *protseq, const char *endpoint, const char *address, twr_t **tower)
 
void __RPC_FAR *__RPC_USER MIDL_user_allocate (SIZE_T len)
 
void __RPC_USER MIDL_user_free (void __RPC_FAR *ptr)
 

Variables

static const struct epm_endpoints epm_endpoints []
 

Function Documentation

◆ epm_register()

static RPC_STATUS epm_register ( RPC_IF_HANDLE  IfSpec,
RPC_BINDING_VECTOR BindingVector,
UUID_VECTOR UuidVector,
RPC_CSTR  Annotation,
BOOL  replace 
)
static

Definition at line 196 of file rpc_epmap.c.

198{
199 PRPC_SERVER_INTERFACE If = IfSpec;
200 ULONG i;
202 error_status_t status2;
203 ept_entry_t *entries;
205
206 TRACE("(%p,%p,%p,%s) replace=%d\n", IfSpec, BindingVector, UuidVector, debugstr_a((char*)Annotation), replace);
207 TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
208 for (i=0; i<BindingVector->Count; i++) {
209 RpcBinding* bind = BindingVector->BindingH[i];
210 TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq));
211 TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint));
212 }
213 if (UuidVector) {
214 for (i=0; i<UuidVector->Count; i++)
215 TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
216 }
217
218 if (!BindingVector->Count) return RPC_S_OK;
219
220 entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
221 if (!entries)
222 return RPC_S_OUT_OF_MEMORY;
223
225 if (status != RPC_S_OK)
226 {
227 HeapFree(GetProcessHeap(), 0, entries);
228 return status;
229 }
230
231 for (i = 0; i < BindingVector->Count; i++)
232 {
233 unsigned j;
234 RpcBinding* bind = BindingVector->BindingH[i];
235 for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
236 {
238 bind->Protseq, bind->Endpoint,
239 bind->NetworkAddr,
240 &entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
241 if (status != RPC_S_OK) break;
242
243 if (UuidVector)
244 memcpy(&entries[i * UuidVector->Count].object, &UuidVector->Uuid[j], sizeof(GUID));
245 else
246 memset(&entries[i].object, 0, sizeof(entries[i].object));
247 if (Annotation)
248 memcpy(entries[i].annotation, Annotation,
249 min(strlen((char *)Annotation) + 1, ept_max_annotation_size));
250 }
251 }
252
253 if (status == RPC_S_OK)
254 {
255 while (TRUE)
256 {
257 __TRY
258 {
259 ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
260 entries, replace, &status2);
261 }
263 {
264 status2 = GetExceptionCode();
265 }
267 if (status2 == RPC_S_SERVER_UNAVAILABLE &&
269 {
270 if (start_rpcss())
271 continue;
272 }
273 if (status2 != RPC_S_OK)
274 ERR("ept_insert failed with error %d\n", status2);
275 status = status2; /* FIXME: convert status? */
276 break;
277 }
278 }
280
281 for (i = 0; i < BindingVector->Count; i++)
282 {
283 unsigned j;
284 for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
285 I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
286 }
287
288 HeapFree(GetProcessHeap(), 0, entries);
289
290 return status;
291}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ERR(fmt,...)
Definition: precomp.h:57
unsigned long error_status_t
Definition: basetyps.h:83
#define annotation(x)
Definition: dispex.idl:19
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define __TRY
Definition: compat.h:80
#define HeapFree(x, y, z)
Definition: compat.h:735
#define __ENDTRY
Definition: compat.h:82
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
void __cdecl ept_insert(handle_t h, unsigned32 num_ents, ept_entry_t entries[], boolean32 replace, error_status_t *status)
Definition: epmp.c:92
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
#define __EXCEPT(func)
Definition: exception.h:84
INT replace(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], DWORD dwFlags, BOOL *doMore)
Definition: replace.c:38
RPC_STATUS WINAPI RpcBindingFree(RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:787
static RPC_STATUS get_epm_handle_server(RPC_BINDING_HANDLE *epm_handle)
Definition: rpc_epmap.c:177
RPC_STATUS WINAPI TowerConstruct(const RPC_SYNTAX_IDENTIFIER *object, const RPC_SYNTAX_IDENTIFIER *syntax, const char *protseq, const char *endpoint, const char *address, twr_t **tower)
Definition: rpc_epmap.c:596
static BOOL is_epm_destination_local(RPC_BINDING_HANDLE handle)
Definition: rpc_epmap.c:129
static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr)
Definition: rpc_epmap.c:184
static BOOL start_rpcss(void)
Definition: rpc_epmap.c:79
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
#define RPC_S_OK
Definition: rpcnterr.h:22
void WINAPI I_RpcFree(void *Object)
Definition: rpcrt4_main.c:724
long RPC_STATUS
Definition: rpc.h:52
#define memset(x, y, z)
Definition: compat.h:39
#define GetExceptionCode()
Definition: seh.h:27
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
#define TRACE(s)
Definition: solgame.cpp:4
RPC_BINDING_HANDLE BindingH[1]
Definition: rpcdce.h:58
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:104
RPC_SYNTAX_IDENTIFIER TransferSyntax
Definition: rpcdcep.h:105
UUID * Uuid[1]
Definition: rpcdce.h:65
ULONG Count
Definition: rpcdce.h:64
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033

Referenced by RpcEpRegisterA(), RpcEpRegisterNoReplaceA(), RpcEpRegisterNoReplaceW(), and RpcEpRegisterW().

◆ get_epm_handle_client()

static RPC_STATUS get_epm_handle_client ( RPC_BINDING_HANDLE  handle,
RPC_BINDING_HANDLE epm_handle 
)
static

Definition at line 140 of file rpc_epmap.c.

141{
143 const char * pszEndpoint = NULL;
145 RpcBinding* epm_bind;
146 unsigned int i;
147
148 if (bind->server)
150
151 for (i = 0; i < ARRAY_SIZE(epm_endpoints); i++)
152 if (!strcmp(bind->Protseq, epm_endpoints[i].protseq))
153 pszEndpoint = epm_endpoints[i].endpoint;
154
155 if (!pszEndpoint)
156 {
157 FIXME("no endpoint for the endpoint-mapper found for protseq %s\n", debugstr_a(bind->Protseq));
159 }
160
161 status = RpcBindingCopy(handle, epm_handle);
162 if (status != RPC_S_OK) return status;
163
164 epm_bind = *epm_handle;
165 if (epm_bind->AuthInfo)
166 {
167 /* don't bother with authenticating against the EPM by default
168 * (see EnableAuthEpResolution registry value) */
169 RpcAuthInfo_Release(epm_bind->AuthInfo);
170 epm_bind->AuthInfo = NULL;
171 }
172 RPCRT4_ResolveBinding(epm_bind, pszEndpoint);
173 TRACE("RPC_S_OK\n");
174 return RPC_S_OK;
175}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define NULL
Definition: types.h:112
RPC_STATUS RPCRT4_ResolveBinding(RpcBinding *Binding, LPCSTR Endpoint)
Definition: rpc_binding.c:204
ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1188
RPC_STATUS RPC_ENTRY RpcBindingCopy(RPC_BINDING_HANDLE SourceBinding, RPC_BINDING_HANDLE *DestinationBinding)
Definition: rpc_binding.c:989
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:140
Definition: nis.h:10
const char * protseq
Definition: rpc_epmap.c:68
#define RPC_S_PROTSEQ_NOT_SUPPORTED
Definition: winerror.h:1014
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1013

Referenced by RpcEpResolveBinding().

◆ get_epm_handle_server()

static RPC_STATUS get_epm_handle_server ( RPC_BINDING_HANDLE epm_handle)
static

Definition at line 177 of file rpc_epmap.c.

178{
179 unsigned char string_binding[] = "ncacn_np:.[\\\\pipe\\\\epmapper]";
180
181 return RpcBindingFromStringBindingA(string_binding, epm_handle);
182}
RPC_STATUS WINAPI RpcBindingFromStringBindingA(RPC_CSTR StringBinding, RPC_BINDING_HANDLE *Binding)
Definition: rpc_binding.c:840

Referenced by epm_register(), and RpcEpUnregister().

◆ is_epm_destination_local()

static BOOL is_epm_destination_local ( RPC_BINDING_HANDLE  handle)
inlinestatic

Definition at line 129 of file rpc_epmap.c.

130{
132 const char *protseq = bind->Protseq;
133 const char *network_addr = bind->NetworkAddr;
134
135 return (!strcmp(protseq, "ncalrpc") ||
136 (!strcmp(protseq, "ncacn_np") &&
137 (!network_addr || !strcmp(network_addr, "."))));
138}

Referenced by epm_register(), and RpcEpResolveBinding().

◆ MIDL_user_allocate()

void __RPC_FAR *__RPC_USER MIDL_user_allocate ( SIZE_T  len)

Definition at line 657 of file rpc_epmap.c.

658{
659 return HeapAlloc(GetProcessHeap(), 0, len);
660}
GLenum GLsizei len
Definition: glext.h:6722

◆ MIDL_user_free()

void __RPC_USER MIDL_user_free ( void __RPC_FAR ptr)

Definition at line 662 of file rpc_epmap.c.

663{
665}
static PVOID ptr
Definition: dispmode.c:27

◆ rpc_filter()

static LONG WINAPI rpc_filter ( EXCEPTION_POINTERS __eptr)
static

Definition at line 184 of file rpc_epmap.c.

185{
186 switch (__eptr->ExceptionRecord->ExceptionCode)
187 {
191 default:
193 }
194}
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define EXCEPTION_CONTINUE_SEARCH
Definition: excpt.h:86
PEXCEPTION_RECORD ExceptionRecord
Definition: rtltypes.h:200
DWORD ExceptionCode
Definition: compat.h:208
#define EXCEPTION_ILLEGAL_INSTRUCTION
Definition: winbase.h:353
#define EXCEPTION_ACCESS_VIOLATION
Definition: winbase.h:337

Referenced by epm_register(), RpcEpResolveBinding(), and RpcEpUnregister().

◆ RpcEpRegisterA()

RPC_STATUS WINAPI RpcEpRegisterA ( RPC_IF_HANDLE  IfSpec,
RPC_BINDING_VECTOR BindingVector,
UUID_VECTOR UuidVector,
RPC_CSTR  Annotation 
)

Definition at line 296 of file rpc_epmap.c.

298{
299 return epm_register(IfSpec, BindingVector, UuidVector, Annotation, TRUE);
300}
static RPC_STATUS epm_register(RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector, UUID_VECTOR *UuidVector, RPC_CSTR Annotation, BOOL replace)
Definition: rpc_epmap.c:196

Referenced by test_endpoint_mapper().

◆ RpcEpRegisterNoReplaceA()

RPC_STATUS WINAPI RpcEpRegisterNoReplaceA ( RPC_IF_HANDLE  IfSpec,
RPC_BINDING_VECTOR BindingVector,
UUID_VECTOR UuidVector,
RPC_CSTR  Annotation 
)

Definition at line 305 of file rpc_epmap.c.

307{
308 return epm_register(IfSpec, BindingVector, UuidVector, Annotation, FALSE);
309}
#define FALSE
Definition: types.h:117

◆ RpcEpRegisterNoReplaceW()

RPC_STATUS WINAPI RpcEpRegisterNoReplaceW ( RPC_IF_HANDLE  IfSpec,
RPC_BINDING_VECTOR BindingVector,
UUID_VECTOR UuidVector,
RPC_WSTR  Annotation 
)

Definition at line 329 of file rpc_epmap.c.

331{
332 LPSTR annA = RPCRT4_strdupWtoA(Annotation);
334
335 status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, FALSE);
336
337 HeapFree(GetProcessHeap(), 0, annA);
338 return status;
339}
LPSTR RPCRT4_strdupWtoA(LPCWSTR src)
Definition: rpc_binding.c:58
unsigned char * RPC_CSTR
Definition: rpcdce.h:45
char * LPSTR
Definition: xmlstorage.h:182

◆ RpcEpRegisterW()

RPC_STATUS WINAPI RpcEpRegisterW ( RPC_IF_HANDLE  IfSpec,
RPC_BINDING_VECTOR BindingVector,
UUID_VECTOR UuidVector,
RPC_WSTR  Annotation 
)

Definition at line 314 of file rpc_epmap.c.

316{
317 LPSTR annA = RPCRT4_strdupWtoA(Annotation);
319
320 status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, TRUE);
321
322 HeapFree(GetProcessHeap(), 0, annA);
323 return status;
324}

◆ RpcEpResolveBinding()

RPC_STATUS WINAPI RpcEpResolveBinding ( RPC_BINDING_HANDLE  Binding,
RPC_IF_HANDLE  IfSpec 
)

Definition at line 431 of file rpc_epmap.c.

432{
433 PRPC_CLIENT_INTERFACE If = IfSpec;
436 error_status_t status2;
438 ept_lookup_handle_t entry_handle = NULL;
439 twr_t *tower;
440 twr_t *towers[4] = { NULL };
441 unsigned32 num_towers, i;
443 char *resolved_endpoint = NULL;
444
445 TRACE("(%p,%p)\n", Binding, IfSpec);
446 TRACE(" protseq=%s\n", debugstr_a(bind->Protseq));
447 TRACE(" obj=%s\n", debugstr_guid(&bind->ObjectUuid));
448 TRACE(" networkaddr=%s\n", debugstr_a(bind->NetworkAddr));
449 TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
450
451 /* just return for fully bound handles */
452 if (bind->Endpoint && (bind->Endpoint[0] != '\0'))
453 return RPC_S_OK;
454
456 if (status != RPC_S_OK) return status;
457
458 status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax, bind->Protseq,
459 ((RpcBinding *)handle)->Endpoint,
460 bind->NetworkAddr, &tower);
461 if (status != RPC_S_OK)
462 {
463 WARN("couldn't get tower\n");
465 return status;
466 }
467
468 while (TRUE)
469 {
470 __TRY
471 {
472 ept_map(handle, &uuid, tower, &entry_handle, ARRAY_SIZE(towers), &num_towers, towers, &status2);
473 /* FIXME: translate status2? */
474 }
476 {
477 status2 = GetExceptionCode();
478 }
480 if (status2 == RPC_S_SERVER_UNAVAILABLE &&
482 {
483 if (start_rpcss())
484 continue;
485 }
486 break;
487 };
488
490 I_RpcFree(tower);
491
492 if (status2 != RPC_S_OK)
493 {
494 ERR("ept_map failed for ifid %s, protseq %s, networkaddr %s\n", debugstr_guid(&If->TransferSyntax.SyntaxGUID), bind->Protseq, bind->NetworkAddr);
495 return status2;
496 }
497
498 for (i = 0; i < num_towers; i++)
499 {
500 /* only parse the tower if we haven't already found a suitable
501 * endpoint, otherwise just free the tower */
502 if (!resolved_endpoint)
503 {
504 status = TowerExplode(towers[i], NULL, NULL, NULL, &resolved_endpoint, NULL);
505 TRACE("status = %d\n", status);
506 }
507 I_RpcFree(towers[i]);
508 }
509
510 if (resolved_endpoint)
511 {
512 RPCRT4_ResolveBinding(Binding, resolved_endpoint);
513 I_RpcFree(resolved_endpoint);
514 return RPC_S_OK;
515 }
516
517 WARN("couldn't find an endpoint\n");
519}
#define WARN(fmt,...)
Definition: precomp.h:61
void __cdecl ept_map(handle_t h, uuid_p_t object, twr_p_t map_tower, ept_lookup_handle_t *entry_handle, unsigned32 max_towers, unsigned32 *num_towers, twr_p_t *towers, error_status_t *status)
Definition: epmp.c:201
Definition: msctf.idl:550
#define GUID_NULL
Definition: ks.h:106
unsigned int unsigned32
Definition: rpc.c:43
RPC_STATUS WINAPI TowerExplode(const twr_t *tower, PRPC_SYNTAX_IDENTIFIER object, PRPC_SYNTAX_IDENTIFIER syntax, char **protseq, char **endpoint, char **address)
Definition: rpc_epmap.c:524
static RPC_STATUS get_epm_handle_client(RPC_BINDING_HANDLE handle, RPC_BINDING_HANDLE *epm_handle)
Definition: rpc_epmap.c:140
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:117
RPC_SYNTAX_IDENTIFIER TransferSyntax
Definition: rpcdcep.h:118
Definition: rpc.c:45
#define EPT_S_NOT_REGISTERED
Definition: winerror.h:1061

Referenced by I_RpcNegotiateTransferSyntax(), and test_endpoint_mapper().

◆ RpcEpUnregister()

RPC_STATUS WINAPI RpcEpUnregister ( RPC_IF_HANDLE  IfSpec,
RPC_BINDING_VECTOR BindingVector,
UUID_VECTOR UuidVector 
)

Definition at line 344 of file rpc_epmap.c.

346{
347 PRPC_SERVER_INTERFACE If = IfSpec;
348 ULONG i;
350 error_status_t status2;
351 ept_entry_t *entries;
353
354 TRACE("(%p,%p,%p)\n", IfSpec, BindingVector, UuidVector);
355 TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
356 for (i=0; i<BindingVector->Count; i++) {
357 RpcBinding* bind = BindingVector->BindingH[i];
358 TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq));
359 TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint));
360 }
361 if (UuidVector) {
362 for (i=0; i<UuidVector->Count; i++)
363 TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
364 }
365
366 entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
367 if (!entries)
368 return RPC_S_OUT_OF_MEMORY;
369
371 if (status != RPC_S_OK)
372 {
373 HeapFree(GetProcessHeap(), 0, entries);
374 return status;
375 }
376
377 for (i = 0; i < BindingVector->Count; i++)
378 {
379 unsigned j;
380 RpcBinding* bind = BindingVector->BindingH[i];
381 for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
382 {
384 bind->Protseq, bind->Endpoint,
385 bind->NetworkAddr,
386 &entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
387 if (status != RPC_S_OK) break;
388
389 if (UuidVector)
390 memcpy(&entries[i * UuidVector->Count + j].object, &UuidVector->Uuid[j], sizeof(GUID));
391 else
392 memset(&entries[i].object, 0, sizeof(entries[i].object));
393 }
394 }
395
396 if (status == RPC_S_OK)
397 {
398 __TRY
399 {
400 ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
401 entries, TRUE, &status2);
402 }
404 {
405 status2 = GetExceptionCode();
406 }
408 if (status2 == RPC_S_SERVER_UNAVAILABLE)
409 status2 = EPT_S_NOT_REGISTERED;
410 if (status2 != RPC_S_OK)
411 ERR("ept_insert failed with error %d\n", status2);
412 status = status2; /* FIXME: convert status? */
413 }
415
416 for (i = 0; i < BindingVector->Count; i++)
417 {
418 unsigned j;
419 for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
420 I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
421 }
422
423 HeapFree(GetProcessHeap(), 0, entries);
424
425 return status;
426}

Referenced by test_endpoint_mapper().

◆ start_rpcss()

static BOOL start_rpcss ( void  )
static

Definition at line 79 of file rpc_epmap.c.

80{
81 static const WCHAR rpcssW[] = {'R','p','c','S','s',0};
82 SC_HANDLE scm, service;
84 BOOL ret = FALSE;
85
86 TRACE("\n");
87
88 if (!(scm = OpenSCManagerW( NULL, NULL, 0 )))
89 {
90 ERR( "failed to open service manager\n" );
91 return FALSE;
92 }
93 if (!(service = OpenServiceW( scm, rpcssW, SERVICE_START | SERVICE_QUERY_STATUS )))
94 {
95 ERR( "failed to open RpcSs service\n" );
96 CloseServiceHandle( scm );
97 return FALSE;
98 }
100 {
101 ULONGLONG start_time = GetTickCount64();
102 do
103 {
104 DWORD dummy;
105
107 (BYTE *)&status, sizeof(status), &dummy ))
108 break;
109 if (status.dwCurrentState == SERVICE_RUNNING)
110 {
111 ret = TRUE;
112 break;
113 }
114 if (GetTickCount64() - start_time > 30000) break;
115 Sleep( 100 );
116
117 } while (status.dwCurrentState == SERVICE_START_PENDING);
118
119 if (status.dwCurrentState != SERVICE_RUNNING)
120 WARN( "RpcSs failed to start %u\n", status.dwCurrentState );
121 }
122 else ERR( "failed to start RpcSs service\n" );
123
124 CloseServiceHandle( service );
125 CloseServiceHandle( scm );
126 return ret;
127}
ULONGLONG WINAPI GetTickCount64(VOID)
Definition: GetTickCount64.c:9
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static WCHAR rpcssW[]
Definition: rpcss_main.c:36
SC_HANDLE WINAPI OpenSCManagerW(LPCWSTR lpMachineName, LPCWSTR lpDatabaseName, DWORD dwDesiredAccess)
Definition: scm.c:2068
BOOL WINAPI QueryServiceStatusEx(SC_HANDLE hService, SC_STATUS_TYPE InfoLevel, LPBYTE lpBuffer, DWORD cbBufSize, LPDWORD pcbBytesNeeded)
Definition: scm.c:2887
SC_HANDLE WINAPI OpenServiceW(SC_HANDLE hSCManager, LPCWSTR lpServiceName, DWORD dwDesiredAccess)
Definition: scm.c:2160
BOOL WINAPI StartServiceW(SC_HANDLE hService, DWORD dwNumServiceArgs, LPCWSTR *lpServiceArgVectors)
Definition: scm.c:2980
BOOL WINAPI CloseServiceHandle(SC_HANDLE hSCObject)
Definition: scm.c:580
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
uint64_t ULONGLONG
Definition: typedefs.h:67
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_SERVICE_ALREADY_RUNNING
Definition: winerror.h:607
#define SERVICE_START
Definition: winsvc.h:57
#define SERVICE_QUERY_STATUS
Definition: winsvc.h:55
@ SC_STATUS_PROCESS_INFO
Definition: winsvc.h:119
#define SERVICE_START_PENDING
Definition: winsvc.h:22
#define SERVICE_RUNNING
Definition: winsvc.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by epm_register(), and RpcEpResolveBinding().

◆ TowerConstruct()

RPC_STATUS WINAPI TowerConstruct ( const RPC_SYNTAX_IDENTIFIER object,
const RPC_SYNTAX_IDENTIFIER syntax,
const char protseq,
const char endpoint,
const char address,
twr_t **  tower 
)

Definition at line 596 of file rpc_epmap.c.

600{
601 size_t tower_size;
603 unsigned char *p;
604 twr_uuid_floor_t *object_floor;
605 twr_uuid_floor_t *syntax_floor;
606
607 TRACE("(%p, %p, %s, %s, %s, %p)\n", object, syntax, debugstr_a(protseq),
609
610 *tower = NULL;
611
612 status = RpcTransport_GetTopOfTower(NULL, &tower_size, protseq, address, endpoint);
613
614 if (status != RPC_S_OK)
615 return status;
616
617 tower_size += sizeof(u_int16) + sizeof(*object_floor) + sizeof(*syntax_floor);
618 *tower = I_RpcAllocate(FIELD_OFFSET(twr_t, tower_octet_string[tower_size]));
619 if (!*tower)
621
622 (*tower)->tower_length = tower_size;
623 p = &(*tower)->tower_octet_string[0];
624 *(u_int16 *)p = 5; /* number of floors */
625 p += sizeof(u_int16);
626 object_floor = (twr_uuid_floor_t *)p;
627 p += sizeof(*object_floor);
628 syntax_floor = (twr_uuid_floor_t *)p;
629 p += sizeof(*syntax_floor);
630
631 object_floor->count_lhs = sizeof(object_floor->protid) + sizeof(object_floor->uuid) +
632 sizeof(object_floor->major_version);
633 object_floor->protid = EPM_PROTOCOL_UUID;
634 object_floor->count_rhs = sizeof(object_floor->minor_version);
635 object_floor->uuid = object->SyntaxGUID;
636 object_floor->major_version = object->SyntaxVersion.MajorVersion;
637 object_floor->minor_version = object->SyntaxVersion.MinorVersion;
638
639 syntax_floor->count_lhs = sizeof(syntax_floor->protid) + sizeof(syntax_floor->uuid) +
640 sizeof(syntax_floor->major_version);
641 syntax_floor->protid = EPM_PROTOCOL_UUID;
642 syntax_floor->count_rhs = sizeof(syntax_floor->minor_version);
643 syntax_floor->uuid = syntax->SyntaxGUID;
644 syntax_floor->major_version = syntax->SyntaxVersion.MajorVersion;
645 syntax_floor->minor_version = syntax->SyntaxVersion.MinorVersion;
646
647 status = RpcTransport_GetTopOfTower(p, &tower_size, protseq, address, endpoint);
648 if (status != RPC_S_OK)
649 {
650 I_RpcFree(*tower);
651 *tower = NULL;
652 return status;
653 }
654 return RPC_S_OK;
655}
unsigned short u_int16
Definition: dcetypes.idl:33
#define EPM_PROTOCOL_UUID
Definition: epm_towers.h:35
GLuint address
Definition: glext.h:9393
GLfloat GLfloat p
Definition: glext.h:8902
RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint) DECLSPEC_HIDDEN
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:716
RPC_VERSION SyntaxVersion
Definition: rpcdcep.h:33
unsigned short MajorVersion
Definition: rpcdcep.h:27
unsigned short MinorVersion
Definition: rpcdcep.h:28
u_int16 minor_version
Definition: epm_towers.h:62
u_int16 count_lhs
Definition: epm_towers.h:57
u_int16 count_rhs
Definition: epm_towers.h:61
u_int16 major_version
Definition: epm_towers.h:60
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032

Referenced by epm_register(), ept_map(), RpcEpResolveBinding(), RpcEpUnregister(), and test_towers().

◆ TowerExplode()

RPC_STATUS WINAPI TowerExplode ( const twr_t tower,
PRPC_SYNTAX_IDENTIFIER  object,
PRPC_SYNTAX_IDENTIFIER  syntax,
char **  protseq,
char **  endpoint,
char **  address 
)

Definition at line 524 of file rpc_epmap.c.

527{
528 size_t tower_size;
530 const unsigned char *p;
531 u_int16 floor_count;
532 const twr_uuid_floor_t *object_floor;
533 const twr_uuid_floor_t *syntax_floor;
534
535 TRACE("(%p, %p, %p, %p, %p, %p)\n", tower, object, syntax, protseq,
537
538 if (protseq)
539 *protseq = NULL;
540 if (endpoint)
541 *endpoint = NULL;
542 if (address)
543 *address = NULL;
544
545 tower_size = tower->tower_length;
546
547 if (tower_size < sizeof(u_int16))
549
550 p = &tower->tower_octet_string[0];
551
552 floor_count = *(const u_int16 *)p;
553 p += sizeof(u_int16);
554 tower_size -= sizeof(u_int16);
555 TRACE("floor_count: %d\n", floor_count);
556 /* FIXME: should we do something with the floor count? at the moment we don't */
557
558 if (tower_size < sizeof(*object_floor) + sizeof(*syntax_floor))
560
561 object_floor = (const twr_uuid_floor_t *)p;
562 p += sizeof(*object_floor);
563 tower_size -= sizeof(*object_floor);
564 syntax_floor = (const twr_uuid_floor_t *)p;
565 p += sizeof(*syntax_floor);
566 tower_size -= sizeof(*syntax_floor);
567
568 if ((object_floor->count_lhs != sizeof(object_floor->protid) +
569 sizeof(object_floor->uuid) + sizeof(object_floor->major_version)) ||
570 (object_floor->protid != EPM_PROTOCOL_UUID) ||
571 (object_floor->count_rhs != sizeof(object_floor->minor_version)))
573
574 if ((syntax_floor->count_lhs != sizeof(syntax_floor->protid) +
575 sizeof(syntax_floor->uuid) + sizeof(syntax_floor->major_version)) ||
576 (syntax_floor->protid != EPM_PROTOCOL_UUID) ||
577 (syntax_floor->count_rhs != sizeof(syntax_floor->minor_version)))
579
580 status = RpcTransport_ParseTopOfTower(p, tower_size, protseq, address, endpoint);
581 if ((status == RPC_S_OK) && syntax && object)
582 {
583 syntax->SyntaxGUID = syntax_floor->uuid;
584 syntax->SyntaxVersion.MajorVersion = syntax_floor->major_version;
585 syntax->SyntaxVersion.MinorVersion = syntax_floor->minor_version;
586 object->SyntaxGUID = object_floor->uuid;
587 object->SyntaxVersion.MajorVersion = object_floor->major_version;
588 object->SyntaxVersion.MinorVersion = object_floor->minor_version;
589 }
590 return status;
591}
RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint) DECLSPEC_HIDDEN
byte tower_octet_string[1]
Definition: rpc.c:47
unsigned32 tower_length
Definition: rpc.c:46

Referenced by ept_delete(), ept_insert(), ept_map(), and RpcEpResolveBinding().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ epm_endpoints

Initial value:
=
{
{ "ncacn_np", "\\pipe\\epmapper" },
{ "ncacn_ip_tcp", "135" },
{ "ncacn_ip_udp", "135" },
{ "ncalrpc", "epmapper" },
{ "ncacn_http", "593" },
}