/*
* RPCRT4
*
+ * Copyright 2000 Huw D M Davies for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ * WINE RPC TODO's (and a few TODONT's)
+ *
+ * - Statistics: we are supposed to be keeping various counters. we aren't.
+ *
+ * - Async RPC: Unimplemented.
+ *
+ * - The NT "ports" API, aka LPC. Greg claims this is on his radar. Might (or
+ * might not) enable users to get some kind of meaningful result out of
+ * NT-based native rpcrt4's. Commonly-used transport for self-to-self RPC's.
*/
#include "config.h"
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "windef.h"
-#include "wine/windef16.h"
#include "winerror.h"
#include "winbase.h"
+#include "winuser.h"
+#include "winnt.h"
+#include "winternl.h"
+#include "ntsecapi.h"
+#include "wine/unicode.h"
#include "rpc.h"
-#ifdef HAVE_SYS_FILE_H
-# include <sys/file.h>
-#endif
-#include <sys/ioctl.h>
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#ifdef HAVE_SYS_SOCKIO_H
-# include <sys/sockio.h>
-#endif
-#ifdef HAVE_NET_IF_H
-# include <net/if.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-
-#include "debugtools.h"
-
-DEFAULT_DEBUG_CHANNEL(ole);
+#include "ole2.h"
+#include "rpcndr.h"
+#include "rpcproxy.h"
+
+#include "rpc_binding.h"
+#include "rpc_server.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(rpc);
+
+static UUID uuid_nil;
+
+static CRITICAL_SECTION threaddata_cs;
+static CRITICAL_SECTION_DEBUG threaddata_cs_debug =
+{
+ 0, 0, &threaddata_cs,
+ { &threaddata_cs_debug.ProcessLocksList, &threaddata_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": threaddata_cs") }
+};
+static CRITICAL_SECTION threaddata_cs = { &threaddata_cs_debug, -1, 0, 0, 0, 0 };
+
+static struct list threaddata_list = LIST_INIT(threaddata_list);
+
+struct context_handle_list
+{
+ struct context_handle_list *next;
+ NDR_SCONTEXT context_handle;
+};
+
+struct threaddata
+{
+ struct list entry;
+ CRITICAL_SECTION cs;
+ DWORD thread_id;
+ RpcConnection *connection;
+ RpcBinding *server_binding;
+ struct context_handle_list *context_handle_list;
+};
/***********************************************************************
- * RPCRT4_LibMain
+ * DllMain
*
* PARAMS
* hinstDLL [I] handle to the DLL's instance
* Failure: FALSE
*/
-BOOL WINAPI
-RPCRT4_LibMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
+ struct threaddata *tdata;
+
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
- break;
+ break;
+
+ case DLL_THREAD_DETACH:
+ tdata = NtCurrentTeb()->ReservedForNtRpc;
+ if (tdata)
+ {
+ EnterCriticalSection(&threaddata_cs);
+ list_remove(&tdata->entry);
+ LeaveCriticalSection(&threaddata_cs);
+
+ DeleteCriticalSection(&tdata->cs);
+ if (tdata->connection)
+ ERR("tdata->connection should be NULL but is still set to %p\n", tdata->connection);
+ if (tdata->server_binding)
+ ERR("tdata->server_binding should be NULL but is still set to %p\n", tdata->server_binding);
+ HeapFree(GetProcessHeap(), 0, tdata);
+ }
+ break;
case DLL_PROCESS_DETACH:
- break;
+ RPCRT4_destroy_all_protseqs();
+ break;
}
return TRUE;
}
/*************************************************************************
- * UuidCreate [RPCRT4.@]
+ * RpcStringFreeA [RPCRT4.@]
*
- * Creates a 128bit UUID.
- * Implemented according the DCE specification for UUID generation.
- * Code is based upon uuid library in e2fsprogs by Theodore Ts'o.
- * Copyright (C) 1996, 1997 Theodore Ts'o.
+ * Frees a character string allocated by the RPC run-time library.
*
* RETURNS
*
* S_OK if successful.
*/
-RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
+RPC_STATUS WINAPI RpcStringFreeA(RPC_CSTR* String)
{
- static char has_init = 0;
- unsigned char a[6];
- static int adjustment = 0;
- static struct timeval last = {0, 0};
- static UINT16 clock_seq;
- struct timeval tv;
- unsigned long long clock_reg;
- UINT clock_high, clock_low;
- UINT16 temp_clock_seq, temp_clock_mid, temp_clock_hi_and_version;
-#ifdef HAVE_NET_IF_H
- int sd;
- struct ifreq ifr, *ifrp;
- struct ifconf ifc;
- char buf[1024];
- int n, i;
-#endif
-
- /* Have we already tried to get the MAC address? */
- if (!has_init) {
-#ifdef HAVE_NET_IF_H
- /* BSD 4.4 defines the size of an ifreq to be
- * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
- * However, under earlier systems, sa_len isn't present, so
- * the size is just sizeof(struct ifreq)
- */
-#ifdef HAVE_SOCKADDR_SA_LEN
-# ifndef max
-# define max(a,b) ((a) > (b) ? (a) : (b))
-# endif
-# define ifreq_size(i) max(sizeof(struct ifreq),\
-sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
-# else
-# define ifreq_size(i) sizeof(struct ifreq)
-# endif /* defined(HAVE_SOCKADDR_SA_LEN) */
-
- sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
- if (sd < 0) {
- /* if we can't open a socket, just use random numbers */
- /* set the multicast bit to prevent conflicts with real cards */
- a[0] = (rand() & 0xff) | 0x80;
- a[1] = rand() & 0xff;
- a[2] = rand() & 0xff;
- a[3] = rand() & 0xff;
- a[4] = rand() & 0xff;
- a[5] = rand() & 0xff;
- } else {
- memset(buf, 0, sizeof(buf));
- ifc.ifc_len = sizeof(buf);
- ifc.ifc_buf = buf;
- /* get the ifconf interface */
- if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) {
- close(sd);
- /* no ifconf, so just use random numbers */
- /* set the multicast bit to prevent conflicts with real cards */
- a[0] = (rand() & 0xff) | 0x80;
- a[1] = rand() & 0xff;
- a[2] = rand() & 0xff;
- a[3] = rand() & 0xff;
- a[4] = rand() & 0xff;
- a[5] = rand() & 0xff;
- } else {
- /* loop through the interfaces, looking for a valid one */
- n = ifc.ifc_len;
- for (i = 0; i < n; i+= ifreq_size(ifr) ) {
- ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
- strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
- /* try to get the address for this interface */
-# ifdef SIOCGIFHWADDR
- if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
- continue;
- memcpy(a, (unsigned char *)&ifr.ifr_hwaddr.sa_data, 6);
-# else
-# ifdef SIOCGENADDR
- if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
- continue;
- memcpy(a, (unsigned char *) ifr.ifr_enaddr, 6);
-# else
- /* XXX we don't have a way of getting the hardware address */
- close(sd);
- a[0] = 0;
- break;
-# endif /* SIOCGENADDR */
-# endif /* SIOCGIFHWADDR */
- /* make sure it's not blank */
- if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
- continue;
-
- goto valid_address;
- }
- /* if we didn't find a valid address, make a random one */
- /* once again, set multicast bit to avoid conflicts */
- a[0] = (rand() & 0xff) | 0x80;
- a[1] = rand() & 0xff;
- a[2] = rand() & 0xff;
- a[3] = rand() & 0xff;
- a[4] = rand() & 0xff;
- a[5] = rand() & 0xff;
-
- valid_address:
- close(sd);
- }
- }
-#else
- /* no networking info, so generate a random address */
- a[0] = (rand() & 0xff) | 0x80;
- a[1] = rand() & 0xff;
- a[2] = rand() & 0xff;
- a[3] = rand() & 0xff;
- a[4] = rand() & 0xff;
- a[5] = rand() & 0xff;
-#endif /* HAVE_NET_IF_H */
- has_init = 1;
- }
-
- /* generate time element of GUID */
-
- /* Assume that the gettimeofday() has microsecond granularity */
-#define MAX_ADJUSTMENT 10
-
- try_again:
- gettimeofday(&tv, 0);
- if ((last.tv_sec == 0) && (last.tv_usec == 0)) {
- clock_seq = ((rand() & 0xff) << 8) + (rand() & 0xff);
- clock_seq &= 0x1FFF;
- last = tv;
- last.tv_sec--;
- }
- if ((tv.tv_sec < last.tv_sec) ||
- ((tv.tv_sec == last.tv_sec) &&
- (tv.tv_usec < last.tv_usec))) {
- clock_seq = (clock_seq+1) & 0x1FFF;
- adjustment = 0;
- } else if ((tv.tv_sec == last.tv_sec) &&
- (tv.tv_usec == last.tv_usec)) {
- if (adjustment >= MAX_ADJUSTMENT)
- goto try_again;
- adjustment++;
- } else
- adjustment = 0;
-
- clock_reg = tv.tv_usec*10 + adjustment;
- clock_reg += ((unsigned long long) tv.tv_sec)*10000000;
- clock_reg += (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000;
-
- clock_high = clock_reg >> 32;
- clock_low = clock_reg;
- temp_clock_seq = clock_seq | 0x8000;
- temp_clock_mid = (UINT16)clock_high;
- temp_clock_hi_and_version = (clock_high >> 16) | 0x1000;
-
- /* pack the information into the GUID structure */
-
- ((unsigned char*)&Uuid->Data1)[3] = (unsigned char)clock_low;
- clock_low >>= 8;
- ((unsigned char*)&Uuid->Data1)[2] = (unsigned char)clock_low;
- clock_low >>= 8;
- ((unsigned char*)&Uuid->Data1)[1] = (unsigned char)clock_low;
- clock_low >>= 8;
- ((unsigned char*)&Uuid->Data1)[0] = (unsigned char)clock_low;
-
- ((unsigned char*)&Uuid->Data2)[1] = (unsigned char)temp_clock_mid;
- temp_clock_mid >>= 8;
- ((unsigned char*)&Uuid->Data2)[0] = (unsigned char)temp_clock_mid;
-
- ((unsigned char*)&Uuid->Data3)[1] = (unsigned char)temp_clock_hi_and_version;
- temp_clock_hi_and_version >>= 8;
- ((unsigned char*)&Uuid->Data3)[0] = (unsigned char)temp_clock_hi_and_version;
-
- ((unsigned char*)Uuid->Data4)[1] = (unsigned char)temp_clock_seq;
- temp_clock_seq >>= 8;
- ((unsigned char*)Uuid->Data4)[0] = (unsigned char)temp_clock_seq;
-
- ((unsigned char*)Uuid->Data4)[2] = a[0];
- ((unsigned char*)Uuid->Data4)[3] = a[1];
- ((unsigned char*)Uuid->Data4)[4] = a[2];
- ((unsigned char*)Uuid->Data4)[5] = a[3];
- ((unsigned char*)Uuid->Data4)[6] = a[4];
- ((unsigned char*)Uuid->Data4)[7] = a[5];
-
- TRACE("%s\n", debugstr_guid(Uuid));
-
- return S_OK;
+ HeapFree( GetProcessHeap(), 0, *String);
+
+ return RPC_S_OK;
}
/*************************************************************************
- * RpcStringFreeA [RPCRT4.@]
+ * RpcStringFreeW [RPCRT4.@]
*
* Frees a character string allocated by the RPC run-time library.
*
*
* S_OK if successful.
*/
-RPC_STATUS WINAPI RpcStringFreeA(unsigned char** String)
+RPC_STATUS WINAPI RpcStringFreeW(RPC_WSTR* String)
{
HeapFree( GetProcessHeap(), 0, *String);
- return S_OK;
+ return RPC_S_OK;
+}
+
+/*************************************************************************
+ * RpcRaiseException [RPCRT4.@]
+ *
+ * Raises an exception.
+ */
+void DECLSPEC_NORETURN WINAPI RpcRaiseException(RPC_STATUS exception)
+{
+ /* shouldn't return */
+ RaiseException(exception, 0, 0, NULL);
+ ERR("handler continued execution\n");
+ ExitProcess(1);
+}
+
+/*************************************************************************
+ * UuidCompare [RPCRT4.@]
+ *
+ * PARAMS
+ * UUID *Uuid1 [I] Uuid to compare
+ * UUID *Uuid2 [I] Uuid to compare
+ * RPC_STATUS *Status [O] returns RPC_S_OK
+ *
+ * RETURNS
+ * -1 if Uuid1 is less than Uuid2
+ * 0 if Uuid1 and Uuid2 are equal
+ * 1 if Uuid1 is greater than Uuid2
+ */
+int WINAPI UuidCompare(UUID *Uuid1, UUID *Uuid2, RPC_STATUS *Status)
+{
+ int i;
+
+ TRACE("(%s,%s)\n", debugstr_guid(Uuid1), debugstr_guid(Uuid2));
+
+ *Status = RPC_S_OK;
+
+ if (!Uuid1) Uuid1 = &uuid_nil;
+ if (!Uuid2) Uuid2 = &uuid_nil;
+
+ if (Uuid1 == Uuid2) return 0;
+
+ if (Uuid1->Data1 != Uuid2->Data1)
+ return Uuid1->Data1 < Uuid2->Data1 ? -1 : 1;
+
+ if (Uuid1->Data2 != Uuid2->Data2)
+ return Uuid1->Data2 < Uuid2->Data2 ? -1 : 1;
+
+ if (Uuid1->Data3 != Uuid2->Data3)
+ return Uuid1->Data3 < Uuid2->Data3 ? -1 : 1;
+
+ for (i = 0; i < 8; i++) {
+ if (Uuid1->Data4[i] < Uuid2->Data4[i])
+ return -1;
+ if (Uuid1->Data4[i] > Uuid2->Data4[i])
+ return 1;
+ }
+
+ return 0;
+}
+
+/*************************************************************************
+ * UuidEqual [RPCRT4.@]
+ *
+ * PARAMS
+ * UUID *Uuid1 [I] Uuid to compare
+ * UUID *Uuid2 [I] Uuid to compare
+ * RPC_STATUS *Status [O] returns RPC_S_OK
+ *
+ * RETURNS
+ * TRUE/FALSE
+ */
+int WINAPI UuidEqual(UUID *Uuid1, UUID *Uuid2, RPC_STATUS *Status)
+{
+ TRACE("(%s,%s)\n", debugstr_guid(Uuid1), debugstr_guid(Uuid2));
+ return !UuidCompare(Uuid1, Uuid2, Status);
+}
+
+/*************************************************************************
+ * UuidIsNil [RPCRT4.@]
+ *
+ * PARAMS
+ * UUID *Uuid [I] Uuid to compare
+ * RPC_STATUS *Status [O] returns RPC_S_OK
+ *
+ * RETURNS
+ * TRUE/FALSE
+ */
+int WINAPI UuidIsNil(UUID *Uuid, RPC_STATUS *Status)
+{
+ TRACE("(%s)\n", debugstr_guid(Uuid));
+ if (!Uuid) return TRUE;
+ return !UuidCompare(Uuid, &uuid_nil, Status);
+}
+
+ /*************************************************************************
+ * UuidCreateNil [RPCRT4.@]
+ *
+ * PARAMS
+ * UUID *Uuid [O] returns a nil UUID
+ *
+ * RETURNS
+ * RPC_S_OK
+ */
+RPC_STATUS WINAPI UuidCreateNil(UUID *Uuid)
+{
+ *Uuid = uuid_nil;
+ return RPC_S_OK;
+}
+
+/*************************************************************************
+ * UuidCreate [RPCRT4.@]
+ *
+ * Creates a 128bit UUID.
+ *
+ * RETURNS
+ *
+ * RPC_S_OK if successful.
+ * RPC_S_UUID_LOCAL_ONLY if UUID is only locally unique.
+ *
+ * NOTES
+ *
+ * Follows RFC 4122, section 4.4 (Algorithms for Creating a UUID from
+ * Truly Random or Pseudo-Random Numbers)
+ */
+RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
+{
+ RtlGenRandom(Uuid, sizeof(*Uuid));
+ /* Clear the version bits and set the version (4) */
+ Uuid->Data3 &= 0x0fff;
+ Uuid->Data3 |= (4 << 12);
+ /* Set the topmost bits of Data4 (clock_seq_hi_and_reserved) as
+ * specified in RFC 4122, section 4.4.
+ */
+ Uuid->Data4[0] &= 0x3f;
+ Uuid->Data4[0] |= 0x80;
+
+ TRACE("%s\n", debugstr_guid(Uuid));
+
+ return RPC_S_OK;
+}
+
+/*************************************************************************
+ * UuidCreateSequential [RPCRT4.@]
+ *
+ * Creates a 128bit UUID.
+ *
+ * RETURNS
+ *
+ * RPC_S_OK if successful.
+ * RPC_S_UUID_LOCAL_ONLY if UUID is only locally unique.
+ *
+ */
+RPC_STATUS WINAPI UuidCreateSequential(UUID *Uuid)
+{
+ return UuidCreate(Uuid);
+}
+
+
+/*************************************************************************
+ * UuidHash [RPCRT4.@]
+ *
+ * Generates a hash value for a given UUID
+ *
+ * Code based on FreeDCE implementation
+ *
+ */
+unsigned short WINAPI UuidHash(UUID *uuid, RPC_STATUS *Status)
+{
+ BYTE *data = (BYTE*)uuid;
+ short c0 = 0, c1 = 0, x, y;
+ unsigned int i;
+
+ if (!uuid) data = (BYTE*)(uuid = &uuid_nil);
+
+ TRACE("(%s)\n", debugstr_guid(uuid));
+
+ for (i=0; i<sizeof(UUID); i++) {
+ c0 += data[i];
+ c1 += c0;
+ }
+
+ x = -c1 % 255;
+ if (x < 0) x += 255;
+
+ y = (c1 - c0) % 255;
+ if (y < 0) y += 255;
+
+ *Status = RPC_S_OK;
+ return y*256 + x;
}
/*************************************************************************
* RETURNS
*
* S_OK if successful.
- * S_OUT_OF_MEMORY if unsucessful.
+ * S_OUT_OF_MEMORY if unsuccessful.
*/
-RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, unsigned char** StringUuid)
+RPC_STATUS WINAPI UuidToStringA(UUID *Uuid, RPC_CSTR* StringUuid)
{
*StringUuid = HeapAlloc( GetProcessHeap(), 0, sizeof(char) * 37);
-
- /* FIXME: this should be RPC_S_OUT_OF_MEMORY */
if(!(*StringUuid))
- return ERROR_OUTOFMEMORY;
+ return RPC_S_OUT_OF_MEMORY;
- sprintf(*StringUuid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ if (!Uuid) Uuid = &uuid_nil;
+
+ sprintf( (char*)*StringUuid, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
Uuid->Data1, Uuid->Data2, Uuid->Data3,
Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2],
Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
Uuid->Data4[6], Uuid->Data4[7] );
- return S_OK; /*FIXME: this should be RPC_S_OK */
+ return RPC_S_OK;
+}
+
+/*************************************************************************
+ * UuidToStringW [RPCRT4.@]
+ *
+ * Converts a UUID to a string.
+ *
+ * S_OK if successful.
+ * S_OUT_OF_MEMORY if unsuccessful.
+ */
+RPC_STATUS WINAPI UuidToStringW(UUID *Uuid, RPC_WSTR* StringUuid)
+{
+ char buf[37];
+
+ if (!Uuid) Uuid = &uuid_nil;
+
+ sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ Uuid->Data1, Uuid->Data2, Uuid->Data3,
+ Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2],
+ Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
+ Uuid->Data4[6], Uuid->Data4[7] );
+
+ *StringUuid = RPCRT4_strdupAtoW(buf);
+
+ if(!(*StringUuid))
+ return RPC_S_OUT_OF_MEMORY;
+
+ return RPC_S_OK;
+}
+
+static const BYTE hex2bin[] =
+{
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x00 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x10 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x20 */
+ 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, /* 0x30 */
+ 0,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0, /* 0x40 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x50 */
+ 0,10,11,12,13,14,15 /* 0x60 */
+};
+
+/***********************************************************************
+ * UuidFromStringA (RPCRT4.@)
+ */
+RPC_STATUS WINAPI UuidFromStringA(RPC_CSTR s, UUID *uuid)
+{
+ int i;
+
+ if (!s) return UuidCreateNil( uuid );
+
+ if (strlen((char*)s) != 36) return RPC_S_INVALID_STRING_UUID;
+
+ if ((s[8]!='-') || (s[13]!='-') || (s[18]!='-') || (s[23]!='-'))
+ return RPC_S_INVALID_STRING_UUID;
+
+ for (i=0; i<36; i++)
+ {
+ if ((i == 8)||(i == 13)||(i == 18)||(i == 23)) continue;
+ if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0')) return RPC_S_INVALID_STRING_UUID;
+ }
+
+ /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
+
+ uuid->Data1 = (hex2bin[s[0]] << 28 | hex2bin[s[1]] << 24 | hex2bin[s[2]] << 20 | hex2bin[s[3]] << 16 |
+ hex2bin[s[4]] << 12 | hex2bin[s[5]] << 8 | hex2bin[s[6]] << 4 | hex2bin[s[7]]);
+ uuid->Data2 = hex2bin[s[9]] << 12 | hex2bin[s[10]] << 8 | hex2bin[s[11]] << 4 | hex2bin[s[12]];
+ uuid->Data3 = hex2bin[s[14]] << 12 | hex2bin[s[15]] << 8 | hex2bin[s[16]] << 4 | hex2bin[s[17]];
+
+ /* these are just sequential bytes */
+ uuid->Data4[0] = hex2bin[s[19]] << 4 | hex2bin[s[20]];
+ uuid->Data4[1] = hex2bin[s[21]] << 4 | hex2bin[s[22]];
+ uuid->Data4[2] = hex2bin[s[24]] << 4 | hex2bin[s[25]];
+ uuid->Data4[3] = hex2bin[s[26]] << 4 | hex2bin[s[27]];
+ uuid->Data4[4] = hex2bin[s[28]] << 4 | hex2bin[s[29]];
+ uuid->Data4[5] = hex2bin[s[30]] << 4 | hex2bin[s[31]];
+ uuid->Data4[6] = hex2bin[s[32]] << 4 | hex2bin[s[33]];
+ uuid->Data4[7] = hex2bin[s[34]] << 4 | hex2bin[s[35]];
+ return RPC_S_OK;
+}
+
+
+/***********************************************************************
+ * UuidFromStringW (RPCRT4.@)
+ */
+RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
+{
+ int i;
+
+ if (!s) return UuidCreateNil( uuid );
+
+ if (strlenW(s) != 36) return RPC_S_INVALID_STRING_UUID;
+
+ if ((s[8]!='-') || (s[13]!='-') || (s[18]!='-') || (s[23]!='-'))
+ return RPC_S_INVALID_STRING_UUID;
+
+ for (i=0; i<36; i++)
+ {
+ if ((i == 8)||(i == 13)||(i == 18)||(i == 23)) continue;
+ if (s[i] > 'f' || (!hex2bin[s[i]] && s[i] != '0')) return RPC_S_INVALID_STRING_UUID;
+ }
+
+ /* in form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX */
+
+ uuid->Data1 = (hex2bin[s[0]] << 28 | hex2bin[s[1]] << 24 | hex2bin[s[2]] << 20 | hex2bin[s[3]] << 16 |
+ hex2bin[s[4]] << 12 | hex2bin[s[5]] << 8 | hex2bin[s[6]] << 4 | hex2bin[s[7]]);
+ uuid->Data2 = hex2bin[s[9]] << 12 | hex2bin[s[10]] << 8 | hex2bin[s[11]] << 4 | hex2bin[s[12]];
+ uuid->Data3 = hex2bin[s[14]] << 12 | hex2bin[s[15]] << 8 | hex2bin[s[16]] << 4 | hex2bin[s[17]];
+
+ /* these are just sequential bytes */
+ uuid->Data4[0] = hex2bin[s[19]] << 4 | hex2bin[s[20]];
+ uuid->Data4[1] = hex2bin[s[21]] << 4 | hex2bin[s[22]];
+ uuid->Data4[2] = hex2bin[s[24]] << 4 | hex2bin[s[25]];
+ uuid->Data4[3] = hex2bin[s[26]] << 4 | hex2bin[s[27]];
+ uuid->Data4[4] = hex2bin[s[28]] << 4 | hex2bin[s[29]];
+ uuid->Data4[5] = hex2bin[s[30]] << 4 | hex2bin[s[31]];
+ uuid->Data4[6] = hex2bin[s[32]] << 4 | hex2bin[s[33]];
+ uuid->Data4[7] = hex2bin[s[34]] << 4 | hex2bin[s[35]];
+ return RPC_S_OK;
}
/***********************************************************************
- * NdrDllRegisterProxy (RPCRT4.@)
+ * DllRegisterServer (RPCRT4.@)
+ */
+
+HRESULT WINAPI DllRegisterServer( void )
+{
+ FIXME( "(): stub\n" );
+ return S_OK;
+}
+
+#define MAX_RPC_ERROR_TEXT 256
+
+/******************************************************************************
+ * DceErrorInqTextW (rpcrt4.@)
+ *
+ * Notes
+ * 1. On passing a NULL pointer the code does bomb out.
+ * 2. The size of the required buffer is not defined in the documentation.
+ * It appears to be 256.
+ * 3. The function is defined to return RPC_S_INVALID_ARG but I don't know
+ * of any value for which it does.
+ * 4. The MSDN documentation currently declares that the second argument is
+ * unsigned char *, even for the W version. I don't believe it.
+ */
+RPC_STATUS RPC_ENTRY DceErrorInqTextW (RPC_STATUS e, RPC_WSTR buffer)
+{
+ DWORD count;
+ count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, e, 0, buffer, MAX_RPC_ERROR_TEXT, NULL);
+ if (!count)
+ {
+ count = FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, RPC_S_NOT_RPC_ERROR, 0, buffer, MAX_RPC_ERROR_TEXT, NULL);
+ if (!count)
+ {
+ ERR ("Failed to translate error\n");
+ return RPC_S_INVALID_ARG;
+ }
+ }
+ return RPC_S_OK;
+}
+
+/******************************************************************************
+ * DceErrorInqTextA (rpcrt4.@)
+ */
+RPC_STATUS RPC_ENTRY DceErrorInqTextA (RPC_STATUS e, RPC_CSTR buffer)
+{
+ RPC_STATUS status;
+ WCHAR bufferW [MAX_RPC_ERROR_TEXT];
+ if ((status = DceErrorInqTextW (e, bufferW)) == RPC_S_OK)
+ {
+ if (!WideCharToMultiByte(CP_ACP, 0, bufferW, -1, (LPSTR)buffer, MAX_RPC_ERROR_TEXT,
+ NULL, NULL))
+ {
+ ERR ("Failed to translate error\n");
+ status = RPC_S_INVALID_ARG;
+ }
+ }
+ return status;
+}
+
+/******************************************************************************
+ * I_RpcAllocate (rpcrt4.@)
+ */
+void * WINAPI I_RpcAllocate(unsigned int Size)
+{
+ return HeapAlloc(GetProcessHeap(), 0, Size);
+}
+
+/******************************************************************************
+ * I_RpcFree (rpcrt4.@)
+ */
+void WINAPI I_RpcFree(void *Object)
+{
+ HeapFree(GetProcessHeap(), 0, Object);
+}
+
+/******************************************************************************
+ * I_RpcMapWin32Status (rpcrt4.@)
+ *
+ * Maps Win32 RPC error codes to NT statuses.
+ *
+ * PARAMS
+ * status [I] Win32 RPC error code.
+ *
+ * RETURNS
+ * Appropriate translation into an NT status code.
+ */
+LONG WINAPI I_RpcMapWin32Status(RPC_STATUS status)
+{
+ TRACE("(%d)\n", status);
+ switch (status)
+ {
+ case ERROR_ACCESS_DENIED: return STATUS_ACCESS_DENIED;
+ case ERROR_INVALID_HANDLE: return RPC_NT_SS_CONTEXT_MISMATCH;
+ case ERROR_OUTOFMEMORY: return STATUS_NO_MEMORY;
+ case ERROR_INVALID_PARAMETER: return STATUS_INVALID_PARAMETER;
+ case ERROR_INSUFFICIENT_BUFFER: return STATUS_BUFFER_TOO_SMALL;
+ case ERROR_MAX_THRDS_REACHED: return STATUS_NO_MEMORY;
+ case ERROR_NOACCESS: return STATUS_ACCESS_VIOLATION;
+ case ERROR_NOT_ENOUGH_SERVER_MEMORY: return STATUS_INSUFF_SERVER_RESOURCES;
+ case ERROR_WRONG_PASSWORD: return STATUS_WRONG_PASSWORD;
+ case ERROR_INVALID_LOGON_HOURS: return STATUS_INVALID_LOGON_HOURS;
+ case ERROR_PASSWORD_EXPIRED: return STATUS_PASSWORD_EXPIRED;
+ case ERROR_ACCOUNT_DISABLED: return STATUS_ACCOUNT_DISABLED;
+ case ERROR_INVALID_SECURITY_DESCR: return STATUS_INVALID_SECURITY_DESCR;
+ case RPC_S_INVALID_STRING_BINDING: return RPC_NT_INVALID_STRING_BINDING;
+ case RPC_S_WRONG_KIND_OF_BINDING: return RPC_NT_WRONG_KIND_OF_BINDING;
+ case RPC_S_INVALID_BINDING: return RPC_NT_INVALID_BINDING;
+ case RPC_S_PROTSEQ_NOT_SUPPORTED: return RPC_NT_PROTSEQ_NOT_SUPPORTED;
+ case RPC_S_INVALID_RPC_PROTSEQ: return RPC_NT_INVALID_RPC_PROTSEQ;
+ case RPC_S_INVALID_STRING_UUID: return RPC_NT_INVALID_STRING_UUID;
+ case RPC_S_INVALID_ENDPOINT_FORMAT: return RPC_NT_INVALID_ENDPOINT_FORMAT;
+ case RPC_S_INVALID_NET_ADDR: return RPC_NT_INVALID_NET_ADDR;
+ case RPC_S_NO_ENDPOINT_FOUND: return RPC_NT_NO_ENDPOINT_FOUND;
+ case RPC_S_INVALID_TIMEOUT: return RPC_NT_INVALID_TIMEOUT;
+ case RPC_S_OBJECT_NOT_FOUND: return RPC_NT_OBJECT_NOT_FOUND;
+ case RPC_S_ALREADY_REGISTERED: return RPC_NT_ALREADY_REGISTERED;
+ case RPC_S_TYPE_ALREADY_REGISTERED: return RPC_NT_TYPE_ALREADY_REGISTERED;
+ case RPC_S_ALREADY_LISTENING: return RPC_NT_ALREADY_LISTENING;
+ case RPC_S_NO_PROTSEQS_REGISTERED: return RPC_NT_NO_PROTSEQS_REGISTERED;
+ case RPC_S_NOT_LISTENING: return RPC_NT_NOT_LISTENING;
+ case RPC_S_UNKNOWN_MGR_TYPE: return RPC_NT_UNKNOWN_MGR_TYPE;
+ case RPC_S_UNKNOWN_IF: return RPC_NT_UNKNOWN_IF;
+ case RPC_S_NO_BINDINGS: return RPC_NT_NO_BINDINGS;
+ case RPC_S_NO_PROTSEQS: return RPC_NT_NO_PROTSEQS;
+ case RPC_S_CANT_CREATE_ENDPOINT: return RPC_NT_CANT_CREATE_ENDPOINT;
+ case RPC_S_OUT_OF_RESOURCES: return RPC_NT_OUT_OF_RESOURCES;
+ case RPC_S_SERVER_UNAVAILABLE: return RPC_NT_SERVER_UNAVAILABLE;
+ case RPC_S_SERVER_TOO_BUSY: return RPC_NT_SERVER_TOO_BUSY;
+ case RPC_S_INVALID_NETWORK_OPTIONS: return RPC_NT_INVALID_NETWORK_OPTIONS;
+ case RPC_S_NO_CALL_ACTIVE: return RPC_NT_NO_CALL_ACTIVE;
+ case RPC_S_CALL_FAILED: return RPC_NT_CALL_FAILED;
+ case RPC_S_CALL_FAILED_DNE: return RPC_NT_CALL_FAILED_DNE;
+ case RPC_S_PROTOCOL_ERROR: return RPC_NT_PROTOCOL_ERROR;
+ case RPC_S_UNSUPPORTED_TRANS_SYN: return RPC_NT_UNSUPPORTED_TRANS_SYN;
+ case RPC_S_UNSUPPORTED_TYPE: return RPC_NT_UNSUPPORTED_TYPE;
+ case RPC_S_INVALID_TAG: return RPC_NT_INVALID_TAG;
+ case RPC_S_INVALID_BOUND: return RPC_NT_INVALID_BOUND;
+ case RPC_S_NO_ENTRY_NAME: return RPC_NT_NO_ENTRY_NAME;
+ case RPC_S_INVALID_NAME_SYNTAX: return RPC_NT_INVALID_NAME_SYNTAX;
+ case RPC_S_UNSUPPORTED_NAME_SYNTAX: return RPC_NT_UNSUPPORTED_NAME_SYNTAX;
+ case RPC_S_UUID_NO_ADDRESS: return RPC_NT_UUID_NO_ADDRESS;
+ case RPC_S_DUPLICATE_ENDPOINT: return RPC_NT_DUPLICATE_ENDPOINT;
+ case RPC_S_UNKNOWN_AUTHN_TYPE: return RPC_NT_UNKNOWN_AUTHN_TYPE;
+ case RPC_S_MAX_CALLS_TOO_SMALL: return RPC_NT_MAX_CALLS_TOO_SMALL;
+ case RPC_S_STRING_TOO_LONG: return RPC_NT_STRING_TOO_LONG;
+ case RPC_S_PROTSEQ_NOT_FOUND: return RPC_NT_PROTSEQ_NOT_FOUND;
+ case RPC_S_PROCNUM_OUT_OF_RANGE: return RPC_NT_PROCNUM_OUT_OF_RANGE;
+ case RPC_S_BINDING_HAS_NO_AUTH: return RPC_NT_BINDING_HAS_NO_AUTH;
+ case RPC_S_UNKNOWN_AUTHN_SERVICE: return RPC_NT_UNKNOWN_AUTHN_SERVICE;
+ case RPC_S_UNKNOWN_AUTHN_LEVEL: return RPC_NT_UNKNOWN_AUTHN_LEVEL;
+ case RPC_S_INVALID_AUTH_IDENTITY: return RPC_NT_INVALID_AUTH_IDENTITY;
+ case RPC_S_UNKNOWN_AUTHZ_SERVICE: return RPC_NT_UNKNOWN_AUTHZ_SERVICE;
+ case EPT_S_INVALID_ENTRY: return EPT_NT_INVALID_ENTRY;
+ case EPT_S_CANT_PERFORM_OP: return EPT_NT_CANT_PERFORM_OP;
+ case EPT_S_NOT_REGISTERED: return EPT_NT_NOT_REGISTERED;
+ case EPT_S_CANT_CREATE: return EPT_NT_CANT_CREATE;
+ case RPC_S_NOTHING_TO_EXPORT: return RPC_NT_NOTHING_TO_EXPORT;
+ case RPC_S_INCOMPLETE_NAME: return RPC_NT_INCOMPLETE_NAME;
+ case RPC_S_INVALID_VERS_OPTION: return RPC_NT_INVALID_VERS_OPTION;
+ case RPC_S_NO_MORE_MEMBERS: return RPC_NT_NO_MORE_MEMBERS;
+ case RPC_S_NOT_ALL_OBJS_UNEXPORTED: return RPC_NT_NOT_ALL_OBJS_UNEXPORTED;
+ case RPC_S_INTERFACE_NOT_FOUND: return RPC_NT_INTERFACE_NOT_FOUND;
+ case RPC_S_ENTRY_ALREADY_EXISTS: return RPC_NT_ENTRY_ALREADY_EXISTS;
+ case RPC_S_ENTRY_NOT_FOUND: return RPC_NT_ENTRY_NOT_FOUND;
+ case RPC_S_NAME_SERVICE_UNAVAILABLE: return RPC_NT_NAME_SERVICE_UNAVAILABLE;
+ case RPC_S_INVALID_NAF_ID: return RPC_NT_INVALID_NAF_ID;
+ case RPC_S_CANNOT_SUPPORT: return RPC_NT_CANNOT_SUPPORT;
+ case RPC_S_NO_CONTEXT_AVAILABLE: return RPC_NT_NO_CONTEXT_AVAILABLE;
+ case RPC_S_INTERNAL_ERROR: return RPC_NT_INTERNAL_ERROR;
+ case RPC_S_ZERO_DIVIDE: return RPC_NT_ZERO_DIVIDE;
+ case RPC_S_ADDRESS_ERROR: return RPC_NT_ADDRESS_ERROR;
+ case RPC_S_FP_DIV_ZERO: return RPC_NT_FP_DIV_ZERO;
+ case RPC_S_FP_UNDERFLOW: return RPC_NT_FP_UNDERFLOW;
+ case RPC_S_FP_OVERFLOW: return RPC_NT_FP_OVERFLOW;
+ case RPC_S_CALL_IN_PROGRESS: return RPC_NT_CALL_IN_PROGRESS;
+ case RPC_S_NO_MORE_BINDINGS: return RPC_NT_NO_MORE_BINDINGS;
+ case RPC_S_CALL_CANCELLED: return RPC_NT_CALL_CANCELLED;
+ case RPC_S_INVALID_OBJECT: return RPC_NT_INVALID_OBJECT;
+ case RPC_S_INVALID_ASYNC_HANDLE: return RPC_NT_INVALID_ASYNC_HANDLE;
+ case RPC_S_INVALID_ASYNC_CALL: return RPC_NT_INVALID_ASYNC_CALL;
+ case RPC_S_GROUP_MEMBER_NOT_FOUND: return RPC_NT_GROUP_MEMBER_NOT_FOUND;
+ case RPC_X_NO_MORE_ENTRIES: return RPC_NT_NO_MORE_ENTRIES;
+ case RPC_X_SS_CHAR_TRANS_OPEN_FAIL: return RPC_NT_SS_CHAR_TRANS_OPEN_FAIL;
+ case RPC_X_SS_CHAR_TRANS_SHORT_FILE: return RPC_NT_SS_CHAR_TRANS_SHORT_FILE;
+ case RPC_X_SS_IN_NULL_CONTEXT: return RPC_NT_SS_IN_NULL_CONTEXT;
+ case RPC_X_SS_CONTEXT_DAMAGED: return RPC_NT_SS_CONTEXT_DAMAGED;
+ case RPC_X_SS_HANDLES_MISMATCH: return RPC_NT_SS_HANDLES_MISMATCH;
+ case RPC_X_SS_CANNOT_GET_CALL_HANDLE: return RPC_NT_SS_CANNOT_GET_CALL_HANDLE;
+ case RPC_X_NULL_REF_POINTER: return RPC_NT_NULL_REF_POINTER;
+ case RPC_X_ENUM_VALUE_OUT_OF_RANGE: return RPC_NT_ENUM_VALUE_OUT_OF_RANGE;
+ case RPC_X_BYTE_COUNT_TOO_SMALL: return RPC_NT_BYTE_COUNT_TOO_SMALL;
+ case RPC_X_BAD_STUB_DATA: return RPC_NT_BAD_STUB_DATA;
+ case RPC_X_PIPE_CLOSED: return RPC_NT_PIPE_CLOSED;
+ case RPC_X_PIPE_DISCIPLINE_ERROR: return RPC_NT_PIPE_DISCIPLINE_ERROR;
+ case RPC_X_PIPE_EMPTY: return RPC_NT_PIPE_EMPTY;
+ case ERROR_PASSWORD_MUST_CHANGE: return STATUS_PASSWORD_MUST_CHANGE;
+ case ERROR_ACCOUNT_LOCKED_OUT: return STATUS_ACCOUNT_LOCKED_OUT;
+ default: return status;
+ }
+}
+
+/******************************************************************************
+ * I_RpcExceptionFilter (rpcrt4.@)
+ */
+int WINAPI I_RpcExceptionFilter(ULONG ExceptionCode)
+{
+ TRACE("0x%x\n", ExceptionCode);
+ switch (ExceptionCode)
+ {
+ case STATUS_DATATYPE_MISALIGNMENT:
+ case STATUS_BREAKPOINT:
+ case STATUS_ACCESS_VIOLATION:
+ case STATUS_ILLEGAL_INSTRUCTION:
+ case STATUS_PRIVILEGED_INSTRUCTION:
+ case STATUS_INSTRUCTION_MISALIGNMENT:
+ case STATUS_STACK_OVERFLOW:
+ case STATUS_POSSIBLE_DEADLOCK:
+ return EXCEPTION_CONTINUE_SEARCH;
+ default:
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+}
+
+/******************************************************************************
+ * RpcErrorStartEnumeration (rpcrt4.@)
+ */
+RPC_STATUS RPC_ENTRY RpcErrorStartEnumeration(RPC_ERROR_ENUM_HANDLE* EnumHandle)
+{
+ FIXME("(%p): stub\n", EnumHandle);
+ return RPC_S_ENTRY_NOT_FOUND;
+}
+
+/******************************************************************************
+ * RpcMgmtSetCancelTimeout (rpcrt4.@)
+ */
+RPC_STATUS RPC_ENTRY RpcMgmtSetCancelTimeout(LONG Timeout)
+{
+ FIXME("(%d): stub\n", Timeout);
+ return RPC_S_OK;
+}
+
+static struct threaddata *get_or_create_threaddata(void)
+{
+ struct threaddata *tdata = NtCurrentTeb()->ReservedForNtRpc;
+ if (!tdata)
+ {
+ tdata = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*tdata));
+ if (!tdata) return NULL;
+
+ InitializeCriticalSection(&tdata->cs);
+ tdata->thread_id = GetCurrentThreadId();
+
+ EnterCriticalSection(&threaddata_cs);
+ list_add_tail(&threaddata_list, &tdata->entry);
+ LeaveCriticalSection(&threaddata_cs);
+
+ NtCurrentTeb()->ReservedForNtRpc = tdata;
+ return tdata;
+ }
+ return tdata;
+}
+
+void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection)
+{
+ struct threaddata *tdata = get_or_create_threaddata();
+ if (!tdata) return;
+
+ EnterCriticalSection(&tdata->cs);
+ tdata->connection = Connection;
+ LeaveCriticalSection(&tdata->cs);
+}
+
+void RPCRT4_SetThreadCurrentCallHandle(RpcBinding *Binding)
+{
+ struct threaddata *tdata = get_or_create_threaddata();
+ if (!tdata) return;
+
+ tdata->server_binding = Binding;
+}
+
+RpcBinding *RPCRT4_GetThreadCurrentCallHandle(void)
+{
+ struct threaddata *tdata = get_or_create_threaddata();
+ if (!tdata) return NULL;
+
+ return tdata->server_binding;
+}
+
+void RPCRT4_PushThreadContextHandle(NDR_SCONTEXT SContext)
+{
+ struct threaddata *tdata = get_or_create_threaddata();
+ struct context_handle_list *context_handle_list;
+
+ if (!tdata) return;
+
+ context_handle_list = HeapAlloc(GetProcessHeap(), 0, sizeof(*context_handle_list));
+ if (!context_handle_list) return;
+
+ context_handle_list->context_handle = SContext;
+ context_handle_list->next = tdata->context_handle_list;
+ tdata->context_handle_list = context_handle_list;
+}
+
+void RPCRT4_RemoveThreadContextHandle(NDR_SCONTEXT SContext)
+{
+ struct threaddata *tdata = get_or_create_threaddata();
+ struct context_handle_list *current, *prev;
+
+ if (!tdata) return;
+
+ for (current = tdata->context_handle_list, prev = NULL; current; prev = current, current = current->next)
+ {
+ if (current->context_handle == SContext)
+ {
+ if (prev)
+ prev->next = current->next;
+ else
+ tdata->context_handle_list = current->next;
+ HeapFree(GetProcessHeap(), 0, current);
+ return;
+ }
+ }
+}
+
+NDR_SCONTEXT RPCRT4_PopThreadContextHandle(void)
+{
+ struct threaddata *tdata = get_or_create_threaddata();
+ struct context_handle_list *context_handle_list;
+ NDR_SCONTEXT context_handle;
+
+ if (!tdata) return NULL;
+
+ context_handle_list = tdata->context_handle_list;
+ if (!context_handle_list) return NULL;
+ tdata->context_handle_list = context_handle_list->next;
+
+ context_handle = context_handle_list->context_handle;
+ HeapFree(GetProcessHeap(), 0, context_handle_list);
+ return context_handle;
+}
+
+static RPC_STATUS rpc_cancel_thread(DWORD target_tid)
+{
+ struct threaddata *tdata;
+
+ EnterCriticalSection(&threaddata_cs);
+ LIST_FOR_EACH_ENTRY(tdata, &threaddata_list, struct threaddata, entry)
+ if (tdata->thread_id == target_tid)
+ {
+ EnterCriticalSection(&tdata->cs);
+ if (tdata->connection) rpcrt4_conn_cancel_call(tdata->connection);
+ LeaveCriticalSection(&tdata->cs);
+ break;
+ }
+ LeaveCriticalSection(&threaddata_cs);
+
+ return RPC_S_OK;
+}
+
+/******************************************************************************
+ * RpcCancelThread (rpcrt4.@)
+ */
+RPC_STATUS RPC_ENTRY RpcCancelThread(void* ThreadHandle)
+{
+ TRACE("(%p)\n", ThreadHandle);
+ return RpcCancelThreadEx(ThreadHandle, 0);
+}
+
+/******************************************************************************
+ * RpcCancelThreadEx (rpcrt4.@)
*/
-HRESULT WINAPI NdrDllRegisterProxy(
- HMODULE hDll, /* [in] */
- void **pProxyFileList, /* [???] FIXME: const ProxyFileInfo ** */
- const CLSID *pclsid /* [in] */
-) {
- FIXME("(%x,%p,%s), stub!\n",hDll,pProxyFileList,debugstr_guid(pclsid));
- return S_OK;
+RPC_STATUS RPC_ENTRY RpcCancelThreadEx(void* ThreadHandle, LONG Timeout)
+{
+ DWORD target_tid;
+
+ FIXME("(%p, %d)\n", ThreadHandle, Timeout);
+
+ target_tid = GetThreadId(ThreadHandle);
+ if (!target_tid)
+ return RPC_S_INVALID_ARG;
+
+ if (Timeout)
+ {
+ FIXME("(%p, %d)\n", ThreadHandle, Timeout);
+ return RPC_S_OK;
+ }
+ else
+ return rpc_cancel_thread(target_tid);
}