mshtml: Don't use PRInt32 in property getters implementations.
[wine] / dlls / rpcrt4 / rpc_epmap.c
1 /*
2  * RPC endpoint mapper
3  *
4  * Copyright 2002 Greg Turner
5  * Copyright 2001 Ove Kåven, TransGaming Technologies
6  * Copyright 2008 Robert Shearman (for CodeWeavers)
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winerror.h"
28
29 #include "rpc.h"
30
31 #include "wine/debug.h"
32 #include "wine/exception.h"
33
34 #include "rpc_binding.h"
35 #include "epm.h"
36 #include "epm_towers.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(ole);
39
40 /* The "real" RPC portmapper endpoints that I know of are:
41  *
42  *  ncadg_ip_udp: 135
43  *  ncacn_ip_tcp: 135
44  *  ncacn_np: \\pipe\epmapper
45  *  ncalrpc: epmapper
46  *  ncacn_http: 593
47  *
48  * If the user's machine ran a DCE RPC daemon, it would
49  * probably be possible to connect to it, but there are many
50  * reasons not to, like:
51  *  - the user probably does *not* run one, and probably
52  *    shouldn't be forced to run one just for local COM
53  *  - very few Unix systems use DCE RPC... if they run a RPC
54  *    daemon at all, it's usually Sun RPC
55  *  - DCE RPC registrations are persistent and saved on disk,
56  *    while MS-RPC registrations are documented as non-persistent
57  *    and stored only in RAM, and auto-destroyed when the process
58  *    dies (something DCE RPC can't do)
59  *
60  * Of course, if the user *did* want to run a DCE RPC daemon anyway,
61  * there would be interoperability advantages, like the possibility
62  * of running a fully functional DCOM server using Wine...
63  */
64
65 static const struct epm_endpoints
66 {
67     const char *protseq;
68     const char *endpoint;
69 } epm_endpoints[] =
70 {
71     { "ncacn_np", "\\pipe\\epmapper" },
72     { "ncacn_ip_tcp", "135" },
73     { "ncacn_ip_udp", "135" },
74     { "ncalrpc", "epmapper" },
75     { "ncacn_http", "593" },
76 };
77
78 static BOOL start_rpcss(void)
79 {
80     PROCESS_INFORMATION pi;
81     STARTUPINFOW si;
82     WCHAR cmd[MAX_PATH];
83     static const WCHAR rpcss[] = {'\\','r','p','c','s','s','.','e','x','e',0};
84     BOOL rslt;
85     void *redir;
86
87     TRACE("\n");
88
89     ZeroMemory(&si, sizeof(STARTUPINFOA));
90     si.cb = sizeof(STARTUPINFOA);
91     GetSystemDirectoryW( cmd, MAX_PATH - sizeof(rpcss)/sizeof(WCHAR) );
92     lstrcatW( cmd, rpcss );
93
94     Wow64DisableWow64FsRedirection( &redir );
95     rslt = CreateProcessW( cmd, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi );
96     Wow64RevertWow64FsRedirection( redir );
97
98     if (rslt)
99     {
100         CloseHandle(pi.hProcess);
101         CloseHandle(pi.hThread);
102         Sleep(100);
103     }
104
105     return rslt;
106 }
107
108 static inline BOOL is_epm_destination_local(RPC_BINDING_HANDLE handle)
109 {
110     RpcBinding *bind = handle;
111     const char *protseq = bind->Protseq;
112     const char *network_addr = bind->NetworkAddr;
113
114     return (!strcmp(protseq, "ncalrpc") ||
115            (!strcmp(protseq, "ncacn_np") &&
116                 (!network_addr || !strcmp(network_addr, "."))));
117 }
118
119 static RPC_STATUS get_epm_handle_client(RPC_BINDING_HANDLE handle, RPC_BINDING_HANDLE *epm_handle)
120 {
121     RpcBinding *bind = handle;
122     const char * pszEndpoint = NULL;
123     RPC_STATUS status;
124     RpcBinding* epm_bind;
125     unsigned int i;
126
127     if (bind->server)
128         return RPC_S_INVALID_BINDING;
129
130     for (i = 0; i < sizeof(epm_endpoints)/sizeof(epm_endpoints[0]); i++)
131         if (!strcmp(bind->Protseq, epm_endpoints[i].protseq))
132             pszEndpoint = epm_endpoints[i].endpoint;
133
134     if (!pszEndpoint)
135     {
136         FIXME("no endpoint for the endpoint-mapper found for protseq %s\n", debugstr_a(bind->Protseq));
137         return RPC_S_PROTSEQ_NOT_SUPPORTED;
138     }
139
140     status = RpcBindingCopy(handle, epm_handle);
141     if (status != RPC_S_OK) return status;
142
143     epm_bind = *epm_handle;
144     if (epm_bind->AuthInfo)
145     {
146         /* don't bother with authenticating against the EPM by default
147         * (see EnableAuthEpResolution registry value) */
148         RpcAuthInfo_Release(epm_bind->AuthInfo);
149         epm_bind->AuthInfo = NULL;
150     }
151     RPCRT4_ResolveBinding(epm_bind, pszEndpoint);
152     TRACE("RPC_S_OK\n");
153     return RPC_S_OK;
154 }
155
156 static RPC_STATUS get_epm_handle_server(RPC_BINDING_HANDLE *epm_handle)
157 {
158     unsigned char string_binding[] = "ncacn_np:.[\\\\pipe\\\\epmapper]";
159
160     return RpcBindingFromStringBindingA(string_binding, epm_handle);
161 }
162
163 static LONG WINAPI rpc_filter(EXCEPTION_POINTERS *__eptr)
164 {
165     switch (GetExceptionCode())
166     {
167         case EXCEPTION_ACCESS_VIOLATION:
168         case EXCEPTION_ILLEGAL_INSTRUCTION:
169             return EXCEPTION_CONTINUE_SEARCH;
170         default:
171             return EXCEPTION_EXECUTE_HANDLER;
172     }
173 }
174
175 static RPC_STATUS epm_register( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
176                                 UUID_VECTOR *UuidVector, RPC_CSTR Annotation, BOOL replace )
177 {
178   PRPC_SERVER_INTERFACE If = IfSpec;
179   ULONG i;
180   RPC_STATUS status = RPC_S_OK;
181   error_status_t status2;
182   ept_entry_t *entries;
183   handle_t handle;
184
185   TRACE("(%p,%p,%p,%s) replace=%d\n", IfSpec, BindingVector, UuidVector, debugstr_a((char*)Annotation), replace);
186   TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
187   for (i=0; i<BindingVector->Count; i++) {
188     RpcBinding* bind = BindingVector->BindingH[i];
189     TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq));
190     TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint));
191   }
192   if (UuidVector) {
193     for (i=0; i<UuidVector->Count; i++)
194       TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
195   }
196
197   if (!BindingVector->Count) return RPC_S_OK;
198
199   entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
200   if (!entries)
201       return RPC_S_OUT_OF_MEMORY;
202
203   status = get_epm_handle_server(&handle);
204   if (status != RPC_S_OK)
205   {
206     HeapFree(GetProcessHeap(), 0, entries);
207     return status;
208   }
209
210   for (i = 0; i < BindingVector->Count; i++)
211   {
212       unsigned j;
213       RpcBinding* bind = BindingVector->BindingH[i];
214       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
215       {
216           status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax,
217                                   bind->Protseq, bind->Endpoint,
218                                   bind->NetworkAddr,
219                                   &entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
220           if (status != RPC_S_OK) break;
221
222           if (UuidVector)
223               memcpy(&entries[i * UuidVector->Count].object, &UuidVector->Uuid[j], sizeof(GUID));
224           else
225               memset(&entries[i].object, 0, sizeof(entries[i].object));
226           if (Annotation)
227               memcpy(entries[i].annotation, Annotation,
228                      min(strlen((char *)Annotation) + 1, ept_max_annotation_size));
229       }
230   }
231
232   if (status == RPC_S_OK)
233   {
234       while (TRUE)
235       {
236           __TRY
237           {
238               ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
239                          entries, replace, &status2);
240           }
241           __EXCEPT(rpc_filter)
242           {
243               status2 = GetExceptionCode();
244           }
245           __ENDTRY
246           if (status2 == RPC_S_SERVER_UNAVAILABLE &&
247               is_epm_destination_local(handle))
248           {
249               if (start_rpcss())
250                   continue;
251           }
252           if (status2 != RPC_S_OK)
253               ERR("ept_insert failed with error %d\n", status2);
254           status = status2; /* FIXME: convert status? */
255           break;
256       }
257   }
258   RpcBindingFree(&handle);
259
260   for (i = 0; i < BindingVector->Count; i++)
261   {
262       unsigned j;
263       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
264           I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
265   }
266
267   HeapFree(GetProcessHeap(), 0, entries);
268
269   return status;
270 }
271
272 /***********************************************************************
273  *             RpcEpRegisterA (RPCRT4.@)
274  */
275 RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
276                                   UUID_VECTOR *UuidVector, RPC_CSTR Annotation )
277 {
278     return epm_register(IfSpec, BindingVector, UuidVector, Annotation, TRUE);
279 }
280
281 /***********************************************************************
282  *             RpcEpRegisterNoReplaceA (RPCRT4.@)
283  */
284 RPC_STATUS WINAPI RpcEpRegisterNoReplaceA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
285                                            UUID_VECTOR *UuidVector, RPC_CSTR Annotation )
286 {
287     return epm_register(IfSpec, BindingVector, UuidVector, Annotation, FALSE);
288 }
289
290 /***********************************************************************
291  *             RpcEpRegisterW (RPCRT4.@)
292  */
293 RPC_STATUS WINAPI RpcEpRegisterW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
294                                   UUID_VECTOR *UuidVector, RPC_WSTR Annotation )
295 {
296   LPSTR annA = RPCRT4_strdupWtoA(Annotation);
297   RPC_STATUS status;
298
299   status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, TRUE);
300
301   HeapFree(GetProcessHeap(), 0, annA);
302   return status;
303 }
304
305 /***********************************************************************
306  *             RpcEpRegisterNoReplaceW (RPCRT4.@)
307  */
308 RPC_STATUS WINAPI RpcEpRegisterNoReplaceW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
309                                            UUID_VECTOR *UuidVector, RPC_WSTR Annotation )
310 {
311   LPSTR annA = RPCRT4_strdupWtoA(Annotation);
312   RPC_STATUS status;
313
314   status = epm_register(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA, FALSE);
315
316   HeapFree(GetProcessHeap(), 0, annA);
317   return status;
318 }
319
320 /***********************************************************************
321  *             RpcEpUnregister (RPCRT4.@)
322  */
323 RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
324                                    UUID_VECTOR *UuidVector )
325 {
326   PRPC_SERVER_INTERFACE If = IfSpec;
327   ULONG i;
328   RPC_STATUS status = RPC_S_OK;
329   error_status_t status2;
330   ept_entry_t *entries;
331   handle_t handle;
332
333   TRACE("(%p,%p,%p)\n", IfSpec, BindingVector, UuidVector);
334   TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
335   for (i=0; i<BindingVector->Count; i++) {
336     RpcBinding* bind = BindingVector->BindingH[i];
337     TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq));
338     TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint));
339   }
340   if (UuidVector) {
341     for (i=0; i<UuidVector->Count; i++)
342       TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
343   }
344
345   entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
346   if (!entries)
347       return RPC_S_OUT_OF_MEMORY;
348
349   status = get_epm_handle_server(&handle);
350   if (status != RPC_S_OK)
351   {
352     HeapFree(GetProcessHeap(), 0, entries);
353     return status;
354   }
355
356   for (i = 0; i < BindingVector->Count; i++)
357   {
358       unsigned j;
359       RpcBinding* bind = BindingVector->BindingH[i];
360       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
361       {
362           status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax,
363                                   bind->Protseq, bind->Endpoint,
364                                   bind->NetworkAddr,
365                                   &entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
366           if (status != RPC_S_OK) break;
367
368           if (UuidVector)
369               memcpy(&entries[i * UuidVector->Count + j].object, &UuidVector->Uuid[j], sizeof(GUID));
370           else
371               memset(&entries[i].object, 0, sizeof(entries[i].object));
372       }
373   }
374
375   if (status == RPC_S_OK)
376   {
377       __TRY
378       {
379           ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
380                      entries, TRUE, &status2);
381       }
382       __EXCEPT(rpc_filter)
383       {
384           status2 = GetExceptionCode();
385       }
386       __ENDTRY
387       if (status2 == RPC_S_SERVER_UNAVAILABLE)
388           status2 = EPT_S_NOT_REGISTERED;
389       if (status2 != RPC_S_OK)
390           ERR("ept_insert failed with error %d\n", status2);
391       status = status2; /* FIXME: convert status? */
392   }
393   RpcBindingFree(&handle);
394
395   for (i = 0; i < BindingVector->Count; i++)
396   {
397       unsigned j;
398       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
399           I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
400   }
401
402   HeapFree(GetProcessHeap(), 0, entries);
403
404   return status;
405 }
406
407 /***********************************************************************
408  *             RpcEpResolveBinding (RPCRT4.@)
409  */
410 RPC_STATUS WINAPI RpcEpResolveBinding( RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec )
411 {
412   PRPC_CLIENT_INTERFACE If = IfSpec;
413   RpcBinding* bind = Binding;
414   RPC_STATUS status;
415   error_status_t status2;
416   handle_t handle;
417   ept_lookup_handle_t entry_handle = NULL;
418   twr_t *tower;
419   twr_t *towers[4] = { NULL };
420   unsigned32 num_towers, i;
421   GUID uuid = GUID_NULL;
422   char *resolved_endpoint = NULL;
423
424   TRACE("(%p,%p)\n", Binding, IfSpec);
425   TRACE(" protseq=%s\n", debugstr_a(bind->Protseq));
426   TRACE(" obj=%s\n", debugstr_guid(&bind->ObjectUuid));
427   TRACE(" networkaddr=%s\n", debugstr_a(bind->NetworkAddr));
428   TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
429
430   /* just return for fully bound handles */
431   if (bind->Endpoint && (bind->Endpoint[0] != '\0'))
432     return RPC_S_OK;
433
434   status = get_epm_handle_client(Binding, &handle);
435   if (status != RPC_S_OK) return status;
436   
437   status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax, bind->Protseq,
438                           ((RpcBinding *)handle)->Endpoint,
439                           bind->NetworkAddr, &tower);
440   if (status != RPC_S_OK)
441   {
442       WARN("couldn't get tower\n");
443       RpcBindingFree(&handle);
444       return status;
445   }
446
447   while (TRUE)
448   {
449     __TRY
450     {
451       ept_map(handle, &uuid, tower, &entry_handle, sizeof(towers)/sizeof(towers[0]), &num_towers, towers, &status2);
452       /* FIXME: translate status2? */
453     }
454     __EXCEPT(rpc_filter)
455     {
456       status2 = GetExceptionCode();
457     }
458     __ENDTRY
459     if (status2 == RPC_S_SERVER_UNAVAILABLE &&
460         is_epm_destination_local(handle))
461     {
462       if (start_rpcss())
463         continue;
464     }
465     break;
466   };
467
468   RpcBindingFree(&handle);
469   I_RpcFree(tower);
470
471   if (status2 != RPC_S_OK)
472   {
473     ERR("ept_map failed for ifid %s, protseq %s, networkaddr %s\n", debugstr_guid(&If->TransferSyntax.SyntaxGUID), bind->Protseq, bind->NetworkAddr);
474     return status2;
475   }
476
477   for (i = 0; i < num_towers; i++)
478   {
479     /* only parse the tower if we haven't already found a suitable
480     * endpoint, otherwise just free the tower */
481     if (!resolved_endpoint)
482     {
483       status = TowerExplode(towers[i], NULL, NULL, NULL, &resolved_endpoint, NULL);
484       TRACE("status = %d\n", status);
485     }
486     I_RpcFree(towers[i]);
487   }
488
489   if (resolved_endpoint)
490   {
491     RPCRT4_ResolveBinding(Binding, resolved_endpoint);
492     I_RpcFree(resolved_endpoint);
493     return RPC_S_OK;
494   }
495
496   WARN("couldn't find an endpoint\n");
497   return EPT_S_NOT_REGISTERED;
498 }
499
500 /*****************************************************************************
501  * TowerExplode (RPCRT4.@)
502  */
503 RPC_STATUS WINAPI TowerExplode(
504     const twr_t *tower, PRPC_SYNTAX_IDENTIFIER object, PRPC_SYNTAX_IDENTIFIER syntax,
505     char **protseq, char **endpoint, char **address)
506 {
507     size_t tower_size;
508     RPC_STATUS status;
509     const unsigned char *p;
510     u_int16 floor_count;
511     const twr_uuid_floor_t *object_floor;
512     const twr_uuid_floor_t *syntax_floor;
513
514     TRACE("(%p, %p, %p, %p, %p, %p)\n", tower, object, syntax, protseq,
515           endpoint, address);
516
517     if (protseq)
518         *protseq = NULL;
519     if (endpoint)
520         *endpoint = NULL;
521     if (address)
522         *address = NULL;
523
524     tower_size = tower->tower_length;
525
526     if (tower_size < sizeof(u_int16))
527         return EPT_S_NOT_REGISTERED;
528
529     p = &tower->tower_octet_string[0];
530
531     floor_count = *(const u_int16 *)p;
532     p += sizeof(u_int16);
533     tower_size -= sizeof(u_int16);
534     TRACE("floor_count: %d\n", floor_count);
535     /* FIXME: should we do something with the floor count? at the moment we don't */
536
537     if (tower_size < sizeof(*object_floor) + sizeof(*syntax_floor))
538         return EPT_S_NOT_REGISTERED;
539
540     object_floor = (const twr_uuid_floor_t *)p;
541     p += sizeof(*object_floor);
542     tower_size -= sizeof(*object_floor);
543     syntax_floor = (const twr_uuid_floor_t *)p;
544     p += sizeof(*syntax_floor);
545     tower_size -= sizeof(*syntax_floor);
546
547     if ((object_floor->count_lhs != sizeof(object_floor->protid) +
548         sizeof(object_floor->uuid) + sizeof(object_floor->major_version)) ||
549         (object_floor->protid != EPM_PROTOCOL_UUID) ||
550         (object_floor->count_rhs != sizeof(object_floor->minor_version)))
551         return EPT_S_NOT_REGISTERED;
552
553     if ((syntax_floor->count_lhs != sizeof(syntax_floor->protid) +
554         sizeof(syntax_floor->uuid) + sizeof(syntax_floor->major_version)) ||
555         (syntax_floor->protid != EPM_PROTOCOL_UUID) ||
556         (syntax_floor->count_rhs != sizeof(syntax_floor->minor_version)))
557         return EPT_S_NOT_REGISTERED;
558
559     status = RpcTransport_ParseTopOfTower(p, tower_size, protseq, address, endpoint);
560     if ((status == RPC_S_OK) && syntax && object)
561     {
562         syntax->SyntaxGUID = syntax_floor->uuid;
563         syntax->SyntaxVersion.MajorVersion = syntax_floor->major_version;
564         syntax->SyntaxVersion.MinorVersion = syntax_floor->minor_version;
565         object->SyntaxGUID = object_floor->uuid;
566         object->SyntaxVersion.MajorVersion = object_floor->major_version;
567         object->SyntaxVersion.MinorVersion = object_floor->minor_version;
568     }
569     return status;
570 }
571
572 /***********************************************************************
573  *             TowerConstruct (RPCRT4.@)
574  */
575 RPC_STATUS WINAPI TowerConstruct(
576     const RPC_SYNTAX_IDENTIFIER *object, const RPC_SYNTAX_IDENTIFIER *syntax,
577     const char *protseq, const char *endpoint, const char *address,
578     twr_t **tower)
579 {
580     size_t tower_size;
581     RPC_STATUS status;
582     unsigned char *p;
583     twr_uuid_floor_t *object_floor;
584     twr_uuid_floor_t *syntax_floor;
585
586     TRACE("(%p, %p, %s, %s, %s, %p)\n", object, syntax, debugstr_a(protseq),
587           debugstr_a(endpoint), debugstr_a(address), tower);
588
589     *tower = NULL;
590
591     status = RpcTransport_GetTopOfTower(NULL, &tower_size, protseq, address, endpoint);
592
593     if (status != RPC_S_OK)
594         return status;
595
596     tower_size += sizeof(u_int16) + sizeof(*object_floor) + sizeof(*syntax_floor);
597     *tower = I_RpcAllocate(FIELD_OFFSET(twr_t, tower_octet_string[tower_size]));
598     if (!*tower)
599         return RPC_S_OUT_OF_RESOURCES;
600
601     (*tower)->tower_length = tower_size;
602     p = &(*tower)->tower_octet_string[0];
603     *(u_int16 *)p = 5; /* number of floors */
604     p += sizeof(u_int16);
605     object_floor = (twr_uuid_floor_t *)p;
606     p += sizeof(*object_floor);
607     syntax_floor = (twr_uuid_floor_t *)p;
608     p += sizeof(*syntax_floor);
609
610     object_floor->count_lhs = sizeof(object_floor->protid) + sizeof(object_floor->uuid) +
611                               sizeof(object_floor->major_version);
612     object_floor->protid = EPM_PROTOCOL_UUID;
613     object_floor->count_rhs = sizeof(object_floor->minor_version);
614     object_floor->uuid = object->SyntaxGUID;
615     object_floor->major_version = object->SyntaxVersion.MajorVersion;
616     object_floor->minor_version = object->SyntaxVersion.MinorVersion;
617
618     syntax_floor->count_lhs = sizeof(syntax_floor->protid) + sizeof(syntax_floor->uuid) +
619                               sizeof(syntax_floor->major_version);
620     syntax_floor->protid = EPM_PROTOCOL_UUID;
621     syntax_floor->count_rhs = sizeof(syntax_floor->minor_version);
622     syntax_floor->uuid = syntax->SyntaxGUID;
623     syntax_floor->major_version = syntax->SyntaxVersion.MajorVersion;
624     syntax_floor->minor_version = syntax->SyntaxVersion.MinorVersion;
625
626     status = RpcTransport_GetTopOfTower(p, &tower_size, protseq, address, endpoint);
627     if (status != RPC_S_OK)
628     {
629         I_RpcFree(*tower);
630         *tower = NULL;
631         return status;
632     }
633     return RPC_S_OK;
634 }
635
636 void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
637 {
638     return HeapAlloc(GetProcessHeap(), 0, len);
639 }
640
641 void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
642 {
643     HeapFree(GetProcessHeap(), 0, ptr);
644 }