rpcrt4: Add a phase in proxies for clearing output parameters on error.
[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, 0, 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 /***********************************************************************
176  *             RpcEpRegisterA (RPCRT4.@)
177  */
178 RPC_STATUS WINAPI RpcEpRegisterA( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
179                                   UUID_VECTOR *UuidVector, RPC_CSTR Annotation )
180 {
181   PRPC_SERVER_INTERFACE If = IfSpec;
182   ULONG i;
183   RPC_STATUS status = RPC_S_OK;
184   error_status_t status2;
185   ept_entry_t *entries;
186   handle_t handle;
187
188   TRACE("(%p,%p,%p,%s)\n", IfSpec, BindingVector, UuidVector, debugstr_a((char*)Annotation));
189   TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
190   for (i=0; i<BindingVector->Count; i++) {
191     RpcBinding* bind = BindingVector->BindingH[i];
192     TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq));
193     TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint));
194   }
195   if (UuidVector) {
196     for (i=0; i<UuidVector->Count; i++)
197       TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
198   }
199
200   if (!BindingVector->Count) return RPC_S_OK;
201
202   entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
203   if (!entries)
204       return RPC_S_OUT_OF_MEMORY;
205
206   status = get_epm_handle_server(&handle);
207   if (status != RPC_S_OK)
208   {
209     HeapFree(GetProcessHeap(), 0, entries);
210     return status;
211   }
212
213   for (i = 0; i < BindingVector->Count; i++)
214   {
215       unsigned j;
216       RpcBinding* bind = BindingVector->BindingH[i];
217       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
218       {
219           status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax,
220                                   bind->Protseq, bind->Endpoint,
221                                   bind->NetworkAddr,
222                                   &entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
223           if (status != RPC_S_OK) break;
224
225           if (UuidVector)
226               memcpy(&entries[i * UuidVector->Count].object, &UuidVector->Uuid[j], sizeof(GUID));
227           else
228               memset(&entries[i].object, 0, sizeof(entries[i].object));
229           if (Annotation)
230               memcpy(entries[i].annotation, Annotation,
231                      min(strlen((char *)Annotation) + 1, ept_max_annotation_size));
232       }
233   }
234
235   if (status == RPC_S_OK)
236   {
237       while (TRUE)
238       {
239           __TRY
240           {
241               ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
242                          entries, TRUE, &status2);
243           }
244           __EXCEPT(rpc_filter)
245           {
246               status2 = GetExceptionCode();
247           }
248           __ENDTRY
249           if (status2 == RPC_S_SERVER_UNAVAILABLE &&
250               is_epm_destination_local(handle))
251           {
252               if (start_rpcss())
253                   continue;
254           }
255           if (status2 != RPC_S_OK)
256               ERR("ept_insert failed with error %d\n", status2);
257           status = status2; /* FIXME: convert status? */
258           break;
259       }
260   }
261   RpcBindingFree(&handle);
262
263   for (i = 0; i < BindingVector->Count; i++)
264   {
265       unsigned j;
266       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
267           I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
268   }
269
270   HeapFree(GetProcessHeap(), 0, entries);
271
272   return status;
273 }
274
275 /***********************************************************************
276  *             RpcEpRegisterW (RPCRT4.@)
277  */
278 RPC_STATUS WINAPI RpcEpRegisterW( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
279                                   UUID_VECTOR *UuidVector, RPC_WSTR Annotation )
280 {
281   LPSTR annA = RPCRT4_strdupWtoA(Annotation);
282   RPC_STATUS status;
283
284   status = RpcEpRegisterA(IfSpec, BindingVector, UuidVector, (RPC_CSTR)annA);
285
286   HeapFree(GetProcessHeap(), 0, annA);
287   return status;
288 }
289
290 /***********************************************************************
291  *             RpcEpUnregister (RPCRT4.@)
292  */
293 RPC_STATUS WINAPI RpcEpUnregister( RPC_IF_HANDLE IfSpec, RPC_BINDING_VECTOR *BindingVector,
294                                    UUID_VECTOR *UuidVector )
295 {
296   PRPC_SERVER_INTERFACE If = IfSpec;
297   ULONG i;
298   RPC_STATUS status = RPC_S_OK;
299   error_status_t status2;
300   ept_entry_t *entries;
301   handle_t handle;
302
303   TRACE("(%p,%p,%p)\n", IfSpec, BindingVector, UuidVector);
304   TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
305   for (i=0; i<BindingVector->Count; i++) {
306     RpcBinding* bind = BindingVector->BindingH[i];
307     TRACE(" protseq[%d]=%s\n", i, debugstr_a(bind->Protseq));
308     TRACE(" endpoint[%d]=%s\n", i, debugstr_a(bind->Endpoint));
309   }
310   if (UuidVector) {
311     for (i=0; i<UuidVector->Count; i++)
312       TRACE(" obj[%d]=%s\n", i, debugstr_guid(UuidVector->Uuid[i]));
313   }
314
315   entries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*entries) * BindingVector->Count * (UuidVector ? UuidVector->Count : 1));
316   if (!entries)
317       return RPC_S_OUT_OF_MEMORY;
318
319   status = get_epm_handle_server(&handle);
320   if (status != RPC_S_OK)
321   {
322     HeapFree(GetProcessHeap(), 0, entries);
323     return status;
324   }
325
326   for (i = 0; i < BindingVector->Count; i++)
327   {
328       unsigned j;
329       RpcBinding* bind = BindingVector->BindingH[i];
330       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
331       {
332           status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax,
333                                   bind->Protseq, bind->Endpoint,
334                                   bind->NetworkAddr,
335                                   &entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
336           if (status != RPC_S_OK) break;
337
338           if (UuidVector)
339               memcpy(&entries[i * UuidVector->Count + j].object, &UuidVector->Uuid[j], sizeof(GUID));
340           else
341               memset(&entries[i].object, 0, sizeof(entries[i].object));
342       }
343   }
344
345   if (status == RPC_S_OK)
346   {
347       __TRY
348       {
349           ept_insert(handle, BindingVector->Count * (UuidVector ? UuidVector->Count : 1),
350                      entries, TRUE, &status2);
351       }
352       __EXCEPT(rpc_filter)
353       {
354           status2 = GetExceptionCode();
355       }
356       __ENDTRY
357       if (status2 == RPC_S_SERVER_UNAVAILABLE)
358           status2 = EPT_S_NOT_REGISTERED;
359       if (status2 != RPC_S_OK)
360           ERR("ept_insert failed with error %d\n", status2);
361       status = status2; /* FIXME: convert status? */
362   }
363   RpcBindingFree(&handle);
364
365   for (i = 0; i < BindingVector->Count; i++)
366   {
367       unsigned j;
368       for (j = 0; j < (UuidVector ? UuidVector->Count : 1); j++)
369           I_RpcFree(entries[i*(UuidVector ? UuidVector->Count : 1) + j].tower);
370   }
371
372   HeapFree(GetProcessHeap(), 0, entries);
373
374   return status;
375 }
376
377 /***********************************************************************
378  *             RpcEpResolveBinding (RPCRT4.@)
379  */
380 RPC_STATUS WINAPI RpcEpResolveBinding( RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec )
381 {
382   PRPC_CLIENT_INTERFACE If = IfSpec;
383   RpcBinding* bind = Binding;
384   RPC_STATUS status;
385   error_status_t status2;
386   handle_t handle;
387   ept_lookup_handle_t entry_handle = NULL;
388   twr_t *tower;
389   twr_t *towers[4] = { NULL };
390   unsigned32 num_towers, i;
391   GUID uuid = GUID_NULL;
392   char *resolved_endpoint = NULL;
393
394   TRACE("(%p,%p)\n", Binding, IfSpec);
395   TRACE(" protseq=%s\n", debugstr_a(bind->Protseq));
396   TRACE(" obj=%s\n", debugstr_guid(&bind->ObjectUuid));
397   TRACE(" networkaddr=%s\n", debugstr_a(bind->NetworkAddr));
398   TRACE(" ifid=%s\n", debugstr_guid(&If->InterfaceId.SyntaxGUID));
399
400   /* just return for fully bound handles */
401   if (bind->Endpoint && (bind->Endpoint[0] != '\0'))
402     return RPC_S_OK;
403
404   status = get_epm_handle_client(Binding, &handle);
405   if (status != RPC_S_OK) return status;
406   
407   status = TowerConstruct(&If->InterfaceId, &If->TransferSyntax, bind->Protseq,
408                           ((RpcBinding *)handle)->Endpoint,
409                           bind->NetworkAddr, &tower);
410   if (status != RPC_S_OK)
411   {
412       WARN("couldn't get tower\n");
413       RpcBindingFree(&handle);
414       return status;
415   }
416
417   while (TRUE)
418   {
419     __TRY
420     {
421       ept_map(handle, &uuid, tower, &entry_handle, sizeof(towers)/sizeof(towers[0]), &num_towers, towers, &status2);
422       /* FIXME: translate status2? */
423     }
424     __EXCEPT(rpc_filter)
425     {
426       status2 = GetExceptionCode();
427     }
428     __ENDTRY
429     if (status2 == RPC_S_SERVER_UNAVAILABLE &&
430         is_epm_destination_local(handle))
431     {
432       if (start_rpcss())
433         continue;
434     }
435     break;
436   };
437
438   RpcBindingFree(&handle);
439   I_RpcFree(tower);
440
441   if (status2 != RPC_S_OK)
442   {
443     ERR("ept_map failed for ifid %s, protseq %s, networkaddr %s\n", debugstr_guid(&If->TransferSyntax.SyntaxGUID), bind->Protseq, bind->NetworkAddr);
444     return status2;
445   }
446
447   for (i = 0; i < num_towers; i++)
448   {
449     /* only parse the tower if we haven't already found a suitable
450     * endpoint, otherwise just free the tower */
451     if (!resolved_endpoint)
452     {
453       status = TowerExplode(towers[i], NULL, NULL, NULL, &resolved_endpoint, NULL);
454       TRACE("status = %d\n", status);
455     }
456     I_RpcFree(towers[i]);
457   }
458
459   if (resolved_endpoint)
460   {
461     RPCRT4_ResolveBinding(Binding, resolved_endpoint);
462     I_RpcFree(resolved_endpoint);
463     return RPC_S_OK;
464   }
465
466   WARN("couldn't find an endpoint\n");
467   return EPT_S_NOT_REGISTERED;
468 }
469
470 /*****************************************************************************
471  * TowerExplode (RPCRT4.@)
472  */
473 RPC_STATUS WINAPI TowerExplode(
474     const twr_t *tower, PRPC_SYNTAX_IDENTIFIER object, PRPC_SYNTAX_IDENTIFIER syntax,
475     char **protseq, char **endpoint, char **address)
476 {
477     size_t tower_size;
478     RPC_STATUS status;
479     const unsigned char *p;
480     u_int16 floor_count;
481     const twr_uuid_floor_t *object_floor;
482     const twr_uuid_floor_t *syntax_floor;
483
484     TRACE("(%p, %p, %p, %p, %p, %p)\n", tower, object, syntax, protseq,
485           endpoint, address);
486
487     if (protseq)
488         *protseq = NULL;
489     if (endpoint)
490         *endpoint = NULL;
491     if (address)
492         *address = NULL;
493
494     tower_size = tower->tower_length;
495
496     if (tower_size < sizeof(u_int16))
497         return EPT_S_NOT_REGISTERED;
498
499     p = &tower->tower_octet_string[0];
500
501     floor_count = *(const u_int16 *)p;
502     p += sizeof(u_int16);
503     tower_size -= sizeof(u_int16);
504     TRACE("floor_count: %d\n", floor_count);
505     /* FIXME: should we do something with the floor count? at the moment we don't */
506
507     if (tower_size < sizeof(*object_floor) + sizeof(*syntax_floor))
508         return EPT_S_NOT_REGISTERED;
509
510     object_floor = (const twr_uuid_floor_t *)p;
511     p += sizeof(*object_floor);
512     tower_size -= sizeof(*object_floor);
513     syntax_floor = (const twr_uuid_floor_t *)p;
514     p += sizeof(*syntax_floor);
515     tower_size -= sizeof(*syntax_floor);
516
517     if ((object_floor->count_lhs != sizeof(object_floor->protid) +
518         sizeof(object_floor->uuid) + sizeof(object_floor->major_version)) ||
519         (object_floor->protid != EPM_PROTOCOL_UUID) ||
520         (object_floor->count_rhs != sizeof(object_floor->minor_version)))
521         return EPT_S_NOT_REGISTERED;
522
523     if ((syntax_floor->count_lhs != sizeof(syntax_floor->protid) +
524         sizeof(syntax_floor->uuid) + sizeof(syntax_floor->major_version)) ||
525         (syntax_floor->protid != EPM_PROTOCOL_UUID) ||
526         (syntax_floor->count_rhs != sizeof(syntax_floor->minor_version)))
527         return EPT_S_NOT_REGISTERED;
528
529     status = RpcTransport_ParseTopOfTower(p, tower_size, protseq, address, endpoint);
530     if ((status == RPC_S_OK) && syntax && object)
531     {
532         syntax->SyntaxGUID = syntax_floor->uuid;
533         syntax->SyntaxVersion.MajorVersion = syntax_floor->major_version;
534         syntax->SyntaxVersion.MinorVersion = syntax_floor->minor_version;
535         object->SyntaxGUID = object_floor->uuid;
536         object->SyntaxVersion.MajorVersion = object_floor->major_version;
537         object->SyntaxVersion.MinorVersion = object_floor->minor_version;
538     }
539     return status;
540 }
541
542 /***********************************************************************
543  *             TowerConstruct (RPCRT4.@)
544  */
545 RPC_STATUS WINAPI TowerConstruct(
546     const RPC_SYNTAX_IDENTIFIER *object, const RPC_SYNTAX_IDENTIFIER *syntax,
547     const char *protseq, const char *endpoint, const char *address,
548     twr_t **tower)
549 {
550     size_t tower_size;
551     RPC_STATUS status;
552     unsigned char *p;
553     twr_uuid_floor_t *object_floor;
554     twr_uuid_floor_t *syntax_floor;
555
556     TRACE("(%p, %p, %s, %s, %s, %p)\n", object, syntax, debugstr_a(protseq),
557           debugstr_a(endpoint), debugstr_a(address), tower);
558
559     *tower = NULL;
560
561     status = RpcTransport_GetTopOfTower(NULL, &tower_size, protseq, address, endpoint);
562
563     if (status != RPC_S_OK)
564         return status;
565
566     tower_size += sizeof(u_int16) + sizeof(*object_floor) + sizeof(*syntax_floor);
567     *tower = I_RpcAllocate(FIELD_OFFSET(twr_t, tower_octet_string[tower_size]));
568     if (!*tower)
569         return RPC_S_OUT_OF_RESOURCES;
570
571     (*tower)->tower_length = tower_size;
572     p = &(*tower)->tower_octet_string[0];
573     *(u_int16 *)p = 5; /* number of floors */
574     p += sizeof(u_int16);
575     object_floor = (twr_uuid_floor_t *)p;
576     p += sizeof(*object_floor);
577     syntax_floor = (twr_uuid_floor_t *)p;
578     p += sizeof(*syntax_floor);
579
580     object_floor->count_lhs = sizeof(object_floor->protid) + sizeof(object_floor->uuid) +
581                               sizeof(object_floor->major_version);
582     object_floor->protid = EPM_PROTOCOL_UUID;
583     object_floor->count_rhs = sizeof(object_floor->minor_version);
584     object_floor->uuid = object->SyntaxGUID;
585     object_floor->major_version = object->SyntaxVersion.MajorVersion;
586     object_floor->minor_version = object->SyntaxVersion.MinorVersion;
587
588     syntax_floor->count_lhs = sizeof(syntax_floor->protid) + sizeof(syntax_floor->uuid) +
589                               sizeof(syntax_floor->major_version);
590     syntax_floor->protid = EPM_PROTOCOL_UUID;
591     syntax_floor->count_rhs = sizeof(syntax_floor->minor_version);
592     syntax_floor->uuid = syntax->SyntaxGUID;
593     syntax_floor->major_version = syntax->SyntaxVersion.MajorVersion;
594     syntax_floor->minor_version = syntax->SyntaxVersion.MinorVersion;
595
596     status = RpcTransport_GetTopOfTower(p, &tower_size, protseq, address, endpoint);
597     if (status != RPC_S_OK)
598     {
599         I_RpcFree(*tower);
600         *tower = NULL;
601         return status;
602     }
603     return RPC_S_OK;
604 }
605
606 void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
607 {
608     return HeapAlloc(GetProcessHeap(), 0, len);
609 }
610
611 void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
612 {
613     HeapFree(GetProcessHeap(), 0, ptr);
614 }