2002-10-11 19:52:37 +02:00
|
|
|
/*
|
|
|
|
* RPC server API
|
|
|
|
*
|
2008-10-18 19:20:44 +02:00
|
|
|
* Copyright 2001 Ove Kåven, TransGaming Technologies
|
2004-04-27 01:33:39 +02:00
|
|
|
* Copyright 2004 Filip Navara
|
2008-01-11 11:00:25 +01:00
|
|
|
* Copyright 2006-2008 Robert Shearman (for CodeWeavers)
|
2002-10-11 19:52:37 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-10-11 19:52:37 +02:00
|
|
|
*/
|
|
|
|
|
2003-11-27 01:59:36 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-10-11 19:52:37 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2002-10-31 23:45:12 +01:00
|
|
|
#include <assert.h>
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
|
|
#include "rpc.h"
|
2004-04-27 01:33:39 +02:00
|
|
|
#include "rpcndr.h"
|
2003-05-22 05:36:00 +02:00
|
|
|
#include "excpt.h"
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2003-05-22 05:36:00 +02:00
|
|
|
#include "wine/exception.h"
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
#include "rpc_server.h"
|
2007-12-16 13:11:49 +01:00
|
|
|
#include "rpc_assoc.h"
|
2004-04-27 01:33:39 +02:00
|
|
|
#include "rpc_message.h"
|
2002-10-11 19:52:37 +02:00
|
|
|
#include "rpc_defs.h"
|
2007-07-05 13:46:59 +02:00
|
|
|
#include "ncastatus.h"
|
2012-05-09 12:06:29 +02:00
|
|
|
#include "secext.h"
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2005-03-14 11:11:04 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(rpc);
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2003-02-19 04:44:35 +01:00
|
|
|
typedef struct _RpcPacket
|
|
|
|
{
|
|
|
|
struct _RpcConnection* conn;
|
2004-04-27 01:33:39 +02:00
|
|
|
RpcPktHdr* hdr;
|
|
|
|
RPC_MESSAGE* msg;
|
2009-12-13 22:35:39 +01:00
|
|
|
unsigned char *auth_data;
|
|
|
|
ULONG auth_length;
|
2003-02-19 04:44:35 +01:00
|
|
|
} RpcPacket;
|
|
|
|
|
2003-11-21 23:14:42 +01:00
|
|
|
typedef struct _RpcObjTypeMap
|
|
|
|
{
|
|
|
|
/* FIXME: a hash table would be better. */
|
|
|
|
struct _RpcObjTypeMap *next;
|
|
|
|
UUID Object;
|
|
|
|
UUID Type;
|
|
|
|
} RpcObjTypeMap;
|
|
|
|
|
|
|
|
static RpcObjTypeMap *RpcObjTypeMaps;
|
|
|
|
|
2006-10-16 17:49:29 +02:00
|
|
|
/* list of type RpcServerProtseq */
|
|
|
|
static struct list protseqs = LIST_INIT(protseqs);
|
2006-11-13 12:45:57 +01:00
|
|
|
static struct list server_interfaces = LIST_INIT(server_interfaces);
|
2009-12-13 22:35:29 +01:00
|
|
|
static struct list server_registered_auth_info = LIST_INIT(server_registered_auth_info);
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2003-08-13 01:50:54 +02:00
|
|
|
static CRITICAL_SECTION server_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG server_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &server_cs,
|
|
|
|
{ &server_cs_debug.ProcessLocksList, &server_cs_debug.ProcessLocksList },
|
2005-09-09 12:19:44 +02:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": server_cs") }
|
2003-08-13 01:50:54 +02:00
|
|
|
};
|
|
|
|
static CRITICAL_SECTION server_cs = { &server_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
static CRITICAL_SECTION listen_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG listen_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &listen_cs,
|
|
|
|
{ &listen_cs_debug.ProcessLocksList, &listen_cs_debug.ProcessLocksList },
|
2005-09-09 12:19:44 +02:00
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": listen_cs") }
|
2003-08-13 01:50:54 +02:00
|
|
|
};
|
|
|
|
static CRITICAL_SECTION listen_cs = { &listen_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
2009-12-13 22:35:29 +01:00
|
|
|
static CRITICAL_SECTION server_auth_info_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG server_auth_info_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &server_auth_info_cs,
|
|
|
|
{ &server_auth_info_cs_debug.ProcessLocksList, &server_auth_info_cs_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": server_auth_info_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION server_auth_info_cs = { &server_auth_info_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
2005-03-14 11:11:04 +01:00
|
|
|
/* whether the server is currently listening */
|
2002-10-11 19:52:37 +02:00
|
|
|
static BOOL std_listen;
|
2005-03-14 11:11:04 +01:00
|
|
|
/* number of manual listeners (calls to RpcServerListen) */
|
|
|
|
static LONG manual_listen_count;
|
|
|
|
/* total listeners including auto listeners */
|
|
|
|
static LONG listen_count;
|
2010-11-09 23:11:35 +01:00
|
|
|
/* event set once all listening is finished */
|
|
|
|
static HANDLE listen_done_event;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2003-11-21 23:14:42 +01:00
|
|
|
static UUID uuid_nil;
|
|
|
|
|
2007-03-22 19:26:46 +01:00
|
|
|
static inline RpcObjTypeMap *LookupObjTypeMap(UUID *ObjUuid)
|
2003-11-21 23:14:42 +01:00
|
|
|
{
|
|
|
|
RpcObjTypeMap *rslt = RpcObjTypeMaps;
|
|
|
|
RPC_STATUS dummy;
|
|
|
|
|
|
|
|
while (rslt) {
|
|
|
|
if (! UuidCompare(ObjUuid, &rslt->Object, &dummy)) break;
|
|
|
|
rslt = rslt->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rslt;
|
|
|
|
}
|
|
|
|
|
2007-03-22 19:26:46 +01:00
|
|
|
static inline UUID *LookupObjType(UUID *ObjUuid)
|
2003-11-21 23:14:42 +01:00
|
|
|
{
|
|
|
|
RpcObjTypeMap *map = LookupObjTypeMap(ObjUuid);
|
|
|
|
if (map)
|
|
|
|
return &map->Type;
|
|
|
|
else
|
|
|
|
return &uuid_nil;
|
|
|
|
}
|
|
|
|
|
2004-04-27 01:33:39 +02:00
|
|
|
static RpcServerInterface* RPCRT4_find_interface(UUID* object,
|
2009-11-11 00:05:07 +01:00
|
|
|
const RPC_SYNTAX_IDENTIFIER *if_id,
|
|
|
|
const RPC_SYNTAX_IDENTIFIER *transfer_syntax,
|
2004-04-27 01:33:39 +02:00
|
|
|
BOOL check_object)
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
|
|
|
UUID* MgrType = NULL;
|
2006-11-13 12:45:57 +01:00
|
|
|
RpcServerInterface* cif;
|
2002-10-11 19:52:37 +02:00
|
|
|
RPC_STATUS status;
|
|
|
|
|
2004-04-27 01:33:39 +02:00
|
|
|
if (check_object)
|
|
|
|
MgrType = LookupObjType(object);
|
2002-10-11 19:52:37 +02:00
|
|
|
EnterCriticalSection(&server_cs);
|
2006-11-13 12:45:57 +01:00
|
|
|
LIST_FOR_EACH_ENTRY(cif, &server_interfaces, RpcServerInterface, entry) {
|
2004-04-27 01:33:39 +02:00
|
|
|
if (!memcmp(if_id, &cif->If->InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER)) &&
|
2009-11-11 00:05:07 +01:00
|
|
|
(!transfer_syntax || !memcmp(transfer_syntax, &cif->If->TransferSyntax, sizeof(RPC_SYNTAX_IDENTIFIER))) &&
|
2004-04-27 01:33:39 +02:00
|
|
|
(check_object == FALSE || UuidEqual(MgrType, &cif->MgrTypeUuid, &status)) &&
|
2006-11-13 12:46:04 +01:00
|
|
|
std_listen) {
|
|
|
|
InterlockedIncrement(&cif->CurrentCalls);
|
|
|
|
break;
|
|
|
|
}
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&server_cs);
|
2006-11-13 12:45:57 +01:00
|
|
|
if (&cif->entry == &server_interfaces) cif = NULL;
|
2008-04-01 13:48:06 +02:00
|
|
|
TRACE("returning %p for object %s, if_id { %d.%d %s }\n", cif,
|
|
|
|
debugstr_guid(object), if_id->SyntaxVersion.MajorVersion,
|
|
|
|
if_id->SyntaxVersion.MinorVersion, debugstr_guid(&if_id->SyntaxGUID));
|
2002-10-11 19:52:37 +02:00
|
|
|
return cif;
|
|
|
|
}
|
|
|
|
|
2006-11-13 12:46:04 +01:00
|
|
|
static void RPCRT4_release_server_interface(RpcServerInterface *sif)
|
|
|
|
{
|
|
|
|
if (!InterlockedDecrement(&sif->CurrentCalls) &&
|
2008-09-12 13:58:19 +02:00
|
|
|
sif->Delete) {
|
2006-11-13 12:46:04 +01:00
|
|
|
/* sif must have been removed from server_interfaces before
|
|
|
|
* CallsCompletedEvent is set */
|
2008-09-12 13:58:19 +02:00
|
|
|
if (sif->CallsCompletedEvent)
|
|
|
|
SetEvent(sif->CallsCompletedEvent);
|
2006-11-13 12:46:04 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, sif);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
static RpcPktHdr *handle_bind_error(RpcConnection *conn, RPC_STATUS error)
|
|
|
|
{
|
|
|
|
unsigned int reject_reason;
|
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case RPC_S_SERVER_TOO_BUSY:
|
|
|
|
reject_reason = REJECT_TEMPORARY_CONGESTION;
|
|
|
|
break;
|
|
|
|
case ERROR_OUTOFMEMORY:
|
|
|
|
case RPC_S_OUT_OF_RESOURCES:
|
|
|
|
reject_reason = REJECT_LOCAL_LIMIT_EXCEEDED;
|
|
|
|
break;
|
|
|
|
case RPC_S_PROTOCOL_ERROR:
|
|
|
|
reject_reason = REJECT_PROTOCOL_VERSION_NOT_SUPPORTED;
|
|
|
|
break;
|
|
|
|
case RPC_S_UNKNOWN_AUTHN_SERVICE:
|
|
|
|
reject_reason = REJECT_UNKNOWN_AUTHN_SERVICE;
|
|
|
|
break;
|
|
|
|
case ERROR_ACCESS_DENIED:
|
|
|
|
reject_reason = REJECT_INVALID_CHECKSUM;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unexpected status value %d\n", error);
|
|
|
|
/* fall through */
|
|
|
|
case RPC_S_INVALID_BOUND:
|
|
|
|
reject_reason = REJECT_REASON_NOT_SPECIFIED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return RPCRT4_BuildBindNackHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
|
|
|
RPC_VER_MAJOR, RPC_VER_MINOR,
|
|
|
|
reject_reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
static RPC_STATUS process_bind_packet_no_send(
|
|
|
|
RpcConnection *conn, RpcPktBindHdr *hdr, RPC_MESSAGE *msg,
|
|
|
|
unsigned char *auth_data, ULONG auth_length, RpcPktHdr **ack_response,
|
|
|
|
unsigned char **auth_data_out, ULONG *auth_length_out)
|
2003-02-19 04:44:35 +01:00
|
|
|
{
|
2008-01-11 11:00:25 +01:00
|
|
|
RPC_STATUS status;
|
2009-11-11 00:05:07 +01:00
|
|
|
RpcContextElement *ctxt_elem;
|
|
|
|
unsigned int i;
|
2009-12-13 22:35:39 +01:00
|
|
|
RpcResult *results;
|
2009-11-11 00:05:07 +01:00
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
/* validate data */
|
2009-11-11 00:05:07 +01:00
|
|
|
for (i = 0, ctxt_elem = msg->Buffer;
|
|
|
|
i < hdr->num_elements;
|
|
|
|
i++, ctxt_elem = (RpcContextElement *)&ctxt_elem->transfer_syntaxes[ctxt_elem->num_syntaxes])
|
|
|
|
{
|
|
|
|
if (((char *)ctxt_elem - (char *)msg->Buffer) > msg->BufferLength ||
|
|
|
|
((char *)&ctxt_elem->transfer_syntaxes[ctxt_elem->num_syntaxes] - (char *)msg->Buffer) > msg->BufferLength)
|
|
|
|
{
|
|
|
|
ERR("inconsistent data in packet - packet length %d, num elements %d\n",
|
|
|
|
msg->BufferLength, hdr->num_elements);
|
2009-12-13 22:35:39 +01:00
|
|
|
return RPC_S_INVALID_BOUND;
|
2009-11-11 00:05:07 +01:00
|
|
|
}
|
|
|
|
}
|
2008-01-11 11:00:25 +01:00
|
|
|
|
|
|
|
if (hdr->max_tsize < RPC_MIN_PACKET_SIZE ||
|
|
|
|
!UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status) ||
|
2009-11-11 00:05:07 +01:00
|
|
|
conn->server_binding)
|
|
|
|
{
|
2008-01-11 11:00:25 +01:00
|
|
|
TRACE("packet size less than min size, or active interface syntax guid non-null\n");
|
2009-11-11 00:05:07 +01:00
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
return RPC_S_INVALID_BOUND;
|
2009-11-11 00:05:07 +01:00
|
|
|
}
|
2009-12-13 22:35:39 +01:00
|
|
|
|
|
|
|
results = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
hdr->num_elements * sizeof(*results));
|
|
|
|
if (!results)
|
|
|
|
return RPC_S_OUT_OF_RESOURCES;
|
|
|
|
|
|
|
|
for (i = 0, ctxt_elem = (RpcContextElement *)msg->Buffer;
|
|
|
|
i < hdr->num_elements;
|
|
|
|
i++, ctxt_elem = (RpcContextElement *)&ctxt_elem->transfer_syntaxes[ctxt_elem->num_syntaxes])
|
2009-11-11 00:05:07 +01:00
|
|
|
{
|
2009-12-13 22:35:39 +01:00
|
|
|
RpcServerInterface* sif = NULL;
|
|
|
|
unsigned int j;
|
2009-11-11 00:05:07 +01:00
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
for (j = 0; !sif && j < ctxt_elem->num_syntaxes; j++)
|
|
|
|
{
|
|
|
|
sif = RPCRT4_find_interface(NULL, &ctxt_elem->abstract_syntax,
|
|
|
|
&ctxt_elem->transfer_syntaxes[j], FALSE);
|
|
|
|
if (sif)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (sif)
|
|
|
|
{
|
|
|
|
RPCRT4_release_server_interface(sif);
|
|
|
|
TRACE("accepting bind request on connection %p for %s\n", conn,
|
|
|
|
debugstr_guid(&ctxt_elem->abstract_syntax.SyntaxGUID));
|
|
|
|
results[i].result = RESULT_ACCEPT;
|
|
|
|
results[i].reason = REASON_NONE;
|
|
|
|
results[i].transfer_syntax = ctxt_elem->transfer_syntaxes[j];
|
|
|
|
|
|
|
|
/* save the interface for later use */
|
|
|
|
/* FIXME: save linked list */
|
|
|
|
conn->ActiveInterface = ctxt_elem->abstract_syntax;
|
|
|
|
}
|
|
|
|
else if ((sif = RPCRT4_find_interface(NULL, &ctxt_elem->abstract_syntax,
|
|
|
|
NULL, FALSE)) != NULL)
|
|
|
|
{
|
|
|
|
RPCRT4_release_server_interface(sif);
|
|
|
|
TRACE("not accepting bind request on connection %p for %s - no transfer syntaxes supported\n",
|
|
|
|
conn, debugstr_guid(&ctxt_elem->abstract_syntax.SyntaxGUID));
|
|
|
|
results[i].result = RESULT_PROVIDER_REJECTION;
|
|
|
|
results[i].reason = REASON_TRANSFER_SYNTAXES_NOT_SUPPORTED;
|
|
|
|
memset(&results[i].transfer_syntax, 0, sizeof(results[i].transfer_syntax));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("not accepting bind request on connection %p for %s - abstract syntax not supported\n",
|
|
|
|
conn, debugstr_guid(&ctxt_elem->abstract_syntax.SyntaxGUID));
|
|
|
|
results[i].result = RESULT_PROVIDER_REJECTION;
|
|
|
|
results[i].reason = REASON_ABSTRACT_SYNTAX_NOT_SUPPORTED;
|
|
|
|
memset(&results[i].transfer_syntax, 0, sizeof(results[i].transfer_syntax));
|
|
|
|
}
|
|
|
|
}
|
2009-11-11 00:05:07 +01:00
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
/* create temporary binding */
|
|
|
|
status = RPCRT4_MakeBinding(&conn->server_binding, conn);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, results);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = RpcServerAssoc_GetAssociation(rpcrt4_conn_get_name(conn),
|
|
|
|
conn->NetworkAddr, conn->Endpoint,
|
|
|
|
conn->NetworkOptions,
|
|
|
|
hdr->assoc_gid,
|
|
|
|
&conn->server_binding->Assoc);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, results);
|
|
|
|
return status;
|
2008-01-11 11:00:25 +01:00
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
if (auth_length)
|
|
|
|
{
|
|
|
|
status = RPCRT4_ServerConnectionAuth(conn, TRUE,
|
|
|
|
(RpcAuthVerifier *)auth_data,
|
|
|
|
auth_length, auth_data_out,
|
|
|
|
auth_length_out);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, results);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*ack_response = RPCRT4_BuildBindAckHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
|
|
|
RPC_MAX_PACKET_SIZE,
|
|
|
|
RPC_MAX_PACKET_SIZE,
|
|
|
|
conn->server_binding->Assoc->assoc_group_id,
|
|
|
|
conn->Endpoint, hdr->num_elements,
|
|
|
|
results);
|
|
|
|
HeapFree(GetProcessHeap(), 0, results);
|
|
|
|
|
|
|
|
if (*ack_response)
|
|
|
|
conn->MaxTransmissionSize = hdr->max_tsize;
|
2008-01-11 11:00:25 +01:00
|
|
|
else
|
2009-12-13 22:35:39 +01:00
|
|
|
status = RPC_S_OUT_OF_RESOURCES;
|
2008-01-11 11:00:25 +01:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
static RPC_STATUS process_bind_packet(RpcConnection *conn, RpcPktBindHdr *hdr,
|
|
|
|
RPC_MESSAGE *msg,
|
|
|
|
unsigned char *auth_data,
|
|
|
|
ULONG auth_length)
|
|
|
|
{
|
|
|
|
RPC_STATUS status;
|
|
|
|
RpcPktHdr *response = NULL;
|
|
|
|
unsigned char *auth_data_out = NULL;
|
|
|
|
ULONG auth_length_out = 0;
|
|
|
|
|
|
|
|
status = process_bind_packet_no_send(conn, hdr, msg, auth_data, auth_length,
|
|
|
|
&response, &auth_data_out,
|
|
|
|
&auth_length_out);
|
|
|
|
if (status != RPC_S_OK)
|
|
|
|
response = handle_bind_error(conn, status);
|
|
|
|
if (response)
|
|
|
|
status = RPCRT4_SendWithAuth(conn, response, NULL, 0, auth_data_out, auth_length_out);
|
|
|
|
else
|
|
|
|
status = ERROR_OUTOFMEMORY;
|
|
|
|
RPCRT4_FreeHeader(response);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-11 11:00:25 +01:00
|
|
|
static RPC_STATUS process_request_packet(RpcConnection *conn, RpcPktRequestHdr *hdr, RPC_MESSAGE *msg)
|
|
|
|
{
|
2004-04-27 01:33:39 +02:00
|
|
|
RPC_STATUS status;
|
2008-01-11 11:00:25 +01:00
|
|
|
RpcPktHdr *response = NULL;
|
|
|
|
RpcServerInterface* sif;
|
|
|
|
RPC_DISPATCH_FUNCTION func;
|
2007-07-05 13:47:42 +02:00
|
|
|
BOOL exception;
|
2008-01-11 11:00:25 +01:00
|
|
|
UUID *object_uuid;
|
2007-12-30 17:44:54 +01:00
|
|
|
NDR_SCONTEXT context_handle;
|
2008-01-11 11:00:25 +01:00
|
|
|
void *buf = msg->Buffer;
|
|
|
|
|
|
|
|
/* fail if the connection isn't bound with an interface */
|
|
|
|
if (UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status)) {
|
|
|
|
/* FIXME: should send BindNack instead */
|
|
|
|
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
|
|
|
status);
|
|
|
|
|
|
|
|
RPCRT4_Send(conn, response, NULL, 0);
|
|
|
|
RPCRT4_FreeHeader(response);
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdr->common.flags & RPC_FLG_OBJECT_UUID) {
|
|
|
|
object_uuid = (UUID*)(hdr + 1);
|
|
|
|
} else {
|
|
|
|
object_uuid = NULL;
|
|
|
|
}
|
|
|
|
|
2009-11-11 00:05:07 +01:00
|
|
|
sif = RPCRT4_find_interface(object_uuid, &conn->ActiveInterface, NULL, TRUE);
|
2008-01-11 11:00:25 +01:00
|
|
|
if (!sif) {
|
|
|
|
WARN("interface %s no longer registered, returning fault packet\n", debugstr_guid(&conn->ActiveInterface.SyntaxGUID));
|
|
|
|
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
|
|
|
NCA_S_UNK_IF);
|
|
|
|
|
|
|
|
RPCRT4_Send(conn, response, NULL, 0);
|
|
|
|
RPCRT4_FreeHeader(response);
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
msg->RpcInterfaceInformation = sif->If;
|
|
|
|
/* copy the endpoint vector from sif to msg so that midl-generated code will use it */
|
|
|
|
msg->ManagerEpv = sif->MgrEpv;
|
|
|
|
if (object_uuid != NULL) {
|
|
|
|
RPCRT4_SetBindingObject(msg->Handle, object_uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find dispatch function */
|
|
|
|
msg->ProcNum = hdr->opnum;
|
|
|
|
if (sif->Flags & RPC_IF_OLE) {
|
|
|
|
/* native ole32 always gives us a dispatch table with a single entry
|
|
|
|
* (I assume that's a wrapper for IRpcStubBuffer::Invoke) */
|
|
|
|
func = *sif->If->DispatchTable->DispatchTable;
|
|
|
|
} else {
|
|
|
|
if (msg->ProcNum >= sif->If->DispatchTable->DispatchTableCount) {
|
|
|
|
WARN("invalid procnum (%d/%d)\n", msg->ProcNum, sif->If->DispatchTable->DispatchTableCount);
|
|
|
|
response = RPCRT4_BuildFaultHeader(NDR_LOCAL_DATA_REPRESENTATION,
|
|
|
|
NCA_S_OP_RNG_ERROR);
|
|
|
|
|
|
|
|
RPCRT4_Send(conn, response, NULL, 0);
|
|
|
|
RPCRT4_FreeHeader(response);
|
|
|
|
}
|
|
|
|
func = sif->If->DispatchTable->DispatchTable[msg->ProcNum];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* put in the drep. FIXME: is this more universally applicable?
|
|
|
|
perhaps we should move this outward... */
|
|
|
|
msg->DataRepresentation =
|
|
|
|
MAKELONG( MAKEWORD(hdr->common.drep[0], hdr->common.drep[1]),
|
|
|
|
MAKEWORD(hdr->common.drep[2], hdr->common.drep[3]));
|
|
|
|
|
|
|
|
exception = FALSE;
|
|
|
|
|
|
|
|
/* dispatch */
|
|
|
|
RPCRT4_SetThreadCurrentCallHandle(msg->Handle);
|
|
|
|
__TRY {
|
|
|
|
if (func) func(msg);
|
2008-02-15 16:43:24 +01:00
|
|
|
} __EXCEPT_ALL {
|
2008-02-15 16:19:29 +01:00
|
|
|
WARN("exception caught with code 0x%08x = %d\n", GetExceptionCode(), GetExceptionCode());
|
2008-01-11 11:00:25 +01:00
|
|
|
exception = TRUE;
|
|
|
|
if (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
|
|
|
|
status = ERROR_NOACCESS;
|
|
|
|
else
|
|
|
|
status = GetExceptionCode();
|
|
|
|
response = RPCRT4_BuildFaultHeader(msg->DataRepresentation,
|
|
|
|
RPC2NCA_STATUS(status));
|
|
|
|
} __ENDTRY
|
|
|
|
RPCRT4_SetThreadCurrentCallHandle(NULL);
|
|
|
|
|
|
|
|
/* release any unmarshalled context handles */
|
|
|
|
while ((context_handle = RPCRT4_PopThreadContextHandle()) != NULL)
|
|
|
|
RpcServerAssoc_ReleaseContextHandle(conn->server_binding->Assoc, context_handle, TRUE);
|
|
|
|
|
|
|
|
if (!exception)
|
|
|
|
response = RPCRT4_BuildResponseHeader(msg->DataRepresentation,
|
|
|
|
msg->BufferLength);
|
|
|
|
|
|
|
|
/* send response packet */
|
|
|
|
if (response) {
|
|
|
|
status = RPCRT4_Send(conn, response, exception ? NULL : msg->Buffer,
|
|
|
|
exception ? 0 : msg->BufferLength);
|
|
|
|
RPCRT4_FreeHeader(response);
|
|
|
|
} else
|
|
|
|
ERR("out of memory\n");
|
|
|
|
|
|
|
|
msg->RpcInterfaceInformation = NULL;
|
|
|
|
RPCRT4_release_server_interface(sif);
|
|
|
|
|
|
|
|
if (msg->Buffer == buf) buf = NULL;
|
|
|
|
TRACE("freeing Buffer=%p\n", buf);
|
|
|
|
I_RpcFree(buf);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
static RPC_STATUS process_auth3_packet(RpcConnection *conn,
|
|
|
|
RpcPktCommonHdr *hdr,
|
|
|
|
RPC_MESSAGE *msg,
|
|
|
|
unsigned char *auth_data,
|
|
|
|
ULONG auth_length)
|
|
|
|
{
|
|
|
|
RPC_STATUS status;
|
|
|
|
|
|
|
|
if (UuidIsNil(&conn->ActiveInterface.SyntaxGUID, &status) ||
|
|
|
|
!auth_length || msg->BufferLength != 0)
|
|
|
|
status = RPC_S_PROTOCOL_ERROR;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = RPCRT4_ServerConnectionAuth(conn, FALSE,
|
|
|
|
(RpcAuthVerifier *)auth_data,
|
|
|
|
auth_length, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: client doesn't expect a response to this message so must store
|
|
|
|
* status in connection so that fault packet can be returned when next
|
|
|
|
* packet is received */
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RPCRT4_process_packet(RpcConnection* conn, RpcPktHdr* hdr,
|
|
|
|
RPC_MESSAGE* msg, unsigned char *auth_data,
|
|
|
|
ULONG auth_length)
|
2008-01-11 11:00:25 +01:00
|
|
|
{
|
2007-12-16 13:07:30 +01:00
|
|
|
msg->Handle = (RPC_BINDING_HANDLE)conn->server_binding;
|
|
|
|
|
2004-04-27 01:33:39 +02:00
|
|
|
switch (hdr->common.ptype) {
|
|
|
|
case PKT_BIND:
|
|
|
|
TRACE("got bind packet\n");
|
2010-09-01 12:39:01 +02:00
|
|
|
process_bind_packet(conn, &hdr->bind, msg, auth_data, auth_length);
|
2004-04-27 01:33:39 +02:00
|
|
|
break;
|
|
|
|
|
2003-02-19 04:44:35 +01:00
|
|
|
case PKT_REQUEST:
|
2004-04-27 01:33:39 +02:00
|
|
|
TRACE("got request packet\n");
|
2010-09-01 12:39:01 +02:00
|
|
|
process_request_packet(conn, &hdr->request, msg);
|
2003-02-19 04:44:35 +01:00
|
|
|
break;
|
2004-04-27 01:33:39 +02:00
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
case PKT_AUTH3:
|
|
|
|
TRACE("got auth3 packet\n");
|
2010-09-01 12:39:01 +02:00
|
|
|
process_auth3_packet(conn, &hdr->common, msg, auth_data, auth_length);
|
2009-12-13 22:35:39 +01:00
|
|
|
break;
|
2003-02-19 04:44:35 +01:00
|
|
|
default:
|
2007-01-22 22:50:31 +01:00
|
|
|
FIXME("unhandled packet type %u\n", hdr->common.ptype);
|
2003-02-19 04:44:35 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up */
|
2008-09-12 13:58:39 +02:00
|
|
|
I_RpcFree(msg->Buffer);
|
2004-04-27 01:33:39 +02:00
|
|
|
RPCRT4_FreeHeader(hdr);
|
2006-04-20 12:44:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, msg);
|
2009-12-13 22:35:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, auth_data);
|
2003-02-19 04:44:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD CALLBACK RPCRT4_worker_thread(LPVOID the_arg)
|
|
|
|
{
|
2006-06-17 13:31:32 +02:00
|
|
|
RpcPacket *pkt = the_arg;
|
2009-12-13 22:35:39 +01:00
|
|
|
RPCRT4_process_packet(pkt->conn, pkt->hdr, pkt->msg, pkt->auth_data,
|
|
|
|
pkt->auth_length);
|
2012-02-14 16:19:32 +01:00
|
|
|
RPCRT4_ReleaseConnection(pkt->conn);
|
2006-06-17 13:31:32 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pkt);
|
2003-02-19 04:44:35 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD CALLBACK RPCRT4_io_thread(LPVOID the_arg)
|
|
|
|
{
|
2009-02-16 09:54:10 +01:00
|
|
|
RpcConnection* conn = the_arg;
|
2004-04-27 01:33:39 +02:00
|
|
|
RpcPktHdr *hdr;
|
|
|
|
RPC_MESSAGE *msg;
|
|
|
|
RPC_STATUS status;
|
|
|
|
RpcPacket *packet;
|
2009-12-13 22:35:39 +01:00
|
|
|
unsigned char *auth_data;
|
|
|
|
ULONG auth_length;
|
2003-02-19 04:44:35 +01:00
|
|
|
|
|
|
|
TRACE("(%p)\n", conn);
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
for (;;) {
|
2004-04-27 01:33:39 +02:00
|
|
|
msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RPC_MESSAGE));
|
2009-12-13 22:35:43 +01:00
|
|
|
if (!msg) break;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2009-12-13 22:35:39 +01:00
|
|
|
status = RPCRT4_ReceiveWithAuth(conn, &hdr, msg, &auth_data, &auth_length);
|
2004-04-27 01:33:39 +02:00
|
|
|
if (status != RPC_S_OK) {
|
2009-01-04 01:49:14 +01:00
|
|
|
WARN("receive failed with error %x\n", status);
|
2006-04-20 12:44:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, msg);
|
2002-10-11 19:52:37 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:43 +01:00
|
|
|
switch (hdr->common.ptype) {
|
|
|
|
case PKT_BIND:
|
|
|
|
TRACE("got bind packet\n");
|
|
|
|
|
|
|
|
status = process_bind_packet(conn, &hdr->bind, msg, auth_data,
|
|
|
|
auth_length);
|
2008-01-08 19:14:27 +01:00
|
|
|
break;
|
2009-12-13 22:35:43 +01:00
|
|
|
|
|
|
|
case PKT_REQUEST:
|
|
|
|
TRACE("got request packet\n");
|
|
|
|
|
|
|
|
packet = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcPacket));
|
|
|
|
if (!packet) {
|
|
|
|
I_RpcFree(msg->Buffer);
|
|
|
|
RPCRT4_FreeHeader(hdr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, msg);
|
|
|
|
HeapFree(GetProcessHeap(), 0, auth_data);
|
|
|
|
goto exit;
|
|
|
|
}
|
2012-02-14 16:19:32 +01:00
|
|
|
packet->conn = RPCRT4_GrabConnection( conn );
|
2009-12-13 22:35:43 +01:00
|
|
|
packet->hdr = hdr;
|
|
|
|
packet->msg = msg;
|
|
|
|
packet->auth_data = auth_data;
|
|
|
|
packet->auth_length = auth_length;
|
|
|
|
if (!QueueUserWorkItem(RPCRT4_worker_thread, packet, WT_EXECUTELONGFUNCTION)) {
|
|
|
|
ERR("couldn't queue work item for worker thread, error was %d\n", GetLastError());
|
|
|
|
HeapFree(GetProcessHeap(), 0, packet);
|
|
|
|
status = RPC_S_OUT_OF_RESOURCES;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PKT_AUTH3:
|
|
|
|
TRACE("got auth3 packet\n");
|
|
|
|
|
|
|
|
status = process_auth3_packet(conn, &hdr->common, msg, auth_data,
|
|
|
|
auth_length);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled packet type %u\n", hdr->common.ptype);
|
2008-01-08 19:14:27 +01:00
|
|
|
break;
|
2008-01-08 13:26:31 +01:00
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:43 +01:00
|
|
|
I_RpcFree(msg->Buffer);
|
|
|
|
RPCRT4_FreeHeader(hdr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, msg);
|
|
|
|
HeapFree(GetProcessHeap(), 0, auth_data);
|
|
|
|
|
|
|
|
if (status != RPC_S_OK) {
|
|
|
|
WARN("processing packet failed with error %u\n", status);
|
|
|
|
break;
|
|
|
|
}
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
2009-12-13 22:35:43 +01:00
|
|
|
exit:
|
2012-02-14 16:19:32 +01:00
|
|
|
RPCRT4_ReleaseConnection(conn);
|
2002-10-11 19:52:37 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-25 14:28:56 +02:00
|
|
|
void RPCRT4_new_client(RpcConnection* conn)
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
2003-04-19 04:49:35 +02:00
|
|
|
HANDLE thread = CreateThread(NULL, 0, RPCRT4_io_thread, conn, 0, NULL);
|
|
|
|
if (!thread) {
|
2003-02-19 04:44:35 +01:00
|
|
|
DWORD err = GetLastError();
|
2006-11-09 23:04:48 +01:00
|
|
|
ERR("failed to create thread, error=%08x\n", err);
|
2012-02-14 16:19:32 +01:00
|
|
|
RPCRT4_ReleaseConnection(conn);
|
2003-02-19 04:44:35 +01:00
|
|
|
}
|
2003-04-19 04:49:35 +02:00
|
|
|
/* we could set conn->thread, but then we'd have to make the io_thread wait
|
|
|
|
* for that, otherwise the thread might finish, destroy the connection, and
|
|
|
|
* free the memory we'd write to before we did, causing crashes and stuff -
|
|
|
|
* so let's implement that later, when we really need conn->thread */
|
|
|
|
|
|
|
|
CloseHandle( thread );
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
2006-10-16 17:48:57 +02:00
|
|
|
static DWORD CALLBACK RPCRT4_server_thread(LPVOID the_arg)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
unsigned int count;
|
|
|
|
void *objs = NULL;
|
|
|
|
RpcServerProtseq* cps = the_arg;
|
|
|
|
RpcConnection* conn;
|
|
|
|
BOOL set_ready_event = FALSE;
|
|
|
|
|
|
|
|
TRACE("(the_arg == ^%p)\n", the_arg);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
objs = cps->ops->get_wait_array(cps, objs, &count);
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2005-02-15 16:03:26 +01:00
|
|
|
if (set_ready_event)
|
|
|
|
{
|
|
|
|
/* signal to function that changed state that we are now sync'ed */
|
2006-10-16 17:47:22 +02:00
|
|
|
SetEvent(cps->server_ready_event);
|
2005-02-15 16:03:26 +01:00
|
|
|
set_ready_event = FALSE;
|
|
|
|
}
|
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
/* start waiting */
|
2006-10-16 17:48:57 +02:00
|
|
|
res = cps->ops->wait_for_new_connection(cps, count, objs);
|
2009-03-20 17:10:42 +01:00
|
|
|
|
|
|
|
if (res == -1 || (res == 0 && !std_listen))
|
2006-10-16 17:48:57 +02:00
|
|
|
{
|
2009-03-20 17:10:42 +01:00
|
|
|
/* cleanup */
|
|
|
|
cps->ops->free_wait_array(cps, objs);
|
|
|
|
EnterCriticalSection(&cps->cs);
|
|
|
|
for (conn = cps->conn; conn; conn = conn->Next)
|
|
|
|
RPCRT4_CloseConnection(conn);
|
|
|
|
LeaveCriticalSection(&cps->cs);
|
|
|
|
|
|
|
|
if (res == 0 && !std_listen)
|
2006-10-16 17:47:22 +02:00
|
|
|
SetEvent(cps->server_ready_event);
|
2009-03-20 17:10:42 +01:00
|
|
|
break;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
2009-03-20 17:10:42 +01:00
|
|
|
else if (res == 0)
|
|
|
|
set_ready_event = TRUE;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-02-15 16:03:26 +01:00
|
|
|
/* tells the server thread that the state has changed and waits for it to
|
|
|
|
* make the changes */
|
2006-10-16 17:47:22 +02:00
|
|
|
static void RPCRT4_sync_with_server_thread(RpcServerProtseq *ps)
|
2005-02-15 16:03:26 +01:00
|
|
|
{
|
|
|
|
/* make sure we are the only thread sync'ing the server state, otherwise
|
|
|
|
* there is a race with the server thread setting an older state and setting
|
|
|
|
* the server_ready_event when the new state hasn't yet been applied */
|
2006-10-16 17:47:22 +02:00
|
|
|
WaitForSingleObject(ps->mgr_mutex, INFINITE);
|
2005-02-15 16:03:26 +01:00
|
|
|
|
2006-10-16 17:48:57 +02:00
|
|
|
ps->ops->signal_state_changed(ps);
|
|
|
|
|
2005-02-15 16:03:26 +01:00
|
|
|
/* wait for server thread to make the requested changes before returning */
|
2006-10-16 17:47:22 +02:00
|
|
|
WaitForSingleObject(ps->server_ready_event, INFINITE);
|
2005-02-15 16:03:26 +01:00
|
|
|
|
2006-10-16 17:47:22 +02:00
|
|
|
ReleaseMutex(ps->mgr_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static RPC_STATUS RPCRT4_start_listen_protseq(RpcServerProtseq *ps, BOOL auto_listen)
|
|
|
|
{
|
|
|
|
RPC_STATUS status = RPC_S_OK;
|
|
|
|
HANDLE server_thread;
|
|
|
|
|
|
|
|
EnterCriticalSection(&listen_cs);
|
|
|
|
if (ps->is_listening) goto done;
|
|
|
|
|
|
|
|
if (!ps->mgr_mutex) ps->mgr_mutex = CreateMutexW(NULL, FALSE, NULL);
|
|
|
|
if (!ps->server_ready_event) ps->server_ready_event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
server_thread = CreateThread(NULL, 0, RPCRT4_server_thread, ps, 0, NULL);
|
|
|
|
if (!server_thread)
|
|
|
|
{
|
|
|
|
status = RPC_S_OUT_OF_RESOURCES;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ps->is_listening = TRUE;
|
|
|
|
CloseHandle(server_thread);
|
|
|
|
|
|
|
|
done:
|
|
|
|
LeaveCriticalSection(&listen_cs);
|
|
|
|
return status;
|
2005-02-15 16:03:26 +01:00
|
|
|
}
|
|
|
|
|
2005-05-13 15:55:24 +02:00
|
|
|
static RPC_STATUS RPCRT4_start_listen(BOOL auto_listen)
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
2005-05-13 15:55:24 +02:00
|
|
|
RPC_STATUS status = RPC_S_ALREADY_LISTENING;
|
2006-10-16 17:47:22 +02:00
|
|
|
RpcServerProtseq *cps;
|
2005-05-13 15:55:24 +02:00
|
|
|
|
2002-10-18 05:56:56 +02:00
|
|
|
TRACE("\n");
|
2002-10-31 23:45:12 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&listen_cs);
|
2005-03-14 11:11:04 +01:00
|
|
|
if (auto_listen || (manual_listen_count++ == 0))
|
|
|
|
{
|
2005-05-13 15:55:24 +02:00
|
|
|
status = RPC_S_OK;
|
2006-10-16 17:47:22 +02:00
|
|
|
if (++listen_count == 1)
|
2005-03-14 11:11:04 +01:00
|
|
|
std_listen = TRUE;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
2005-03-19 18:05:41 +01:00
|
|
|
LeaveCriticalSection(&listen_cs);
|
2005-05-13 15:55:24 +02:00
|
|
|
|
2006-10-16 17:47:22 +02:00
|
|
|
if (std_listen)
|
|
|
|
{
|
2006-10-16 18:01:27 +02:00
|
|
|
EnterCriticalSection(&server_cs);
|
2006-10-16 17:49:29 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
|
2006-10-16 17:47:22 +02:00
|
|
|
{
|
|
|
|
status = RPCRT4_start_listen_protseq(cps, TRUE);
|
2006-10-16 17:49:29 +02:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
break;
|
2006-10-16 17:47:22 +02:00
|
|
|
|
|
|
|
/* make sure server is actually listening on the interface before
|
2006-10-16 17:49:29 +02:00
|
|
|
* returning */
|
|
|
|
RPCRT4_sync_with_server_thread(cps);
|
2006-10-16 17:47:22 +02:00
|
|
|
}
|
2006-10-16 18:01:27 +02:00
|
|
|
LeaveCriticalSection(&server_cs);
|
2006-10-16 17:47:22 +02:00
|
|
|
}
|
|
|
|
|
2005-05-13 15:55:24 +02:00
|
|
|
return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
2005-03-14 11:11:04 +01:00
|
|
|
static void RPCRT4_stop_listen(BOOL auto_listen)
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
2002-10-31 23:45:12 +01:00
|
|
|
EnterCriticalSection(&listen_cs);
|
2005-03-14 11:11:04 +01:00
|
|
|
if (auto_listen || (--manual_listen_count == 0))
|
|
|
|
{
|
|
|
|
if (listen_count != 0 && --listen_count == 0) {
|
2006-10-16 17:47:22 +02:00
|
|
|
RpcServerProtseq *cps;
|
|
|
|
|
2005-03-14 11:11:04 +01:00
|
|
|
std_listen = FALSE;
|
|
|
|
LeaveCriticalSection(&listen_cs);
|
2006-10-16 17:47:22 +02:00
|
|
|
|
2006-10-16 17:49:29 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
|
2006-10-16 17:47:22 +02:00
|
|
|
RPCRT4_sync_with_server_thread(cps);
|
2006-10-16 17:49:29 +02:00
|
|
|
|
2010-11-09 23:11:35 +01:00
|
|
|
EnterCriticalSection(&listen_cs);
|
|
|
|
if (listen_done_event) SetEvent( listen_done_event );
|
|
|
|
listen_done_event = 0;
|
|
|
|
LeaveCriticalSection(&listen_cs);
|
2005-03-14 11:11:04 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
assert(listen_count >= 0);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&listen_cs);
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
static BOOL RPCRT4_protseq_is_endpoint_registered(RpcServerProtseq *protseq, const char *endpoint)
|
2009-03-26 14:35:36 +01:00
|
|
|
{
|
|
|
|
RpcConnection *conn;
|
|
|
|
EnterCriticalSection(&protseq->cs);
|
|
|
|
for (conn = protseq->conn; conn; conn = conn->Next)
|
|
|
|
{
|
|
|
|
if (!endpoint || !strcmp(endpoint, conn->Endpoint))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&protseq->cs);
|
|
|
|
return (conn != NULL);
|
|
|
|
}
|
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
static RPC_STATUS RPCRT4_use_protseq(RpcServerProtseq* ps, const char *endpoint)
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
2006-10-16 17:47:22 +02:00
|
|
|
RPC_STATUS status;
|
|
|
|
|
2009-03-26 14:35:36 +01:00
|
|
|
EnterCriticalSection(&ps->cs);
|
|
|
|
|
|
|
|
if (RPCRT4_protseq_is_endpoint_registered(ps, endpoint))
|
|
|
|
status = RPC_S_OK;
|
|
|
|
else
|
|
|
|
status = ps->ops->open_endpoint(ps, endpoint);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ps->cs);
|
|
|
|
|
2006-10-16 17:47:22 +02:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2006-10-16 17:47:22 +02:00
|
|
|
if (std_listen)
|
|
|
|
{
|
|
|
|
status = RPCRT4_start_listen_protseq(ps, FALSE);
|
|
|
|
if (status == RPC_S_OK)
|
|
|
|
RPCRT4_sync_with_server_thread(ps);
|
|
|
|
}
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2006-10-16 17:47:22 +02:00
|
|
|
return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerInqBindings (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerInqBindings( RPC_BINDING_VECTOR** BindingVector )
|
|
|
|
{
|
|
|
|
RPC_STATUS status;
|
|
|
|
DWORD count;
|
|
|
|
RpcServerProtseq* ps;
|
2003-02-19 04:44:35 +01:00
|
|
|
RpcConnection* conn;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2002-10-18 05:56:56 +02:00
|
|
|
if (BindingVector)
|
|
|
|
TRACE("(*BindingVector == ^%p)\n", *BindingVector);
|
|
|
|
else
|
2003-11-21 00:39:18 +01:00
|
|
|
ERR("(BindingVector == NULL!!?)\n");
|
2002-10-18 05:56:56 +02:00
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
EnterCriticalSection(&server_cs);
|
2003-02-19 04:44:35 +01:00
|
|
|
/* count connections */
|
2002-10-11 19:52:37 +02:00
|
|
|
count = 0;
|
2006-10-16 17:49:29 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(ps, &protseqs, RpcServerProtseq, entry) {
|
2006-10-16 18:01:27 +02:00
|
|
|
EnterCriticalSection(&ps->cs);
|
2009-03-20 17:11:03 +01:00
|
|
|
for (conn = ps->conn; conn; conn = conn->Next)
|
2002-10-11 19:52:37 +02:00
|
|
|
count++;
|
2006-10-16 18:01:27 +02:00
|
|
|
LeaveCriticalSection(&ps->cs);
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
if (count) {
|
|
|
|
/* export bindings */
|
|
|
|
*BindingVector = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
sizeof(RPC_BINDING_VECTOR) +
|
|
|
|
sizeof(RPC_BINDING_HANDLE)*(count-1));
|
|
|
|
(*BindingVector)->Count = count;
|
|
|
|
count = 0;
|
2006-10-16 17:49:29 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(ps, &protseqs, RpcServerProtseq, entry) {
|
2006-10-16 18:01:27 +02:00
|
|
|
EnterCriticalSection(&ps->cs);
|
2009-03-20 17:11:03 +01:00
|
|
|
for (conn = ps->conn; conn; conn = conn->Next) {
|
2003-02-19 04:44:35 +01:00
|
|
|
RPCRT4_MakeBinding((RpcBinding**)&(*BindingVector)->BindingH[count],
|
|
|
|
conn);
|
2002-10-11 19:52:37 +02:00
|
|
|
count++;
|
|
|
|
}
|
2006-10-16 18:01:27 +02:00
|
|
|
LeaveCriticalSection(&ps->cs);
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
status = RPC_S_OK;
|
|
|
|
} else {
|
|
|
|
*BindingVector = NULL;
|
|
|
|
status = RPC_S_NO_BINDINGS;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&server_cs);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUseProtseqEpA (RPCRT4.@)
|
|
|
|
*/
|
2006-10-13 02:19:15 +02:00
|
|
|
RPC_STATUS WINAPI RpcServerUseProtseqEpA( RPC_CSTR Protseq, UINT MaxCalls, RPC_CSTR Endpoint, LPVOID SecurityDescriptor )
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
|
|
|
RPC_POLICY policy;
|
|
|
|
|
|
|
|
TRACE( "(%s,%u,%s,%p)\n", Protseq, MaxCalls, Endpoint, SecurityDescriptor );
|
|
|
|
|
|
|
|
/* This should provide the default behaviour */
|
|
|
|
policy.Length = sizeof( policy );
|
|
|
|
policy.EndpointFlags = 0;
|
|
|
|
policy.NICFlags = 0;
|
|
|
|
|
|
|
|
return RpcServerUseProtseqEpExA( Protseq, MaxCalls, Endpoint, SecurityDescriptor, &policy );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUseProtseqEpW (RPCRT4.@)
|
|
|
|
*/
|
2006-10-13 02:19:15 +02:00
|
|
|
RPC_STATUS WINAPI RpcServerUseProtseqEpW( RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor )
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
|
|
|
RPC_POLICY policy;
|
|
|
|
|
|
|
|
TRACE( "(%s,%u,%s,%p)\n", debugstr_w( Protseq ), MaxCalls, debugstr_w( Endpoint ), SecurityDescriptor );
|
|
|
|
|
|
|
|
/* This should provide the default behaviour */
|
|
|
|
policy.Length = sizeof( policy );
|
|
|
|
policy.EndpointFlags = 0;
|
|
|
|
policy.NICFlags = 0;
|
|
|
|
|
|
|
|
return RpcServerUseProtseqEpExW( Protseq, MaxCalls, Endpoint, SecurityDescriptor, &policy );
|
|
|
|
}
|
|
|
|
|
2006-04-21 08:38:25 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* alloc_serverprotoseq (internal)
|
2006-11-10 13:13:57 +01:00
|
|
|
*
|
|
|
|
* Must be called with server_cs held.
|
2006-04-21 08:38:25 +02:00
|
|
|
*/
|
2009-03-29 19:42:35 +02:00
|
|
|
static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, const char *Protseq, RpcServerProtseq **ps)
|
2006-04-21 08:38:25 +02:00
|
|
|
{
|
2006-10-16 17:48:57 +02:00
|
|
|
const struct protseq_ops *ops = rpcrt4_get_protseq_ops(Protseq);
|
|
|
|
|
|
|
|
if (!ops)
|
2006-11-10 12:02:04 +01:00
|
|
|
{
|
|
|
|
FIXME("protseq %s not supported\n", debugstr_a(Protseq));
|
|
|
|
return RPC_S_PROTSEQ_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ps = ops->alloc();
|
|
|
|
if (!*ps)
|
|
|
|
return RPC_S_OUT_OF_RESOURCES;
|
|
|
|
(*ps)->MaxCalls = MaxCalls;
|
2009-03-29 19:42:35 +02:00
|
|
|
(*ps)->Protseq = RPCRT4_strdupA(Protseq);
|
2006-11-10 12:02:04 +01:00
|
|
|
(*ps)->ops = ops;
|
|
|
|
(*ps)->MaxCalls = 0;
|
|
|
|
(*ps)->conn = NULL;
|
|
|
|
InitializeCriticalSection(&(*ps)->cs);
|
2011-11-14 15:10:01 +01:00
|
|
|
(*ps)->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcServerProtseq.cs");
|
2006-11-10 12:02:04 +01:00
|
|
|
(*ps)->is_listening = FALSE;
|
|
|
|
(*ps)->mgr_mutex = NULL;
|
|
|
|
(*ps)->server_ready_event = NULL;
|
|
|
|
|
2006-11-10 13:13:57 +01:00
|
|
|
list_add_head(&protseqs, &(*ps)->entry);
|
|
|
|
|
|
|
|
TRACE("new protseq %p created for %s\n", *ps, Protseq);
|
|
|
|
|
2006-11-10 12:02:04 +01:00
|
|
|
return RPC_S_OK;
|
2006-04-21 08:38:25 +02:00
|
|
|
}
|
|
|
|
|
2009-03-20 17:10:42 +01:00
|
|
|
/* must be called with server_cs held */
|
|
|
|
static void destroy_serverprotoseq(RpcServerProtseq *ps)
|
|
|
|
{
|
|
|
|
RPCRT4_strfree(ps->Protseq);
|
2011-11-14 15:10:01 +01:00
|
|
|
ps->cs.DebugInfo->Spare[0] = 0;
|
2009-03-20 17:10:42 +01:00
|
|
|
DeleteCriticalSection(&ps->cs);
|
|
|
|
CloseHandle(ps->mgr_mutex);
|
|
|
|
CloseHandle(ps->server_ready_event);
|
|
|
|
list_remove(&ps->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ps);
|
|
|
|
}
|
|
|
|
|
2006-11-10 13:13:57 +01:00
|
|
|
/* Finds a given protseq or creates a new one if one doesn't already exist */
|
2009-03-29 19:42:35 +02:00
|
|
|
static RPC_STATUS RPCRT4_get_or_create_serverprotseq(UINT MaxCalls, const char *Protseq, RpcServerProtseq **ps)
|
2006-11-10 13:13:57 +01:00
|
|
|
{
|
|
|
|
RPC_STATUS status;
|
|
|
|
RpcServerProtseq *cps;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_cs);
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
|
|
|
|
if (!strcmp(cps->Protseq, Protseq))
|
|
|
|
{
|
|
|
|
TRACE("found existing protseq object for %s\n", Protseq);
|
|
|
|
*ps = cps;
|
|
|
|
LeaveCriticalSection(&server_cs);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = alloc_serverprotoseq(MaxCalls, Protseq, ps);
|
|
|
|
|
|
|
|
LeaveCriticalSection(&server_cs);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUseProtseqEpExA (RPCRT4.@)
|
|
|
|
*/
|
2006-10-13 02:19:15 +02:00
|
|
|
RPC_STATUS WINAPI RpcServerUseProtseqEpExA( RPC_CSTR Protseq, UINT MaxCalls, RPC_CSTR Endpoint, LPVOID SecurityDescriptor,
|
2002-10-11 19:52:37 +02:00
|
|
|
PRPC_POLICY lpPolicy )
|
|
|
|
{
|
|
|
|
RpcServerProtseq* ps;
|
2006-11-10 12:02:04 +01:00
|
|
|
RPC_STATUS status;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
TRACE("(%s,%u,%s,%p,{%u,%u,%u})\n", debugstr_a((const char *)Protseq),
|
|
|
|
MaxCalls, debugstr_a((const char *)Endpoint), SecurityDescriptor,
|
2002-10-11 19:52:37 +02:00
|
|
|
lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
|
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
status = RPCRT4_get_or_create_serverprotseq(MaxCalls, (const char *)Protseq, &ps);
|
2006-11-10 12:02:04 +01:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
return RPCRT4_use_protseq(ps, (const char *)Endpoint);
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUseProtseqEpExW (RPCRT4.@)
|
|
|
|
*/
|
2006-10-13 02:19:15 +02:00
|
|
|
RPC_STATUS WINAPI RpcServerUseProtseqEpExW( RPC_WSTR Protseq, UINT MaxCalls, RPC_WSTR Endpoint, LPVOID SecurityDescriptor,
|
2002-10-11 19:52:37 +02:00
|
|
|
PRPC_POLICY lpPolicy )
|
|
|
|
{
|
|
|
|
RpcServerProtseq* ps;
|
2006-11-10 12:02:04 +01:00
|
|
|
RPC_STATUS status;
|
2009-03-29 19:42:35 +02:00
|
|
|
LPSTR ProtseqA;
|
2006-11-10 13:07:28 +01:00
|
|
|
LPSTR EndpointA;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2009-01-04 01:49:37 +01:00
|
|
|
TRACE("(%s,%u,%s,%p,{%u,%u,%u})\n", debugstr_w( Protseq ), MaxCalls,
|
2002-10-11 19:52:37 +02:00
|
|
|
debugstr_w( Endpoint ), SecurityDescriptor,
|
|
|
|
lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
|
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
ProtseqA = RPCRT4_strdupWtoA(Protseq);
|
|
|
|
status = RPCRT4_get_or_create_serverprotseq(MaxCalls, ProtseqA, &ps);
|
|
|
|
RPCRT4_strfree(ProtseqA);
|
2006-11-10 12:02:04 +01:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2006-11-10 13:07:28 +01:00
|
|
|
EndpointA = RPCRT4_strdupWtoA(Endpoint);
|
|
|
|
status = RPCRT4_use_protseq(ps, EndpointA);
|
|
|
|
RPCRT4_strfree(EndpointA);
|
|
|
|
return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
2002-10-22 01:41:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUseProtseqA (RPCRT4.@)
|
|
|
|
*/
|
2006-10-13 02:19:15 +02:00
|
|
|
RPC_STATUS WINAPI RpcServerUseProtseqA(RPC_CSTR Protseq, unsigned int MaxCalls, void *SecurityDescriptor)
|
2002-10-22 01:41:35 +02:00
|
|
|
{
|
2009-03-26 14:35:36 +01:00
|
|
|
RPC_STATUS status;
|
|
|
|
RpcServerProtseq* ps;
|
|
|
|
|
2005-08-30 10:56:35 +02:00
|
|
|
TRACE("(Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)\n", debugstr_a((char*)Protseq), MaxCalls, SecurityDescriptor);
|
2009-03-26 14:35:36 +01:00
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
status = RPCRT4_get_or_create_serverprotseq(MaxCalls, (const char *)Protseq, &ps);
|
2009-03-26 14:35:36 +01:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
return RPCRT4_use_protseq(ps, NULL);
|
2002-10-22 01:41:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUseProtseqW (RPCRT4.@)
|
|
|
|
*/
|
2006-10-13 02:19:15 +02:00
|
|
|
RPC_STATUS WINAPI RpcServerUseProtseqW(RPC_WSTR Protseq, unsigned int MaxCalls, void *SecurityDescriptor)
|
2002-10-22 01:41:35 +02:00
|
|
|
{
|
2009-03-26 14:35:36 +01:00
|
|
|
RPC_STATUS status;
|
|
|
|
RpcServerProtseq* ps;
|
2009-03-29 19:42:35 +02:00
|
|
|
LPSTR ProtseqA;
|
2009-03-26 14:35:36 +01:00
|
|
|
|
2004-01-27 01:01:43 +01:00
|
|
|
TRACE("Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)\n", debugstr_w(Protseq), MaxCalls, SecurityDescriptor);
|
2009-03-26 14:35:36 +01:00
|
|
|
|
2009-03-29 19:42:35 +02:00
|
|
|
ProtseqA = RPCRT4_strdupWtoA(Protseq);
|
|
|
|
status = RPCRT4_get_or_create_serverprotseq(MaxCalls, ProtseqA, &ps);
|
|
|
|
RPCRT4_strfree(ProtseqA);
|
2009-03-26 14:35:36 +01:00
|
|
|
if (status != RPC_S_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
return RPCRT4_use_protseq(ps, NULL);
|
2002-10-22 01:41:35 +02:00
|
|
|
}
|
|
|
|
|
2009-03-20 17:10:42 +01:00
|
|
|
void RPCRT4_destroy_all_protseqs(void)
|
|
|
|
{
|
|
|
|
RpcServerProtseq *cps, *cursor2;
|
|
|
|
|
|
|
|
if (listen_count != 0)
|
|
|
|
std_listen = FALSE;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_cs);
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(cps, cursor2, &protseqs, RpcServerProtseq, entry)
|
|
|
|
{
|
|
|
|
if (listen_count != 0)
|
|
|
|
RPCRT4_sync_with_server_thread(cps);
|
|
|
|
destroy_serverprotoseq(cps);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&server_cs);
|
2011-11-17 09:53:51 +01:00
|
|
|
DeleteCriticalSection(&server_cs);
|
|
|
|
DeleteCriticalSection(&listen_cs);
|
2009-03-20 17:10:42 +01:00
|
|
|
}
|
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerRegisterIf (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerRegisterIf( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, RPC_MGR_EPV* MgrEpv )
|
|
|
|
{
|
|
|
|
TRACE("(%p,%s,%p)\n", IfSpec, debugstr_guid(MgrTypeUuid), MgrEpv);
|
|
|
|
return RpcServerRegisterIf2( IfSpec, MgrTypeUuid, MgrEpv, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT, (UINT)-1, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerRegisterIfEx (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerRegisterIfEx( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, RPC_MGR_EPV* MgrEpv,
|
|
|
|
UINT Flags, UINT MaxCalls, RPC_IF_CALLBACK_FN* IfCallbackFn )
|
|
|
|
{
|
|
|
|
TRACE("(%p,%s,%p,%u,%u,%p)\n", IfSpec, debugstr_guid(MgrTypeUuid), MgrEpv, Flags, MaxCalls, IfCallbackFn);
|
|
|
|
return RpcServerRegisterIf2( IfSpec, MgrTypeUuid, MgrEpv, Flags, MaxCalls, (UINT)-1, IfCallbackFn );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerRegisterIf2 (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerRegisterIf2( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, RPC_MGR_EPV* MgrEpv,
|
|
|
|
UINT Flags, UINT MaxCalls, UINT MaxRpcSize, RPC_IF_CALLBACK_FN* IfCallbackFn )
|
|
|
|
{
|
2009-02-16 09:54:10 +01:00
|
|
|
PRPC_SERVER_INTERFACE If = IfSpec;
|
2002-10-11 19:52:37 +02:00
|
|
|
RpcServerInterface* sif;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%s,%p,%u,%u,%u,%p)\n", IfSpec, debugstr_guid(MgrTypeUuid), MgrEpv, Flags, MaxCalls,
|
|
|
|
MaxRpcSize, IfCallbackFn);
|
|
|
|
TRACE(" interface id: %s %d.%d\n", debugstr_guid(&If->InterfaceId.SyntaxGUID),
|
|
|
|
If->InterfaceId.SyntaxVersion.MajorVersion,
|
|
|
|
If->InterfaceId.SyntaxVersion.MinorVersion);
|
2002-10-24 01:36:05 +02:00
|
|
|
TRACE(" transfer syntax: %s %d.%d\n", debugstr_guid(&If->TransferSyntax.SyntaxGUID),
|
|
|
|
If->TransferSyntax.SyntaxVersion.MajorVersion,
|
|
|
|
If->TransferSyntax.SyntaxVersion.MinorVersion);
|
2002-10-11 19:52:37 +02:00
|
|
|
TRACE(" dispatch table: %p\n", If->DispatchTable);
|
|
|
|
if (If->DispatchTable) {
|
|
|
|
TRACE(" dispatch table count: %d\n", If->DispatchTable->DispatchTableCount);
|
|
|
|
for (i=0; i<If->DispatchTable->DispatchTableCount; i++) {
|
|
|
|
TRACE(" entry %d: %p\n", i, If->DispatchTable->DispatchTable[i]);
|
|
|
|
}
|
|
|
|
TRACE(" reserved: %ld\n", If->DispatchTable->Reserved);
|
|
|
|
}
|
|
|
|
TRACE(" protseq endpoint count: %d\n", If->RpcProtseqEndpointCount);
|
|
|
|
TRACE(" default manager epv: %p\n", If->DefaultManagerEpv);
|
|
|
|
TRACE(" interpreter info: %p\n", If->InterpreterInfo);
|
|
|
|
|
|
|
|
sif = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(RpcServerInterface));
|
|
|
|
sif->If = If;
|
2003-11-21 23:14:42 +01:00
|
|
|
if (MgrTypeUuid) {
|
2008-03-13 21:52:48 +01:00
|
|
|
sif->MgrTypeUuid = *MgrTypeUuid;
|
2003-11-21 23:14:42 +01:00
|
|
|
sif->MgrEpv = MgrEpv;
|
|
|
|
} else {
|
2002-10-11 19:52:37 +02:00
|
|
|
memset(&sif->MgrTypeUuid, 0, sizeof(UUID));
|
2003-11-21 23:14:42 +01:00
|
|
|
sif->MgrEpv = If->DefaultManagerEpv;
|
|
|
|
}
|
2002-10-11 19:52:37 +02:00
|
|
|
sif->Flags = Flags;
|
|
|
|
sif->MaxCalls = MaxCalls;
|
|
|
|
sif->MaxRpcSize = MaxRpcSize;
|
|
|
|
sif->IfCallbackFn = IfCallbackFn;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_cs);
|
2006-11-13 12:45:57 +01:00
|
|
|
list_add_head(&server_interfaces, &sif->entry);
|
2002-10-11 19:52:37 +02:00
|
|
|
LeaveCriticalSection(&server_cs);
|
|
|
|
|
2006-10-16 17:47:22 +02:00
|
|
|
if (sif->Flags & RPC_IF_AUTOLISTEN)
|
|
|
|
RPCRT4_start_listen(TRUE);
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2002-10-31 23:45:12 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUnregisterIf (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerUnregisterIf( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, UINT WaitForCallsToComplete )
|
|
|
|
{
|
2009-02-16 09:54:10 +01:00
|
|
|
PRPC_SERVER_INTERFACE If = IfSpec;
|
2006-11-13 12:46:04 +01:00
|
|
|
HANDLE event = NULL;
|
|
|
|
BOOL found = FALSE;
|
|
|
|
BOOL completed = TRUE;
|
|
|
|
RpcServerInterface *cif;
|
|
|
|
RPC_STATUS status;
|
|
|
|
|
|
|
|
TRACE("(IfSpec == (RPC_IF_HANDLE)^%p (%s), MgrTypeUuid == %s, WaitForCallsToComplete == %u)\n",
|
|
|
|
IfSpec, debugstr_guid(&If->InterfaceId.SyntaxGUID), debugstr_guid(MgrTypeUuid), WaitForCallsToComplete);
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_cs);
|
|
|
|
LIST_FOR_EACH_ENTRY(cif, &server_interfaces, RpcServerInterface, entry) {
|
2007-01-02 16:39:54 +01:00
|
|
|
if ((!IfSpec || !memcmp(&If->InterfaceId, &cif->If->InterfaceId, sizeof(RPC_SYNTAX_IDENTIFIER))) &&
|
2006-11-13 12:46:04 +01:00
|
|
|
UuidEqual(MgrTypeUuid, &cif->MgrTypeUuid, &status)) {
|
|
|
|
list_remove(&cif->entry);
|
2008-09-12 13:58:19 +02:00
|
|
|
TRACE("unregistering cif %p\n", cif);
|
2006-11-13 12:46:04 +01:00
|
|
|
if (cif->CurrentCalls) {
|
|
|
|
completed = FALSE;
|
2008-09-12 13:58:19 +02:00
|
|
|
cif->Delete = TRUE;
|
2006-11-13 12:46:04 +01:00
|
|
|
if (WaitForCallsToComplete)
|
|
|
|
cif->CallsCompletedEvent = event = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
}
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&server_cs);
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
ERR("not found for object %s\n", debugstr_guid(MgrTypeUuid));
|
|
|
|
return RPC_S_UNKNOWN_IF;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (completed)
|
|
|
|
HeapFree(GetProcessHeap(), 0, cif);
|
|
|
|
else if (event) {
|
|
|
|
/* sif will be freed when the last call is completed, so be careful not to
|
|
|
|
* touch that memory here as that could happen before we get here */
|
|
|
|
WaitForSingleObject(event, INFINITE);
|
|
|
|
CloseHandle(event);
|
|
|
|
}
|
2002-10-31 23:45:12 +01:00
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerUnregisterIfEx (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerUnregisterIfEx( RPC_IF_HANDLE IfSpec, UUID* MgrTypeUuid, int RundownContextHandles )
|
|
|
|
{
|
|
|
|
FIXME("(IfSpec == (RPC_IF_HANDLE)^%p, MgrTypeUuid == %s, RundownContextHandles == %d): stub\n",
|
|
|
|
IfSpec, debugstr_guid(MgrTypeUuid), RundownContextHandles);
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2003-11-21 23:14:42 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcObjectSetType (RPCRT4.@)
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* ObjUuid [I] "Object" UUID
|
|
|
|
* TypeUuid [I] "Type" UUID
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* RPC_S_OK The call succeeded
|
|
|
|
* RPC_S_INVALID_OBJECT The provided object (nil) is not valid
|
|
|
|
* RPC_S_ALREADY_REGISTERED The provided object is already registered
|
|
|
|
*
|
2011-08-02 22:20:32 +02:00
|
|
|
* Maps "Object" UUIDs to "Type" UUIDs. Passing the nil UUID as the type
|
2003-11-21 23:14:42 +01:00
|
|
|
* resets the mapping for the specified object UUID to nil (the default).
|
|
|
|
* The nil object is always associated with the nil type and cannot be
|
|
|
|
* reassigned. Servers can support multiple implementations on the same
|
|
|
|
* interface by registering different end-point vectors for the different
|
|
|
|
* types. There's no need to call this if a server only supports the nil
|
|
|
|
* type, as is typical.
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcObjectSetType( UUID* ObjUuid, UUID* TypeUuid )
|
|
|
|
{
|
|
|
|
RpcObjTypeMap *map = RpcObjTypeMaps, *prev = NULL;
|
|
|
|
RPC_STATUS dummy;
|
|
|
|
|
|
|
|
TRACE("(ObjUUID == %s, TypeUuid == %s).\n", debugstr_guid(ObjUuid), debugstr_guid(TypeUuid));
|
|
|
|
if ((! ObjUuid) || UuidIsNil(ObjUuid, &dummy)) {
|
|
|
|
/* nil uuid cannot be remapped */
|
|
|
|
return RPC_S_INVALID_OBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find the mapping for this object if there is one ... */
|
|
|
|
while (map) {
|
|
|
|
if (! UuidCompare(ObjUuid, &map->Object, &dummy)) break;
|
|
|
|
prev = map;
|
|
|
|
map = map->next;
|
|
|
|
}
|
|
|
|
if ((! TypeUuid) || UuidIsNil(TypeUuid, &dummy)) {
|
|
|
|
/* ... and drop it from the list */
|
|
|
|
if (map) {
|
|
|
|
if (prev)
|
|
|
|
prev->next = map->next;
|
|
|
|
else
|
|
|
|
RpcObjTypeMaps = map->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, map);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* ... , fail if we found it ... */
|
|
|
|
if (map)
|
|
|
|
return RPC_S_ALREADY_REGISTERED;
|
|
|
|
/* ... otherwise create a new one and add it in. */
|
|
|
|
map = HeapAlloc(GetProcessHeap(), 0, sizeof(RpcObjTypeMap));
|
2008-03-13 21:52:48 +01:00
|
|
|
map->Object = *ObjUuid;
|
|
|
|
map->Type = *TypeUuid;
|
2003-11-21 23:14:42 +01:00
|
|
|
map->next = NULL;
|
|
|
|
if (prev)
|
|
|
|
prev->next = map; /* prev is the last map in the linklist */
|
|
|
|
else
|
|
|
|
RpcObjTypeMaps = map;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2009-12-13 22:35:29 +01:00
|
|
|
struct rpc_server_registered_auth_info
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
TimeStamp exp;
|
|
|
|
CredHandle cred;
|
|
|
|
ULONG max_token;
|
|
|
|
USHORT auth_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo(
|
|
|
|
USHORT auth_type, CredHandle *cred, TimeStamp *exp, ULONG *max_token)
|
|
|
|
{
|
|
|
|
RPC_STATUS status = RPC_S_UNKNOWN_AUTHN_SERVICE;
|
|
|
|
struct rpc_server_registered_auth_info *auth_info;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_auth_info_cs);
|
|
|
|
LIST_FOR_EACH_ENTRY(auth_info, &server_registered_auth_info, struct rpc_server_registered_auth_info, entry)
|
|
|
|
{
|
|
|
|
if (auth_info->auth_type == auth_type)
|
|
|
|
{
|
|
|
|
*cred = auth_info->cred;
|
|
|
|
*exp = auth_info->exp;
|
|
|
|
*max_token = auth_info->max_token;
|
|
|
|
status = RPC_S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&server_auth_info_cs);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RPCRT4_ServerFreeAllRegisteredAuthInfo(void)
|
|
|
|
{
|
|
|
|
struct rpc_server_registered_auth_info *auth_info, *cursor2;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_auth_info_cs);
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(auth_info, cursor2, &server_registered_auth_info, struct rpc_server_registered_auth_info, entry)
|
|
|
|
{
|
|
|
|
FreeCredentialsHandle(&auth_info->cred);
|
|
|
|
HeapFree(GetProcessHeap(), 0, auth_info);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&server_auth_info_cs);
|
2011-11-17 09:53:51 +01:00
|
|
|
DeleteCriticalSection(&server_auth_info_cs);
|
2009-12-13 22:35:29 +01:00
|
|
|
}
|
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerRegisterAuthInfoA (RPCRT4.@)
|
|
|
|
*/
|
2007-02-06 10:18:02 +01:00
|
|
|
RPC_STATUS WINAPI RpcServerRegisterAuthInfoA( RPC_CSTR ServerPrincName, ULONG AuthnSvc, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn,
|
2002-10-11 19:52:37 +02:00
|
|
|
LPVOID Arg )
|
|
|
|
{
|
2009-12-13 22:35:29 +01:00
|
|
|
SECURITY_STATUS sec_status;
|
|
|
|
CredHandle cred;
|
|
|
|
TimeStamp exp;
|
|
|
|
ULONG package_count;
|
|
|
|
ULONG i;
|
|
|
|
PSecPkgInfoA packages;
|
|
|
|
ULONG max_token;
|
|
|
|
struct rpc_server_registered_auth_info *auth_info;
|
|
|
|
|
|
|
|
TRACE("(%s,%u,%p,%p)\n", ServerPrincName, AuthnSvc, GetKeyFn, Arg);
|
|
|
|
|
|
|
|
sec_status = EnumerateSecurityPackagesA(&package_count, &packages);
|
|
|
|
if (sec_status != SEC_E_OK)
|
|
|
|
{
|
|
|
|
ERR("EnumerateSecurityPackagesA failed with error 0x%08x\n",
|
|
|
|
sec_status);
|
|
|
|
return RPC_S_SEC_PKG_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < package_count; i++)
|
|
|
|
if (packages[i].wRPCID == AuthnSvc)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == package_count)
|
|
|
|
{
|
|
|
|
WARN("unsupported AuthnSvc %u\n", AuthnSvc);
|
|
|
|
FreeContextBuffer(packages);
|
|
|
|
return RPC_S_UNKNOWN_AUTHN_SERVICE;
|
|
|
|
}
|
|
|
|
TRACE("found package %s for service %u\n", packages[i].Name,
|
|
|
|
AuthnSvc);
|
|
|
|
sec_status = AcquireCredentialsHandleA((SEC_CHAR *)ServerPrincName,
|
|
|
|
packages[i].Name,
|
|
|
|
SECPKG_CRED_INBOUND, NULL, NULL,
|
|
|
|
NULL, NULL, &cred, &exp);
|
|
|
|
max_token = packages[i].cbMaxToken;
|
|
|
|
FreeContextBuffer(packages);
|
|
|
|
if (sec_status != SEC_E_OK)
|
|
|
|
return RPC_S_SEC_PKG_ERROR;
|
|
|
|
|
|
|
|
auth_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*auth_info));
|
|
|
|
if (!auth_info)
|
|
|
|
{
|
|
|
|
FreeCredentialsHandle(&cred);
|
|
|
|
return RPC_S_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
auth_info->exp = exp;
|
|
|
|
auth_info->cred = cred;
|
|
|
|
auth_info->max_token = max_token;
|
|
|
|
auth_info->auth_type = AuthnSvc;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_auth_info_cs);
|
|
|
|
list_add_tail(&server_registered_auth_info, &auth_info->entry);
|
|
|
|
LeaveCriticalSection(&server_auth_info_cs);
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerRegisterAuthInfoW (RPCRT4.@)
|
|
|
|
*/
|
2007-02-06 10:18:02 +01:00
|
|
|
RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG AuthnSvc, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn,
|
2002-10-11 19:52:37 +02:00
|
|
|
LPVOID Arg )
|
|
|
|
{
|
2009-12-13 22:35:29 +01:00
|
|
|
SECURITY_STATUS sec_status;
|
|
|
|
CredHandle cred;
|
|
|
|
TimeStamp exp;
|
|
|
|
ULONG package_count;
|
|
|
|
ULONG i;
|
|
|
|
PSecPkgInfoW packages;
|
|
|
|
ULONG max_token;
|
|
|
|
struct rpc_server_registered_auth_info *auth_info;
|
|
|
|
|
|
|
|
TRACE("(%s,%u,%p,%p)\n", debugstr_w(ServerPrincName), AuthnSvc, GetKeyFn, Arg);
|
|
|
|
|
|
|
|
sec_status = EnumerateSecurityPackagesW(&package_count, &packages);
|
|
|
|
if (sec_status != SEC_E_OK)
|
|
|
|
{
|
|
|
|
ERR("EnumerateSecurityPackagesW failed with error 0x%08x\n",
|
|
|
|
sec_status);
|
|
|
|
return RPC_S_SEC_PKG_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < package_count; i++)
|
|
|
|
if (packages[i].wRPCID == AuthnSvc)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == package_count)
|
|
|
|
{
|
|
|
|
WARN("unsupported AuthnSvc %u\n", AuthnSvc);
|
|
|
|
FreeContextBuffer(packages);
|
|
|
|
return RPC_S_UNKNOWN_AUTHN_SERVICE;
|
|
|
|
}
|
|
|
|
TRACE("found package %s for service %u\n", debugstr_w(packages[i].Name),
|
|
|
|
AuthnSvc);
|
|
|
|
sec_status = AcquireCredentialsHandleW((SEC_WCHAR *)ServerPrincName,
|
|
|
|
packages[i].Name,
|
|
|
|
SECPKG_CRED_INBOUND, NULL, NULL,
|
|
|
|
NULL, NULL, &cred, &exp);
|
|
|
|
max_token = packages[i].cbMaxToken;
|
|
|
|
FreeContextBuffer(packages);
|
|
|
|
if (sec_status != SEC_E_OK)
|
|
|
|
return RPC_S_SEC_PKG_ERROR;
|
|
|
|
|
|
|
|
auth_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*auth_info));
|
|
|
|
if (!auth_info)
|
|
|
|
{
|
|
|
|
FreeCredentialsHandle(&cred);
|
|
|
|
return RPC_S_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
auth_info->exp = exp;
|
|
|
|
auth_info->cred = cred;
|
|
|
|
auth_info->max_token = max_token;
|
|
|
|
auth_info->auth_type = AuthnSvc;
|
|
|
|
|
|
|
|
EnterCriticalSection(&server_auth_info_cs);
|
|
|
|
list_add_tail(&server_registered_auth_info, &auth_info->entry);
|
|
|
|
LeaveCriticalSection(&server_auth_info_cs);
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
2012-05-09 12:06:29 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* RpcServerInqDefaultPrincNameA (rpcrt4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameA(ULONG AuthnSvc, RPC_CSTR *PrincName)
|
|
|
|
{
|
|
|
|
RPC_STATUS ret;
|
|
|
|
RPC_WSTR principalW;
|
|
|
|
|
|
|
|
TRACE("%u, %p\n", AuthnSvc, PrincName);
|
|
|
|
|
|
|
|
if ((ret = RpcServerInqDefaultPrincNameW( AuthnSvc, &principalW )) == RPC_S_OK)
|
|
|
|
{
|
|
|
|
if (!(*PrincName = (RPC_CSTR)RPCRT4_strdupWtoA( principalW ))) return RPC_S_OUT_OF_MEMORY;
|
|
|
|
RpcStringFreeW( &principalW );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* RpcServerInqDefaultPrincNameW (rpcrt4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS RPC_ENTRY RpcServerInqDefaultPrincNameW(ULONG AuthnSvc, RPC_WSTR *PrincName)
|
|
|
|
{
|
|
|
|
ULONG len = 0;
|
|
|
|
|
|
|
|
FIXME("%u, %p\n", AuthnSvc, PrincName);
|
|
|
|
|
|
|
|
if (AuthnSvc != RPC_C_AUTHN_WINNT) return RPC_S_UNKNOWN_AUTHN_SERVICE;
|
|
|
|
|
|
|
|
GetUserNameExW( NameSamCompatible, NULL, &len );
|
|
|
|
if (GetLastError() != ERROR_MORE_DATA) return RPC_S_INTERNAL_ERROR;
|
|
|
|
|
|
|
|
if (!(*PrincName = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
|
|
|
|
return RPC_S_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
GetUserNameExW( NameSamCompatible, *PrincName, &len );
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcServerListen (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcServerListen( UINT MinimumCallThreads, UINT MaxCalls, UINT DontWait )
|
|
|
|
{
|
2006-10-16 17:47:22 +02:00
|
|
|
RPC_STATUS status = RPC_S_OK;
|
2005-05-13 15:55:24 +02:00
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
TRACE("(%u,%u,%u)\n", MinimumCallThreads, MaxCalls, DontWait);
|
|
|
|
|
2006-10-16 17:49:29 +02:00
|
|
|
if (list_empty(&protseqs))
|
2002-10-11 19:52:37 +02:00
|
|
|
return RPC_S_NO_PROTSEQS_REGISTERED;
|
|
|
|
|
2005-05-13 15:55:24 +02:00
|
|
|
status = RPCRT4_start_listen(FALSE);
|
2002-10-31 23:45:12 +01:00
|
|
|
|
2005-05-13 15:55:24 +02:00
|
|
|
if (DontWait || (status != RPC_S_OK)) return status;
|
2002-10-11 19:52:37 +02:00
|
|
|
|
2002-10-18 05:56:56 +02:00
|
|
|
return RpcMgmtWaitServerListen();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtServerWaitListen (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
|
|
|
|
{
|
2010-11-09 23:11:35 +01:00
|
|
|
HANDLE event;
|
|
|
|
|
2005-05-13 15:55:24 +02:00
|
|
|
TRACE("()\n");
|
2002-10-31 23:45:12 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&listen_cs);
|
|
|
|
|
2005-05-13 15:55:24 +02:00
|
|
|
if (!std_listen) {
|
|
|
|
LeaveCriticalSection(&listen_cs);
|
|
|
|
return RPC_S_NOT_LISTENING;
|
|
|
|
}
|
2010-11-09 23:11:35 +01:00
|
|
|
if (listen_done_event) {
|
|
|
|
LeaveCriticalSection(&listen_cs);
|
|
|
|
return RPC_S_ALREADY_LISTENING;
|
|
|
|
}
|
|
|
|
event = CreateEventW( NULL, TRUE, FALSE, NULL );
|
|
|
|
listen_done_event = event;
|
|
|
|
|
2002-10-31 23:45:12 +01:00
|
|
|
LeaveCriticalSection(&listen_cs);
|
|
|
|
|
2010-11-09 23:11:35 +01:00
|
|
|
TRACE( "waiting for server calls to finish\n" );
|
|
|
|
WaitForSingleObject( event, INFINITE );
|
|
|
|
TRACE( "done waiting\n" );
|
2006-04-20 12:44:53 +02:00
|
|
|
|
2010-11-09 23:11:35 +01:00
|
|
|
CloseHandle( event );
|
2005-05-13 15:55:24 +02:00
|
|
|
return RPC_S_OK;
|
2002-10-11 19:52:37 +02:00
|
|
|
}
|
|
|
|
|
2002-10-31 23:45:12 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtStopServerListening (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtStopServerListening ( RPC_BINDING_HANDLE Binding )
|
|
|
|
{
|
|
|
|
TRACE("(Binding == (RPC_BINDING_HANDLE)^%p)\n", Binding);
|
|
|
|
|
|
|
|
if (Binding) {
|
|
|
|
FIXME("client-side invocation not implemented.\n");
|
|
|
|
return RPC_S_WRONG_KIND_OF_BINDING;
|
|
|
|
}
|
|
|
|
|
2005-03-14 11:11:04 +01:00
|
|
|
RPCRT4_stop_listen(FALSE);
|
2002-10-31 23:45:12 +01:00
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-21 13:39:38 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtEnableIdleCleanup (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtEnableIdleCleanup(void)
|
|
|
|
{
|
|
|
|
FIXME("(): stub\n");
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2002-10-11 19:52:37 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* I_RpcServerStartListening (RPCRT4.@)
|
|
|
|
*/
|
2004-09-03 03:04:05 +02:00
|
|
|
RPC_STATUS WINAPI I_RpcServerStartListening( HWND hWnd )
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
|
|
|
FIXME( "(%p): stub\n", hWnd );
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* I_RpcServerStopListening (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI I_RpcServerStopListening( void )
|
|
|
|
{
|
|
|
|
FIXME( "(): stub\n" );
|
|
|
|
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* I_RpcWindowProc (RPCRT4.@)
|
|
|
|
*/
|
2002-11-01 02:47:43 +01:00
|
|
|
UINT WINAPI I_RpcWindowProc( void *hWnd, UINT Message, UINT wParam, ULONG lParam )
|
2002-10-11 19:52:37 +02:00
|
|
|
{
|
2006-11-09 23:04:48 +01:00
|
|
|
FIXME( "(%p,%08x,%08x,%08x): stub\n", hWnd, Message, wParam, lParam );
|
2002-10-11 19:52:37 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-04-19 10:25:02 +02:00
|
|
|
|
2006-04-19 10:25:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtInqIfIds (RPCRT4.@)
|
|
|
|
*/
|
2006-04-19 10:25:02 +02:00
|
|
|
RPC_STATUS WINAPI RpcMgmtInqIfIds(RPC_BINDING_HANDLE Binding, RPC_IF_ID_VECTOR **IfIdVector)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%p): stub\n", Binding, IfIdVector);
|
|
|
|
return RPC_S_INVALID_BINDING;
|
|
|
|
}
|
2006-04-19 10:25:21 +02:00
|
|
|
|
2008-09-23 13:30:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtInqStats (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtInqStats(RPC_BINDING_HANDLE Binding, RPC_STATS_VECTOR **Statistics)
|
|
|
|
{
|
|
|
|
RPC_STATS_VECTOR *stats;
|
|
|
|
|
|
|
|
FIXME("(%p,%p)\n", Binding, Statistics);
|
|
|
|
|
|
|
|
if ((stats = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_STATS_VECTOR))))
|
|
|
|
{
|
|
|
|
stats->Count = 1;
|
|
|
|
stats->Stats[0] = 0;
|
|
|
|
*Statistics = stats;
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
return RPC_S_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtStatsVectorFree (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtStatsVectorFree(RPC_STATS_VECTOR **StatsVector)
|
|
|
|
{
|
|
|
|
FIXME("(%p)\n", StatsVector);
|
|
|
|
|
|
|
|
if (StatsVector)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, *StatsVector);
|
|
|
|
*StatsVector = NULL;
|
|
|
|
}
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2006-04-19 10:25:21 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtEpEltInqBegin (RPCRT4.@)
|
|
|
|
*/
|
2007-02-06 10:18:02 +01:00
|
|
|
RPC_STATUS WINAPI RpcMgmtEpEltInqBegin(RPC_BINDING_HANDLE Binding, ULONG InquiryType,
|
|
|
|
RPC_IF_ID *IfId, ULONG VersOption, UUID *ObjectUuid, RPC_EP_INQ_HANDLE* InquiryContext)
|
2006-04-19 10:25:21 +02:00
|
|
|
{
|
2007-02-06 10:18:02 +01:00
|
|
|
FIXME("(%p,%u,%p,%u,%p,%p): stub\n",
|
2006-04-19 10:25:21 +02:00
|
|
|
Binding, InquiryType, IfId, VersOption, ObjectUuid, InquiryContext);
|
|
|
|
return RPC_S_INVALID_BINDING;
|
|
|
|
}
|
2006-05-18 12:06:15 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
2006-06-30 12:07:07 +02:00
|
|
|
* RpcMgmtIsServerListening (RPCRT4.@)
|
2006-05-18 12:06:15 +02:00
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtIsServerListening(RPC_BINDING_HANDLE Binding)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", Binding);
|
|
|
|
return RPC_S_INVALID_BINDING;
|
|
|
|
}
|
2006-06-30 12:07:07 +02:00
|
|
|
|
2010-12-15 09:08:42 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtSetAuthorizationFn (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_STATUS WINAPI RpcMgmtSetAuthorizationFn(RPC_MGMT_AUTHORIZATION_FN fn)
|
|
|
|
{
|
|
|
|
FIXME("(%p): stub\n", fn);
|
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-30 12:07:07 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RpcMgmtSetServerStackSize (RPCRT4.@)
|
|
|
|
*/
|
2007-02-06 10:18:02 +01:00
|
|
|
RPC_STATUS WINAPI RpcMgmtSetServerStackSize(ULONG ThreadStackSize)
|
2006-06-30 12:07:07 +02:00
|
|
|
{
|
2007-02-06 10:18:02 +01:00
|
|
|
FIXME("(0x%x): stub\n", ThreadStackSize);
|
2006-06-30 12:07:07 +02:00
|
|
|
return RPC_S_OK;
|
|
|
|
}
|
2007-12-17 19:20:41 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* I_RpcGetCurrentCallHandle (RPCRT4.@)
|
|
|
|
*/
|
|
|
|
RPC_BINDING_HANDLE WINAPI I_RpcGetCurrentCallHandle(void)
|
|
|
|
{
|
2007-12-18 15:55:57 +01:00
|
|
|
TRACE("\n");
|
|
|
|
return RPCRT4_GetThreadCurrentCallHandle();
|
2007-12-17 19:20:41 +01:00
|
|
|
}
|