Split between 16 / 32 bit code.
[wine/dcerpc.git] / dlls / rpcrt4 / rpcrt4_main.c
blob7f02f368d185f48c0064fb605a1c272c3108d4fc
1 /*
2 * RPCRT4
4 * Copyright 2000 Huw D M Davies for Codeweavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * WINE RPC TODO's (and a few TODONT's)
22 * - widl is like MIDL for wine. For wine to be a useful RPC platform, quite
23 * a bit of work needs to be done here. widl currently doesn't generate stubs
24 * for RPC invocation -- it will need to; this is tricky because the MIDL compiler
25 * does some really wierd stuff. Then again, we don't neccesarily have to
26 * make widl work like MIDL, so it could be worse.
28 * - RPC has a quite featureful error handling mechanism; none of it is implemented
29 * right now.
31 * - The server portions of the patch don't seem to be getting accepted by
32 * Alexandre. My guess is that once I have a working test he'll conceed to
33 * let this in. To implement this properly is tricky and possibly beyond my
34 * abilities; Ove seems to think the right way to do this is to use LPC
35 * (Local Procedure Call, another undocumented monster). LPC has no implementation
36 * in wine and is not going to be trivial to create.
38 * - There are several different memory allocation schemes for MSRPC.
39 * I don't even understand what they all are yet, much less have them
40 * properly implemented. Surely we are supposed to be doing something with
41 * the user-provided allocation/deallocation functions, but so far,
42 * I don't think we are doing this...
44 * - MSRPC provides impersonation capabilities which currently are not possible
45 * to implement in wine. At the very least we should implement the authorization
46 * API's & gracefully ignore the irrelevant stuff (to a small extent we already do).
48 * - Some transports are not yet implemented. The existing transport implementations
49 * are incomplete; the various transports probably ought to be supported in a more
50 * object-oriented manner, like in DCE's RPC implementation, instead of cluttering
51 * up the code with conditionals like we do now.
53 * - Data marshalling: So far, only the very beginnings of an implementation
54 * exist in wine. NDR protocol is mostly documented, but the MS API's to
55 * convert data-types in memory into NDR are not.
57 * - ORPC is RPC for OLE; once we have a working RPC framework, we can
58 * use it to implement out-of-process OLE client/server communications.
59 * ATM there is a 100% disconnect between the marshalling in the OLE DLL's
60 * and the marshalling going on here. This is a good thing, since marshalling
61 * doesn't work yet. But once it does, obviously there will be the opportunity
62 * to implement out-of-process OLE using wine's rpcrt4 or some derivative.
64 * - In-source API Documentation, at least for those functions which we have
65 * implemented, but preferably for everything we can document, would be nice.
66 * I started out being quite good about this, and ended up getting lazy.
67 * Some stuff is undocumented by Microsoft and we are guessing how to implement
68 * (in these cases we should document the behavior we implemented, or, if there
69 * is no implementation, at least hazard some kind of guess, and put a few
70 * question marks after it ;) ).
72 * - Stubs. Lots of stuff is defined in Microsoft's headers, including undocumented
73 * stuff. So let's make a stub-farm and populate it with as many rpcrt4 api's as
74 * we can stand, so people don't get unimplemented function exceptions.
76 * - Name services: this part hasn't even been started.
78 * - Concurrency: right now I don't think (?) we handle more than one request at a time;
79 * we are supposed to be able to do this, and to queue requests which exceed the
80 * concurrency limit.
82 * - Protocol Towers: Totally unimplemented. I don't even know what these are.
84 * - Context Handle Rundown: whatever that is.
86 * - Nested RPC's: Totally unimplemented.
88 * - Statistics: we are supposed to be keeping various counters. we aren't.
90 * - Connectionless RPC: unimplemented.
92 * - ...? More stuff I haven't thought of. If you think of more RPC todo's drop me
93 * an e-mail <gmturner007@ameritech.net> or send a patch to wine-patches.
96 #include "config.h"
98 #include <stdio.h>
99 #include <stdlib.h>
100 #include <string.h>
101 #include <time.h>
102 #ifdef HAVE_SYS_TIME_H
103 # include <sys/time.h>
104 #endif
105 #ifdef HAVE_UNISTD_H
106 # include <unistd.h>
107 #endif
109 #include "windef.h"
110 #include "winerror.h"
111 #include "winbase.h"
112 #include "wine/unicode.h"
113 #include "rpc.h"
115 #include "ole2.h"
116 #include "rpcndr.h"
117 #include "rpcproxy.h"
119 #ifdef HAVE_SYS_FILE_H
120 # include <sys/file.h>
121 #endif
122 #ifdef HAVE_SYS_IOCTL_H
123 # include <sys/ioctl.h>
124 #endif
125 #ifdef HAVE_SYS_SOCKET_H
126 # include <sys/socket.h>
127 #endif
128 #ifdef HAVE_SYS_SOCKIO_H
129 # include <sys/sockio.h>
130 #endif
131 #ifdef HAVE_NET_IF_H
132 # include <net/if.h>
133 #endif
134 #ifdef HAVE_NETINET_IN_H
135 # include <netinet/in.h>
136 #endif
138 #include "rpc_binding.h"
140 #include "wine/debug.h"
142 WINE_DEFAULT_DEBUG_CHANNEL(ole);
144 static UUID uuid_nil;
146 /***********************************************************************
147 * RPCRT4_LibMain
149 * PARAMS
150 * hinstDLL [I] handle to the DLL's instance
151 * fdwReason [I]
152 * lpvReserved [I] reserved, must be NULL
154 * RETURNS
155 * Success: TRUE
156 * Failure: FALSE
159 BOOL WINAPI
160 RPCRT4_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
162 switch (fdwReason) {
163 case DLL_PROCESS_ATTACH:
164 break;
166 case DLL_PROCESS_DETACH:
167 break;
170 return TRUE;
173 /*************************************************************************
174 * RpcStringFreeA [RPCRT4.@]
176 * Frees a character string allocated by the RPC run-time library.
178 * RETURNS
180 * S_OK if successful.
182 RPC_STATUS WINAPI RpcStringFreeA(LPSTR* String)
184 HeapFree( GetProcessHeap(), 0, *String);
186 return RPC_S_OK;
189 /*************************************************************************
190 * RpcStringFreeW [RPCRT4.@]
192 * Frees a character string allocated by the RPC run-time library.
194 * RETURNS
196 * S_OK if successful.
198 RPC_STATUS WINAPI RpcStringFreeW(LPWSTR* String)
200 HeapFree( GetProcessHeap(), 0, *String);
202 return RPC_S_OK;
205 /*************************************************************************
206 * UuidCompare [RPCRT4.@]
208 * (an educated-guess implementation)
210 * PARAMS
211 * UUID *Uuid1 [I] Uuid to compare
212 * UUID *Uuid2 [I] Uuid to compare
213 * RPC_STATUS *Status [O] returns RPC_S_OK
215 * RETURNS
216 * -1 if Uuid1 is less than Uuid2
217 * 0 if Uuid1 and Uuid2 are equal
218 * 1 if Uuid1 is greater than Uuid2
220 int WINAPI UuidCompare(UUID *Uuid1, UUID *Uuid2, RPC_STATUS *Status)
222 TRACE("(%s,%s)\n", debugstr_guid(Uuid1), debugstr_guid(Uuid2));
223 *Status = RPC_S_OK;
224 if (!Uuid1) Uuid1 = &uuid_nil;
225 if (!Uuid2) Uuid2 = &uuid_nil;
226 if (Uuid1 == Uuid2) return 0;
227 return memcmp(Uuid1, Uuid2, sizeof(UUID));
230 /*************************************************************************
231 * UuidEqual [RPCRT4.@]
233 * PARAMS
234 * UUID *Uuid1 [I] Uuid to compare
235 * UUID *Uuid2 [I] Uuid to compare
236 * RPC_STATUS *Status [O] returns RPC_S_OK
238 * RETURNS
239 * TRUE/FALSE
241 int WINAPI UuidEqual(UUID *Uuid1, UUID *Uuid2, RPC_STATUS *Status)
243 TRACE("(%s,%s)\n", debugstr_guid(Uuid1), debugstr_guid(Uuid2));
244 return !UuidCompare(Uuid1, Uuid2, Status);
247 /*************************************************************************
248 * UuidIsNil [RPCRT4.@]
250 * PARAMS
251 * UUID *Uuid [I] Uuid to compare
252 * RPC_STATUS *Status [O] retuns RPC_S_OK
254 * RETURNS
255 * TRUE/FALSE
257 int WINAPI UuidIsNil(UUID *uuid, RPC_STATUS *Status)
259 TRACE("(%s)\n", debugstr_guid(uuid));
260 *Status = RPC_S_OK;
261 if (!uuid) return TRUE;
262 return !memcmp(uuid, &uuid_nil, sizeof(UUID));
265 /*************************************************************************
266 * UuidCreateNil [RPCRT4.@]
268 * PARAMS
269 * UUID *Uuid [O] returns a nil UUID
271 * RETURNS
272 * RPC_S_OK
274 RPC_STATUS WINAPI UuidCreateNil(UUID *Uuid)
276 *Uuid = uuid_nil;
277 return RPC_S_OK;
280 /*************************************************************************
281 * UuidCreate [RPCRT4.@]
283 * Creates a 128bit UUID.
284 * Implemented according the DCE specification for UUID generation.
285 * Code is based upon uuid library in e2fsprogs by Theodore Ts'o.
286 * Copyright (C) 1996, 1997 Theodore Ts'o.
288 * RETURNS
290 * S_OK if successful.
292 RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
294 static char has_init = 0;
295 static unsigned char a[6];
296 static int adjustment = 0;
297 static struct timeval last = {0, 0};
298 static WORD clock_seq;
299 struct timeval tv;
300 unsigned long long clock_reg;
301 DWORD clock_high, clock_low;
302 WORD temp_clock_seq, temp_clock_mid, temp_clock_hi_and_version;
303 #ifdef HAVE_NET_IF_H
304 int sd;
305 struct ifreq ifr, *ifrp;
306 struct ifconf ifc;
307 char buf[1024];
308 int n, i;
309 #endif
311 /* Have we already tried to get the MAC address? */
312 if (!has_init) {
313 #ifdef HAVE_NET_IF_H
314 /* BSD 4.4 defines the size of an ifreq to be
315 * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
316 * However, under earlier systems, sa_len isn't present, so
317 * the size is just sizeof(struct ifreq)
319 #ifdef HAVE_SOCKADDR_SA_LEN
320 # ifndef max
321 # define max(a,b) ((a) > (b) ? (a) : (b))
322 # endif
323 # define ifreq_size(i) max(sizeof(struct ifreq),\
324 sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
325 # else
326 # define ifreq_size(i) sizeof(struct ifreq)
327 # endif /* defined(HAVE_SOCKADDR_SA_LEN) */
329 sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
330 if (sd < 0) {
331 /* if we can't open a socket, just use random numbers */
332 /* set the multicast bit to prevent conflicts with real cards */
333 a[0] = (rand() & 0xff) | 0x80;
334 a[1] = rand() & 0xff;
335 a[2] = rand() & 0xff;
336 a[3] = rand() & 0xff;
337 a[4] = rand() & 0xff;
338 a[5] = rand() & 0xff;
339 } else {
340 memset(buf, 0, sizeof(buf));
341 ifc.ifc_len = sizeof(buf);
342 ifc.ifc_buf = buf;
343 /* get the ifconf interface */
344 if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) {
345 close(sd);
346 /* no ifconf, so just use random numbers */
347 /* set the multicast bit to prevent conflicts with real cards */
348 a[0] = (rand() & 0xff) | 0x80;
349 a[1] = rand() & 0xff;
350 a[2] = rand() & 0xff;
351 a[3] = rand() & 0xff;
352 a[4] = rand() & 0xff;
353 a[5] = rand() & 0xff;
354 } else {
355 /* loop through the interfaces, looking for a valid one */
356 n = ifc.ifc_len;
357 for (i = 0; i < n; i+= ifreq_size(ifr) ) {
358 ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
359 strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
360 /* try to get the address for this interface */
361 # ifdef SIOCGIFHWADDR
362 if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
363 continue;
364 memcpy(a, (unsigned char *)&ifr.ifr_hwaddr.sa_data, 6);
365 # else
366 # ifdef SIOCGENADDR
367 if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
368 continue;
369 memcpy(a, (unsigned char *) ifr.ifr_enaddr, 6);
370 # else
371 /* XXX we don't have a way of getting the hardware address */
372 close(sd);
373 a[0] = 0;
374 break;
375 # endif /* SIOCGENADDR */
376 # endif /* SIOCGIFHWADDR */
377 /* make sure it's not blank */
378 if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
379 continue;
381 goto valid_address;
383 /* if we didn't find a valid address, make a random one */
384 /* once again, set multicast bit to avoid conflicts */
385 a[0] = (rand() & 0xff) | 0x80;
386 a[1] = rand() & 0xff;
387 a[2] = rand() & 0xff;
388 a[3] = rand() & 0xff;
389 a[4] = rand() & 0xff;
390 a[5] = rand() & 0xff;
392 valid_address:
393 close(sd);
396 #else
397 /* no networking info, so generate a random address */
398 a[0] = (rand() & 0xff) | 0x80;
399 a[1] = rand() & 0xff;
400 a[2] = rand() & 0xff;
401 a[3] = rand() & 0xff;
402 a[4] = rand() & 0xff;
403 a[5] = rand() & 0xff;
404 #endif /* HAVE_NET_IF_H */
405 has_init = 1;
408 /* generate time element of GUID */
410 /* Assume that the gettimeofday() has microsecond granularity */
411 #define MAX_ADJUSTMENT 10
413 try_again:
414 gettimeofday(&tv, 0);
415 if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
416 clock_seq = ((rand() & 0xff) << 8) + (rand() & 0xff);
417 clock_seq &= 0x1FFF;
418 last = tv;
419 last.tv_sec--;
421 if ((tv.tv_sec < last.tv_sec) ||
422 ((tv.tv_sec == last.tv_sec) &&
423 (tv.tv_usec < last.tv_usec))) {
424 clock_seq = (clock_seq+1) & 0x1FFF;
425 adjustment = 0;
426 } else if ((tv.tv_sec == last.tv_sec) &&
427 (tv.tv_usec == last.tv_usec)) {
428 if (adjustment >= MAX_ADJUSTMENT)
429 goto try_again;
430 adjustment++;
431 } else
432 adjustment = 0;
434 clock_reg = tv.tv_usec*10 + adjustment;
435 clock_reg += ((unsigned long long) tv.tv_sec)*10000000;
436 clock_reg += (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000;
438 clock_high = clock_reg >> 32;
439 clock_low = clock_reg;
440 temp_clock_seq = clock_seq | 0x8000;
441 temp_clock_mid = (WORD)clock_high;
442 temp_clock_hi_and_version = (clock_high >> 16) | 0x1000;
444 /* pack the information into the GUID structure */
446 ((unsigned char*)&Uuid->Data1)[3] = (unsigned char)clock_low;
447 clock_low >>= 8;
448 ((unsigned char*)&Uuid->Data1)[2] = (unsigned char)clock_low;
449 clock_low >>= 8;
450 ((unsigned char*)&Uuid->Data1)[1] = (unsigned char)clock_low;
451 clock_low >>= 8;
452 ((unsigned char*)&Uuid->Data1)[0] = (unsigned char)clock_low;
454 ((unsigned char*)&Uuid->Data2)[1] = (unsigned char)temp_clock_mid;
455 temp_clock_mid >>= 8;
456 ((unsigned char*)&Uuid->Data2)[0] = (unsigned char)temp_clock_mid;
458 ((unsigned char*)&Uuid->Data3)[1] = (unsigned char)temp_clock_hi_and_version;
459 temp_clock_hi_and_version >>= 8;
460 ((unsigned char*)&Uuid->Data3)[0] = (unsigned char)temp_clock_hi_and_version;
462 ((unsigned char*)Uuid->Data4)[1] = (unsigned char)temp_clock_seq;
463 temp_clock_seq >>= 8;
464 ((unsigned char*)Uuid->Data4)[0] = (unsigned char)temp_clock_seq;
466 ((unsigned char*)Uuid->Data4)[2] = a[0];
467 ((unsigned char*)Uuid->Data4)[3] = a[1];
468 ((unsigned char*)Uuid->Data4)[4] = a[2];
469 ((unsigned char*)Uuid->Data4)[5] = a[3];
470 ((unsigned char*)Uuid->Data4)[6] = a[4];
471 ((unsigned char*)Uuid->Data4)[7] = a[5];
473 TRACE("%s\n", debugstr_guid(Uuid));
475 return RPC_S_OK;
479 /*************************************************************************
480 * UuidCreateSequential [RPCRT4.@]
482 * Creates a 128bit UUID by calling UuidCreate.
483 * New API in Win 2000
485 RPC_STATUS WINAPI UuidCreateSequential(UUID *Uuid)
487 return UuidCreate (Uuid);
491 /*************************************************************************
492 * UuidHash [RPCRT4.@]
494 * Generates a hash value for a given UUID
496 * Code based on FreeDCE implementation
499 unsigned short WINAPI UuidHash(UUID *uuid, RPC_STATUS *Status)
501 BYTE *data = (BYTE*)uuid;
502 short c0 = 0, c1 = 0, x, y;
503 int i;
505 TRACE("(%s)\n", debugstr_guid(uuid));
507 for (i=0; i<sizeof(UUID); i++) {
508 c0 += data[i];
509 c1 += c0;
512 x = -c1 % 255;
513 if (x < 0) x += 255;
515 y = (c1 - c0) % 255;
516 if (y < 0) y += 255;
518 *Status = RPC_S_OK;
519 return y*256 + x;
522 /*************************************************************************
523 * UuidToStringA [RPCRT4.@]
525 * Converts a UUID to a string.
527 * UUID format is 8 hex digits, followed by a hyphen then three groups of
528 * 4 hex digits each followed by a hyphen and then 12 hex digits
530 * RETURNS
532 * S_OK if successful.
533 * S_OUT_OF_MEMORY if unsucessful.
535 RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, LPSTR* StringUuid)
537 *StringUuid = HeapAlloc( GetProcessHeap(), 0, sizeof(char) * 37);
539 if(!(*StringUuid))
540 return RPC_S_OUT_OF_MEMORY;
542 sprintf(*StringUuid, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
543 Uuid->Data1, Uuid->Data2, Uuid->Data3,
544 Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2],
545 Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
546 Uuid->Data4[6], Uuid->Data4[7] );
548 return RPC_S_OK;
551 /*************************************************************************
552 * UuidToStringW [RPCRT4.@]
554 * Converts a UUID to a string.
556 * S_OK if successful.
557 * S_OUT_OF_MEMORY if unsucessful.
559 RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, LPWSTR* StringUuid)
561 char buf[37];
563 sprintf(buf, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
564 Uuid->Data1, Uuid->Data2, Uuid->Data3,
565 Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2],
566 Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
567 Uuid->Data4[6], Uuid->Data4[7] );
569 *StringUuid = RPCRT4_strdupAtoW(buf);
571 if(!(*StringUuid))
572 return RPC_S_OUT_OF_MEMORY;
574 return RPC_S_OK;
577 static const BYTE hex2bin[] =
579 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x00 */
580 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x10 */
581 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x20 */
582 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, /* 0x30 */
583 0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, /* 0x40 */
584 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x50 */
585 0,10,11,12,13,14,15 /* 0x60 */
588 /***********************************************************************
589 * UuidFromStringA (RPCRT4.@)
591 RPC_STATUS WINAPI UuidFromStringA(LPSTR str, UUID *uuid)
593 BYTE *s = (BYTE *)str;
594 int i;
596 if (!s) return UuidCreateNil( uuid );
598 if (strlen(s) != 36) return RPC_S_INVALID_STRING_UUID;
600 if ((s[8]!='-') || (s[13]!='-') || (s[18]!='-') || (s[23]!='-'))
601 return RPC_S_INVALID_STRING_UUID;
603 for (i=0; i<36; i++)
605 if ((i == 8)||(i == 13)||(i == 18)||(i == 23)) continue;
606 if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0')) return RPC_S_INVALID_STRING_UUID;
609 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
611 uuid->Data1 = (hex2bin[s[0]] << 28 | hex2bin[s[1]] << 24 | hex2bin[s[2]] << 20 | hex2bin[s[3]] << 16 |
612 hex2bin[s[4]] << 12 | hex2bin[s[5]] << 8 | hex2bin[s[6]] << 4 | hex2bin[s[7]]);
613 uuid->Data2 = hex2bin[s[9]] << 12 | hex2bin[s[10]] << 8 | hex2bin[s[11]] << 4 | hex2bin[s[12]];
614 uuid->Data3 = hex2bin[s[14]] << 12 | hex2bin[s[15]] << 8 | hex2bin[s[16]] << 4 | hex2bin[s[17]];
616 /* these are just sequential bytes */
617 uuid->Data4[0] = hex2bin[s[19]] << 4 | hex2bin[s[20]];
618 uuid->Data4[1] = hex2bin[s[21]] << 4 | hex2bin[s[22]];
619 uuid->Data4[2] = hex2bin[s[24]] << 4 | hex2bin[s[25]];
620 uuid->Data4[3] = hex2bin[s[26]] << 4 | hex2bin[s[27]];
621 uuid->Data4[4] = hex2bin[s[28]] << 4 | hex2bin[s[29]];
622 uuid->Data4[5] = hex2bin[s[30]] << 4 | hex2bin[s[31]];
623 uuid->Data4[6] = hex2bin[s[32]] << 4 | hex2bin[s[33]];
624 uuid->Data4[7] = hex2bin[s[34]] << 4 | hex2bin[s[35]];
625 return RPC_S_OK;
629 /***********************************************************************
630 * UuidFromStringW (RPCRT4.@)
632 RPC_STATUS WINAPI UuidFromStringW(LPWSTR s, UUID *uuid)
634 int i;
636 if (!s) return UuidCreateNil( uuid );
638 if (strlenW(s) != 36) return RPC_S_INVALID_STRING_UUID;
640 if ((s[8]!='-') || (s[13]!='-') || (s[18]!='-') || (s[23]!='-'))
641 return RPC_S_INVALID_STRING_UUID;
643 for (i=0; i<36; i++)
645 if ((i == 8)||(i == 13)||(i == 18)||(i == 23)) continue;
646 if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0')) return RPC_S_INVALID_STRING_UUID;
649 /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
651 uuid->Data1 = (hex2bin[s[0]] << 28 | hex2bin[s[1]] << 24 | hex2bin[s[2]] << 20 | hex2bin[s[3]] << 16 |
652 hex2bin[s[4]] << 12 | hex2bin[s[5]] << 8 | hex2bin[s[6]] << 4 | hex2bin[s[7]]);
653 uuid->Data2 = hex2bin[s[9]] << 12 | hex2bin[s[10]] << 8 | hex2bin[s[11]] << 4 | hex2bin[s[12]];
654 uuid->Data3 = hex2bin[s[14]] << 12 | hex2bin[s[15]] << 8 | hex2bin[s[16]] << 4 | hex2bin[s[17]];
656 /* these are just sequential bytes */
657 uuid->Data4[0] = hex2bin[s[19]] << 4 | hex2bin[s[20]];
658 uuid->Data4[1] = hex2bin[s[21]] << 4 | hex2bin[s[22]];
659 uuid->Data4[2] = hex2bin[s[24]] << 4 | hex2bin[s[25]];
660 uuid->Data4[3] = hex2bin[s[26]] << 4 | hex2bin[s[27]];
661 uuid->Data4[4] = hex2bin[s[28]] << 4 | hex2bin[s[29]];
662 uuid->Data4[5] = hex2bin[s[30]] << 4 | hex2bin[s[31]];
663 uuid->Data4[6] = hex2bin[s[32]] << 4 | hex2bin[s[33]];
664 uuid->Data4[7] = hex2bin[s[34]] << 4 | hex2bin[s[35]];
665 return RPC_S_OK;
668 /***********************************************************************
669 * DllRegisterServer (RPCRT4.@)
672 HRESULT WINAPI RPCRT4_DllRegisterServer( void )
674 FIXME( "(): stub\n" );
675 return S_OK;