#include "rpc_binding.h"\r
#include "rpc_message.h"\r
\r
-WINE_DEFAULT_DEBUG_CHANNEL(ole);\r
+WINE_DEFAULT_DEBUG_CHANNEL(rpc);\r
\r
LPSTR RPCRT4_strndupA(LPCSTR src, INT slen)\r
{\r
RPCRT4_DestroyConnection(Binding->FromConn);\r
Binding->FromConn = NULL;\r
} else {\r
- /* we already have an connection with acceptable binding, so use it */\r
+ /* we already have a connection with acceptable binding, so use it */\r
if (Binding->FromConn) {\r
*Connection = Binding->FromConn;\r
return RPC_S_OK;\r
* RETURNS\r
* Success: RPS_S_OK.\r
* Failure: RPC_STATUS value.\r
+ *\r
+ * NOTES\r
+ *\r
+ * If BindingHandle is NULL then the function impersonates the client\r
+ * connected to the binding handle of the current thread.\r
*/\r
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)\r
{\r
FIXME("(%p): stub\n", BindingHandle);\r
- return RPC_S_NO_CONTEXT_AVAILABLE;\r
+ return RPC_S_OK;\r
+}\r
+\r
+/***********************************************************************\r
+ * RpcRevertToSelfEx (RPCRT4.@)\r
+ *\r
+ * Stops impersonating the client connected to the binding handle so that security\r
+ * checks are no longer done in the context of the client.\r
+ *\r
+ * PARAMS\r
+ * BindingHandle [I] Handle to the binding to the client.\r
+ *\r
+ * RETURNS\r
+ * Success: RPS_S_OK.\r
+ * Failure: RPC_STATUS value.\r
+ *\r
+ * NOTES\r
+ *\r
+ * If BindingHandle is NULL then the function stops impersonating the client\r
+ * connected to the binding handle of the current thread.\r
+ */\r
+RPC_STATUS WINAPI RpcRevertToSelfEx(RPC_BINDING_HANDLE BindingHandle)\r
+{\r
+ FIXME("(%p): stub\n", BindingHandle);\r
+ return RPC_S_OK;\r
}\r
\r
#define MAX_THREADS 128\r
\r
-WINE_DEFAULT_DEBUG_CHANNEL(ole);\r
+WINE_DEFAULT_DEBUG_CHANNEL(rpc);\r
\r
typedef struct _RpcPacket\r
{\r
};\r
static CRITICAL_SECTION listen_cs = { &listen_cs_debug, -1, 0, 0, 0, 0 };\r
\r
+/* whether the server is currently listening */\r
static BOOL std_listen;\r
-static LONG listen_count = -1;\r
+/* number of manual listeners (calls to RpcServerListen) */\r
+static LONG manual_listen_count;\r
+/* total listeners including auto listeners */\r
+static LONG listen_count;\r
/* set on change of configuration (e.g. listening on new protseq) */\r
static HANDLE mgr_event;\r
/* mutex for ensuring only one thread can change state at a time */\r
while (cif) {\r
if (!memcmp(if_id, &cif->If->InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER)) &&\r
(check_object == FALSE || UuidEqual(MgrType, &cif->MgrTypeUuid, &status)) &&\r
- (std_listen || (cif->Flags & RPC_IF_AUTOLISTEN))) break;\r
+ std_listen) break;\r
cif = cif->Next;\r
}\r
LeaveCriticalSection(&server_cs);\r
ReleaseMutex(mgr_mutex);\r
}\r
\r
-static void RPCRT4_start_listen(void)\r
+static void RPCRT4_start_listen(BOOL auto_listen)\r
{\r
TRACE("\n");\r
\r
EnterCriticalSection(&listen_cs);\r
- if (! ++listen_count) {\r
- if (!mgr_mutex) mgr_mutex = CreateMutexW(NULL, FALSE, NULL);\r
- if (!mgr_event) mgr_event = CreateEventW(NULL, FALSE, FALSE, NULL);\r
- if (!server_ready_event) server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);\r
- if (!server_sem) server_sem = CreateSemaphoreW(NULL, 0, MAX_THREADS, NULL);\r
- if (!worker_tls) worker_tls = TlsAlloc();\r
- std_listen = TRUE;\r
- server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, NULL, 0, NULL);\r
- LeaveCriticalSection(&listen_cs);\r
- } else {\r
- LeaveCriticalSection(&listen_cs);\r
- RPCRT4_sync_with_server_thread();\r
+ if (auto_listen || (manual_listen_count++ == 0))\r
+ {\r
+ if (++listen_count == 1) {\r
+ /* first listener creates server thread */\r
+ if (!mgr_mutex) mgr_mutex = CreateMutexW(NULL, FALSE, NULL);\r
+ if (!mgr_event) mgr_event = CreateEventW(NULL, FALSE, FALSE, NULL);\r
+ if (!server_ready_event) server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);\r
+ if (!server_sem) server_sem = CreateSemaphoreW(NULL, 0, MAX_THREADS, NULL);\r
+ if (!worker_tls) worker_tls = TlsAlloc();\r
+ std_listen = TRUE;\r
+ server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, NULL, 0, NULL);\r
+ } else {\r
+ LeaveCriticalSection(&listen_cs);\r
+ RPCRT4_sync_with_server_thread();\r
+ return;\r
+ }\r
}\r
+ LeaveCriticalSection(&listen_cs);\r
}\r
\r
-static void RPCRT4_stop_listen(void)\r
+static void RPCRT4_stop_listen(BOOL auto_listen)\r
{\r
EnterCriticalSection(&listen_cs);\r
- if (listen_count == -1)\r
- LeaveCriticalSection(&listen_cs);\r
- else if (--listen_count == -1) {\r
- std_listen = FALSE;\r
- LeaveCriticalSection(&listen_cs);\r
- RPCRT4_sync_with_server_thread();\r
- } else\r
- LeaveCriticalSection(&listen_cs);\r
- assert(listen_count > -2);\r
+ if (auto_listen || (--manual_listen_count == 0))\r
+ {\r
+ if (listen_count != 0 && --listen_count == 0) {\r
+ std_listen = FALSE;\r
+ LeaveCriticalSection(&listen_cs);\r
+ RPCRT4_sync_with_server_thread();\r
+ return;\r
+ }\r
+ assert(listen_count >= 0);\r
+ }\r
+ LeaveCriticalSection(&listen_cs);\r
}\r
\r
static RPC_STATUS RPCRT4_use_protseq(RpcServerProtseq* ps)\r
\r
if (sif->Flags & RPC_IF_AUTOLISTEN) {\r
/* well, start listening, I think... */\r
- RPCRT4_start_listen();\r
+ RPCRT4_start_listen(TRUE);\r
}\r
\r
return RPC_S_OK;\r
return RPC_S_ALREADY_LISTENING;\r
}\r
\r
- RPCRT4_start_listen();\r
+ RPCRT4_start_listen(FALSE);\r
\r
LeaveCriticalSection(&listen_cs);\r
\r
return RPC_S_WRONG_KIND_OF_BINDING;\r
}\r
\r
- /* hmm... */\r
- EnterCriticalSection(&listen_cs);\r
- while (std_listen)\r
- RPCRT4_stop_listen();\r
- LeaveCriticalSection(&listen_cs);\r
+ RPCRT4_stop_listen(FALSE);\r
\r
return RPC_S_OK;\r
}\r
\r
#include "wine/debug.h"\r
\r
-WINE_DEFAULT_DEBUG_CHANNEL(ole);\r
+WINE_DEFAULT_DEBUG_CHANNEL(rpc);\r
\r
static UUID uuid_nil;\r
static HANDLE master_mutex;\r
DWORD status = RPC_S_OK;\r
\r
ULONG buflen = sizeof(IP_ADAPTER_INFO);\r
- PIP_ADAPTER_INFO adapter = (PIP_ADAPTER_INFO)HeapAlloc(GetProcessHeap(), 0, buflen);\r
+ PIP_ADAPTER_INFO adapter = HeapAlloc(GetProcessHeap(), 0, buflen);\r
\r
if (GetAdaptersInfo(adapter, &buflen) == ERROR_BUFFER_OVERFLOW) {\r
HeapFree(GetProcessHeap(), 0, adapter);\r
- adapter = (IP_ADAPTER_INFO *)HeapAlloc(GetProcessHeap(), 0, buflen);\r
+ adapter = HeapAlloc(GetProcessHeap(), 0, buflen);\r
}\r
\r
if (GetAdaptersInfo(adapter, &buflen) == NO_ERROR) {\r
address[i] = rand() & 0xff;\r
}\r
\r
- address[0] |= 0x80;\r
+ address[0] |= 0x01;\r
status = RPC_S_UUID_LOCAL_ONLY;\r
}\r
\r