4 * Copyright 2001 Ove Kåven, TransGaming Technologies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "wine/debug.h"
37 #include "wine/exception.h"
39 #include "rpc_server.h"
43 #define MAX_THREADS 128
45 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
47 typedef struct _RpcPacket
49 struct _RpcPacket
* next
;
50 struct _RpcConnection
* conn
;
55 static RpcServerProtseq
* protseqs
;
56 static RpcServerInterface
* ifs
;
58 static CRITICAL_SECTION server_cs
= CRITICAL_SECTION_INIT("RpcServer");
59 static CRITICAL_SECTION listen_cs
= CRITICAL_SECTION_INIT("RpcListen");
60 static BOOL std_listen
;
61 static LONG listen_count
= -1;
62 static HANDLE mgr_event
, server_thread
;
64 static CRITICAL_SECTION spacket_cs
= CRITICAL_SECTION_INIT("RpcServerPacket");
65 static RpcPacket
* spacket_head
;
66 static RpcPacket
* spacket_tail
;
67 static HANDLE server_sem
;
69 static DWORD worker_count
, worker_free
, worker_tls
;
71 static RpcServerInterface
* RPCRT4_find_interface(UUID
* object
, UUID
* if_id
)
74 RpcServerInterface
* cif
= NULL
;
77 /* FIXME: object -> MgrType */
78 EnterCriticalSection(&server_cs
);
81 if (UuidEqual(if_id
, &cif
->If
->InterfaceId
.SyntaxGUID
, &status
) &&
82 UuidEqual(MgrType
, &cif
->MgrTypeUuid
, &status
) &&
83 (std_listen
|| (cif
->Flags
& RPC_IF_AUTOLISTEN
))) break;
86 LeaveCriticalSection(&server_cs
);
90 static void RPCRT4_push_packet(RpcPacket
* packet
)
93 EnterCriticalSection(&spacket_cs
);
94 if (spacket_tail
) spacket_tail
->next
= packet
;
96 spacket_head
= packet
;
97 spacket_tail
= packet
;
99 LeaveCriticalSection(&spacket_cs
);
102 static RpcPacket
* RPCRT4_pop_packet(void)
105 EnterCriticalSection(&spacket_cs
);
106 packet
= spacket_head
;
108 spacket_head
= packet
->next
;
109 if (!spacket_head
) spacket_tail
= NULL
;
111 LeaveCriticalSection(&spacket_cs
);
112 if (packet
) packet
->next
= NULL
;
116 static WINE_EXCEPTION_FILTER(rpc_filter
)
119 msg
= TlsGetValue(worker_tls
);
120 I_RpcFreeBuffer(msg
);
121 msg
->RpcFlags
|= WINE_RPCFLAG_EXCEPTION
;
122 msg
->BufferLength
= sizeof(DWORD
);
124 *(DWORD
*)msg
->Buffer
= GetExceptionCode();
125 return EXCEPTION_EXECUTE_HANDLER
;
128 static void RPCRT4_process_packet(RpcConnection
* conn
, RpcPktHdr
* hdr
, void* buf
)
132 RpcServerInterface
* sif
;
133 RPC_DISPATCH_FUNCTION func
;
135 TlsSetValue(worker_tls
, &msg
);
136 memset(&msg
, 0, sizeof(msg
));
137 msg
.BufferLength
= hdr
->len
;
139 sif
= RPCRT4_find_interface(&hdr
->object
, &hdr
->if_id
);
141 TRACE("packet received for interface %s\n", debugstr_guid(&hdr
->if_id
));
142 msg
.RpcInterfaceInformation
= sif
->If
;
143 /* create temporary binding for dispatch */
144 RPCRT4_MakeBinding(&pbind
, conn
);
145 RPCRT4_SetBindingObject(pbind
, &hdr
->object
);
146 msg
.Handle
= (RPC_BINDING_HANDLE
)pbind
;
148 switch (hdr
->ptype
) {
150 /* find dispatch function */
151 msg
.ProcNum
= hdr
->opnum
;
152 if (sif
->Flags
& RPC_IF_OLE
) {
153 /* native ole32 always gives us a dispatch table with a single entry
154 * (I assume that's a wrapper for IRpcStubBuffer::Invoke) */
155 func
= *sif
->If
->DispatchTable
->DispatchTable
;
157 if (msg
.ProcNum
>= sif
->If
->DispatchTable
->DispatchTableCount
) {
158 ERR("invalid procnum\n");
161 func
= sif
->If
->DispatchTable
->DispatchTable
[msg
.ProcNum
];
164 /* put in the drep. FIXME: is this more universally applicable?
165 perhaps we should move this outward... */
166 msg
.DataRepresentation
=
167 MAKELONG( MAKEWORD(hdr
->drep
[0], hdr
->drep
[1]),
168 MAKEWORD(hdr
->drep
[2], 0));
172 if (func
) func(&msg
);
173 } __EXCEPT(rpc_filter
) {
174 /* failure packet was created in rpc_filter */
175 TRACE("exception caught, returning failure packet\n");
178 /* send response packet */
182 ERR("unknown packet type\n");
186 RPCRT4_DestroyBinding(pbind
);
188 msg
.RpcInterfaceInformation
= NULL
;
191 ERR("got RPC packet to unregistered interface %s\n", debugstr_guid(&hdr
->if_id
));
195 if (msg
.Buffer
== buf
) msg
.Buffer
= NULL
;
196 TRACE("freeing Buffer=%p\n", buf
);
197 HeapFree(GetProcessHeap(), 0, buf
);
198 I_RpcFreeBuffer(&msg
);
200 TlsSetValue(worker_tls
, NULL
);
203 static DWORD CALLBACK
RPCRT4_worker_thread(LPVOID the_arg
)
209 /* idle timeout after 5s */
210 obj
= WaitForSingleObject(server_sem
, 5000);
211 if (obj
== WAIT_TIMEOUT
) {
212 /* if another idle thread exist, self-destruct */
213 if (worker_free
> 1) break;
216 pkt
= RPCRT4_pop_packet();
218 InterlockedDecrement(&worker_free
);
220 RPCRT4_process_packet(pkt
->conn
, &pkt
->hdr
, pkt
->buf
);
221 HeapFree(GetProcessHeap(), 0, pkt
);
222 /* try to grab another packet here without waiting
223 * on the semaphore, in case it hits max */
224 pkt
= RPCRT4_pop_packet();
226 /* decrement semaphore */
227 WaitForSingleObject(server_sem
, 0);
229 InterlockedIncrement(&worker_free
);
231 InterlockedDecrement(&worker_free
);
232 InterlockedDecrement(&worker_count
);
236 static void RPCRT4_create_worker_if_needed(void)
238 if (!worker_free
&& worker_count
< MAX_THREADS
) {
240 InterlockedIncrement(&worker_count
);
241 InterlockedIncrement(&worker_free
);
242 thread
= CreateThread(NULL
, 0, RPCRT4_worker_thread
, NULL
, 0, NULL
);
243 if (thread
) CloseHandle(thread
);
245 InterlockedDecrement(&worker_free
);
246 InterlockedDecrement(&worker_count
);
251 static DWORD CALLBACK
RPCRT4_io_thread(LPVOID the_arg
)
253 RpcConnection
* conn
= (RpcConnection
*)the_arg
;
259 TRACE("(%p)\n", conn
);
262 /* read packet header */
263 #ifdef OVERLAPPED_WORKS
264 if (!ReadFile(conn
->conn
, &hdr
, sizeof(hdr
), &dwRead
, &conn
->ovl
)) {
265 DWORD err
= GetLastError();
266 if (err
!= ERROR_IO_PENDING
) {
267 TRACE("connection lost, error=%08lx\n", err
);
270 if (!GetOverlappedResult(conn
->conn
, &conn
->ovl
, &dwRead
, TRUE
)) break;
273 if (!ReadFile(conn
->conn
, &hdr
, sizeof(hdr
), &dwRead
, NULL
)) {
274 TRACE("connection lost, error=%08lx\n", GetLastError());
278 if (dwRead
!= sizeof(hdr
)) {
279 if (dwRead
) TRACE("protocol error: <hdrsz == %d, dwRead == %lu>\n", sizeof(hdr
), dwRead
);
283 /* read packet body */
284 buf
= HeapAlloc(GetProcessHeap(), 0, hdr
.len
);
285 TRACE("receiving payload=%d\n", hdr
.len
);
286 if (!hdr
.len
) dwRead
= 0; else
287 #ifdef OVERLAPPED_WORKS
288 if (!ReadFile(conn
->conn
, buf
, hdr
.len
, &dwRead
, &conn
->ovl
)) {
289 DWORD err
= GetLastError();
290 if (err
!= ERROR_IO_PENDING
) {
291 TRACE("connection lost, error=%08lx\n", err
);
294 if (!GetOverlappedResult(conn
->conn
, &conn
->ovl
, &dwRead
, TRUE
)) break;
297 if (!ReadFile(conn
->conn
, buf
, hdr
.len
, &dwRead
, NULL
)) {
298 TRACE("connection lost, error=%08lx\n", GetLastError());
302 if (dwRead
!= hdr
.len
) {
303 TRACE("protocol error: <bodylen == %d, dwRead == %lu>\n", hdr
.len
, dwRead
);
308 RPCRT4_process_packet(conn
, &hdr
, buf
);
310 packet
= HeapAlloc(GetProcessHeap(), 0, sizeof(RpcPacket
));
314 RPCRT4_create_worker_if_needed();
315 RPCRT4_push_packet(packet
);
316 ReleaseSemaphore(server_sem
, 1, NULL
);
320 if (buf
) HeapFree(GetProcessHeap(), 0, buf
);
321 RPCRT4_DestroyConnection(conn
);
325 static void RPCRT4_new_client(RpcConnection
* conn
)
327 HANDLE thread
= CreateThread(NULL
, 0, RPCRT4_io_thread
, conn
, 0, NULL
);
329 DWORD err
= GetLastError();
330 ERR("failed to create thread, error=%08lx\n", err
);
331 RPCRT4_DestroyConnection(conn
);
333 /* we could set conn->thread, but then we'd have to make the io_thread wait
334 * for that, otherwise the thread might finish, destroy the connection, and
335 * free the memory we'd write to before we did, causing crashes and stuff -
336 * so let's implement that later, when we really need conn->thread */
338 CloseHandle( thread
);
341 static DWORD CALLBACK
RPCRT4_server_thread(LPVOID the_arg
)
343 HANDLE m_event
= mgr_event
, b_handle
;
346 RpcServerProtseq
* cps
;
348 RpcConnection
* cconn
;
351 EnterCriticalSection(&server_cs
);
352 /* open and count connections */
358 RPCRT4_OpenConnection(conn
);
359 if (conn
->ovl
.hEvent
) count
++;
364 /* make array of connections */
365 objs
= HeapReAlloc(GetProcessHeap(), 0, objs
, count
*sizeof(HANDLE
));
372 if (conn
->ovl
.hEvent
) objs
[count
++] = conn
->ovl
.hEvent
;
377 LeaveCriticalSection(&server_cs
);
380 res
= WaitForMultipleObjects(count
, objs
, FALSE
, INFINITE
);
381 if (res
== WAIT_OBJECT_0
) {
383 if (!std_listen
) break;
385 else if (res
== WAIT_FAILED
) {
386 ERR("wait failed\n");
389 b_handle
= objs
[res
- WAIT_OBJECT_0
];
390 /* find which connection got a RPC */
391 EnterCriticalSection(&server_cs
);
397 if (conn
->ovl
.hEvent
== b_handle
) break;
404 if (conn
) RPCRT4_SpawnConnection(&cconn
, conn
);
405 LeaveCriticalSection(&server_cs
);
407 ERR("failed to locate connection for handle %p\n", b_handle
);
409 if (cconn
) RPCRT4_new_client(cconn
);
412 HeapFree(GetProcessHeap(), 0, objs
);
413 EnterCriticalSection(&server_cs
);
414 /* close connections */
419 RPCRT4_CloseConnection(conn
);
424 LeaveCriticalSection(&server_cs
);
428 static void RPCRT4_start_listen(void)
432 EnterCriticalSection(&listen_cs
);
433 if (! ++listen_count
) {
434 if (!mgr_event
) mgr_event
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
435 if (!server_sem
) server_sem
= CreateSemaphoreA(NULL
, 0, MAX_THREADS
, NULL
);
436 if (!worker_tls
) worker_tls
= TlsAlloc();
438 server_thread
= CreateThread(NULL
, 0, RPCRT4_server_thread
, NULL
, 0, NULL
);
439 LeaveCriticalSection(&listen_cs
);
441 LeaveCriticalSection(&listen_cs
);
446 static void RPCRT4_stop_listen(void)
448 EnterCriticalSection(&listen_cs
);
449 if (listen_count
== -1)
450 LeaveCriticalSection(&listen_cs
);
451 else if (--listen_count
== -1) {
453 LeaveCriticalSection(&listen_cs
);
456 LeaveCriticalSection(&listen_cs
);
457 assert(listen_count
> -2);
460 static RPC_STATUS
RPCRT4_use_protseq(RpcServerProtseq
* ps
)
462 RPCRT4_CreateConnection(&ps
->conn
, TRUE
, ps
->Protseq
, NULL
, ps
->Endpoint
, NULL
, NULL
);
464 EnterCriticalSection(&server_cs
);
467 LeaveCriticalSection(&server_cs
);
469 if (std_listen
) SetEvent(mgr_event
);
474 /***********************************************************************
475 * RpcServerInqBindings (RPCRT4.@)
477 RPC_STATUS WINAPI
RpcServerInqBindings( RPC_BINDING_VECTOR
** BindingVector
)
481 RpcServerProtseq
* ps
;
485 TRACE("(*BindingVector == ^%p)\n", *BindingVector
);
487 ERR("(BindingVector == ^null!!?)\n");
489 EnterCriticalSection(&server_cs
);
490 /* count connections */
502 /* export bindings */
503 *BindingVector
= HeapAlloc(GetProcessHeap(), 0,
504 sizeof(RPC_BINDING_VECTOR
) +
505 sizeof(RPC_BINDING_HANDLE
)*(count
-1));
506 (*BindingVector
)->Count
= count
;
512 RPCRT4_MakeBinding((RpcBinding
**)&(*BindingVector
)->BindingH
[count
],
521 *BindingVector
= NULL
;
522 status
= RPC_S_NO_BINDINGS
;
524 LeaveCriticalSection(&server_cs
);
528 /***********************************************************************
529 * RpcServerUseProtseqEpA (RPCRT4.@)
531 RPC_STATUS WINAPI
RpcServerUseProtseqEpA( LPSTR Protseq
, UINT MaxCalls
, LPSTR Endpoint
, LPVOID SecurityDescriptor
)
535 TRACE( "(%s,%u,%s,%p)\n", Protseq
, MaxCalls
, Endpoint
, SecurityDescriptor
);
537 /* This should provide the default behaviour */
538 policy
.Length
= sizeof( policy
);
539 policy
.EndpointFlags
= 0;
542 return RpcServerUseProtseqEpExA( Protseq
, MaxCalls
, Endpoint
, SecurityDescriptor
, &policy
);
545 /***********************************************************************
546 * RpcServerUseProtseqEpW (RPCRT4.@)
548 RPC_STATUS WINAPI
RpcServerUseProtseqEpW( LPWSTR Protseq
, UINT MaxCalls
, LPWSTR Endpoint
, LPVOID SecurityDescriptor
)
552 TRACE( "(%s,%u,%s,%p)\n", debugstr_w( Protseq
), MaxCalls
, debugstr_w( Endpoint
), SecurityDescriptor
);
554 /* This should provide the default behaviour */
555 policy
.Length
= sizeof( policy
);
556 policy
.EndpointFlags
= 0;
559 return RpcServerUseProtseqEpExW( Protseq
, MaxCalls
, Endpoint
, SecurityDescriptor
, &policy
);
562 /***********************************************************************
563 * RpcServerUseProtseqEpExA (RPCRT4.@)
565 RPC_STATUS WINAPI
RpcServerUseProtseqEpExA( LPSTR Protseq
, UINT MaxCalls
, LPSTR Endpoint
, LPVOID SecurityDescriptor
,
566 PRPC_POLICY lpPolicy
)
568 RpcServerProtseq
* ps
;
570 TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_a( Protseq
), MaxCalls
,
571 debugstr_a( Endpoint
), SecurityDescriptor
,
572 lpPolicy
->Length
, lpPolicy
->EndpointFlags
, lpPolicy
->NICFlags
);
574 ps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(RpcServerProtseq
));
575 ps
->MaxCalls
= MaxCalls
;
576 ps
->Protseq
= RPCRT4_strdupA(Protseq
);
577 ps
->Endpoint
= RPCRT4_strdupA(Endpoint
);
579 return RPCRT4_use_protseq(ps
);
582 /***********************************************************************
583 * RpcServerUseProtseqEpExW (RPCRT4.@)
585 RPC_STATUS WINAPI
RpcServerUseProtseqEpExW( LPWSTR Protseq
, UINT MaxCalls
, LPWSTR Endpoint
, LPVOID SecurityDescriptor
,
586 PRPC_POLICY lpPolicy
)
588 RpcServerProtseq
* ps
;
590 TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_w( Protseq
), MaxCalls
,
591 debugstr_w( Endpoint
), SecurityDescriptor
,
592 lpPolicy
->Length
, lpPolicy
->EndpointFlags
, lpPolicy
->NICFlags
);
594 ps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(RpcServerProtseq
));
595 ps
->MaxCalls
= MaxCalls
;
596 /* FIXME: Did Ove have these next two as RPCRT4_strdupW for a reason? */
597 ps
->Protseq
= RPCRT4_strdupWtoA(Protseq
);
598 ps
->Endpoint
= RPCRT4_strdupWtoA(Endpoint
);
600 return RPCRT4_use_protseq(ps
);
603 /***********************************************************************
604 * RpcServerUseProtseqA (RPCRT4.@)
606 RPC_STATUS WINAPI
RpcServerUseProtseqA(LPSTR Protseq
, unsigned int MaxCalls
, void *SecurityDescriptor
)
608 TRACE("(Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)", debugstr_a(Protseq
), MaxCalls
, SecurityDescriptor
);
609 return RpcServerUseProtseqEpA(Protseq
, MaxCalls
, NULL
, SecurityDescriptor
);
612 /***********************************************************************
613 * RpcServerUseProtseqW (RPCRT4.@)
615 RPC_STATUS WINAPI
RpcServerUseProtseqW(LPWSTR Protseq
, unsigned int MaxCalls
, void *SecurityDescriptor
)
617 TRACE("Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)", debugstr_w(Protseq
), MaxCalls
, SecurityDescriptor
);
618 return RpcServerUseProtseqEpW(Protseq
, MaxCalls
, NULL
, SecurityDescriptor
);
621 /***********************************************************************
622 * RpcServerRegisterIf (RPCRT4.@)
624 RPC_STATUS WINAPI
RpcServerRegisterIf( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, RPC_MGR_EPV
* MgrEpv
)
626 TRACE("(%p,%s,%p)\n", IfSpec
, debugstr_guid(MgrTypeUuid
), MgrEpv
);
627 return RpcServerRegisterIf2( IfSpec
, MgrTypeUuid
, MgrEpv
, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, (UINT
)-1, NULL
);
630 /***********************************************************************
631 * RpcServerRegisterIfEx (RPCRT4.@)
633 RPC_STATUS WINAPI
RpcServerRegisterIfEx( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, RPC_MGR_EPV
* MgrEpv
,
634 UINT Flags
, UINT MaxCalls
, RPC_IF_CALLBACK_FN
* IfCallbackFn
)
636 TRACE("(%p,%s,%p,%u,%u,%p)\n", IfSpec
, debugstr_guid(MgrTypeUuid
), MgrEpv
, Flags
, MaxCalls
, IfCallbackFn
);
637 return RpcServerRegisterIf2( IfSpec
, MgrTypeUuid
, MgrEpv
, Flags
, MaxCalls
, (UINT
)-1, IfCallbackFn
);
640 /***********************************************************************
641 * RpcServerRegisterIf2 (RPCRT4.@)
643 RPC_STATUS WINAPI
RpcServerRegisterIf2( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, RPC_MGR_EPV
* MgrEpv
,
644 UINT Flags
, UINT MaxCalls
, UINT MaxRpcSize
, RPC_IF_CALLBACK_FN
* IfCallbackFn
)
646 PRPC_SERVER_INTERFACE If
= (PRPC_SERVER_INTERFACE
)IfSpec
;
647 RpcServerInterface
* sif
;
650 TRACE("(%p,%s,%p,%u,%u,%u,%p)\n", IfSpec
, debugstr_guid(MgrTypeUuid
), MgrEpv
, Flags
, MaxCalls
,
651 MaxRpcSize
, IfCallbackFn
);
652 TRACE(" interface id: %s %d.%d\n", debugstr_guid(&If
->InterfaceId
.SyntaxGUID
),
653 If
->InterfaceId
.SyntaxVersion
.MajorVersion
,
654 If
->InterfaceId
.SyntaxVersion
.MinorVersion
);
655 TRACE(" transfer syntax: %s %d.%d\n", debugstr_guid(&If
->TransferSyntax
.SyntaxGUID
),
656 If
->TransferSyntax
.SyntaxVersion
.MajorVersion
,
657 If
->TransferSyntax
.SyntaxVersion
.MinorVersion
);
658 TRACE(" dispatch table: %p\n", If
->DispatchTable
);
659 if (If
->DispatchTable
) {
660 TRACE(" dispatch table count: %d\n", If
->DispatchTable
->DispatchTableCount
);
661 for (i
=0; i
<If
->DispatchTable
->DispatchTableCount
; i
++) {
662 TRACE(" entry %d: %p\n", i
, If
->DispatchTable
->DispatchTable
[i
]);
664 TRACE(" reserved: %ld\n", If
->DispatchTable
->Reserved
);
666 TRACE(" protseq endpoint count: %d\n", If
->RpcProtseqEndpointCount
);
667 TRACE(" default manager epv: %p\n", If
->DefaultManagerEpv
);
668 TRACE(" interpreter info: %p\n", If
->InterpreterInfo
);
669 TRACE(" flags: %08x\n", If
->Flags
);
671 sif
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(RpcServerInterface
));
674 memcpy(&sif
->MgrTypeUuid
, MgrTypeUuid
, sizeof(UUID
));
676 memset(&sif
->MgrTypeUuid
, 0, sizeof(UUID
));
677 sif
->MgrEpv
= MgrEpv
;
679 sif
->MaxCalls
= MaxCalls
;
680 sif
->MaxRpcSize
= MaxRpcSize
;
681 sif
->IfCallbackFn
= IfCallbackFn
;
683 EnterCriticalSection(&server_cs
);
686 LeaveCriticalSection(&server_cs
);
688 if (sif
->Flags
& RPC_IF_AUTOLISTEN
) {
689 /* well, start listening, I think... */
690 RPCRT4_start_listen();
696 /***********************************************************************
697 * RpcServerUnregisterIf (RPCRT4.@)
699 RPC_STATUS WINAPI
RpcServerUnregisterIf( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, UINT WaitForCallsToComplete
)
701 FIXME("(IfSpec == (RPC_IF_HANDLE)^%p, MgrTypeUuid == %s, WaitForCallsToComplete == %u): stub\n",
702 IfSpec
, debugstr_guid(MgrTypeUuid
), WaitForCallsToComplete
);
707 /***********************************************************************
708 * RpcServerUnregisterIfEx (RPCRT4.@)
710 RPC_STATUS WINAPI
RpcServerUnregisterIfEx( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, int RundownContextHandles
)
712 FIXME("(IfSpec == (RPC_IF_HANDLE)^%p, MgrTypeUuid == %s, RundownContextHandles == %d): stub\n",
713 IfSpec
, debugstr_guid(MgrTypeUuid
), RundownContextHandles
);
718 /***********************************************************************
719 * RpcServerRegisterAuthInfoA (RPCRT4.@)
721 RPC_STATUS WINAPI
RpcServerRegisterAuthInfoA( LPSTR ServerPrincName
, ULONG AuthnSvc
, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn
,
724 FIXME( "(%s,%lu,%p,%p): stub\n", ServerPrincName
, AuthnSvc
, GetKeyFn
, Arg
);
726 return RPC_S_UNKNOWN_AUTHN_SERVICE
; /* We don't know any authentication services */
729 /***********************************************************************
730 * RpcServerRegisterAuthInfoW (RPCRT4.@)
732 RPC_STATUS WINAPI
RpcServerRegisterAuthInfoW( LPWSTR ServerPrincName
, ULONG AuthnSvc
, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn
,
735 FIXME( "(%s,%lu,%p,%p): stub\n", debugstr_w( ServerPrincName
), AuthnSvc
, GetKeyFn
, Arg
);
737 return RPC_S_UNKNOWN_AUTHN_SERVICE
; /* We don't know any authentication services */
740 /***********************************************************************
741 * RpcServerListen (RPCRT4.@)
743 RPC_STATUS WINAPI
RpcServerListen( UINT MinimumCallThreads
, UINT MaxCalls
, UINT DontWait
)
745 TRACE("(%u,%u,%u)\n", MinimumCallThreads
, MaxCalls
, DontWait
);
748 return RPC_S_NO_PROTSEQS_REGISTERED
;
750 EnterCriticalSection(&listen_cs
);
753 LeaveCriticalSection(&listen_cs
);
754 return RPC_S_ALREADY_LISTENING
;
757 RPCRT4_start_listen();
759 LeaveCriticalSection(&listen_cs
);
761 if (DontWait
) return RPC_S_OK
;
763 return RpcMgmtWaitServerListen();
766 /***********************************************************************
767 * RpcMgmtServerWaitListen (RPCRT4.@)
769 RPC_STATUS WINAPI
RpcMgmtWaitServerListen( void )
771 RPC_STATUS rslt
= RPC_S_OK
;
775 EnterCriticalSection(&listen_cs
);
778 if ( (rslt
= RpcServerListen(1, 0, TRUE
)) != RPC_S_OK
) {
779 LeaveCriticalSection(&listen_cs
);
783 LeaveCriticalSection(&listen_cs
);
786 WaitForSingleObject(mgr_event
, INFINITE
);
788 Sleep(100); /* don't spin violently */
789 TRACE("spinning.\n");
796 /***********************************************************************
797 * RpcMgmtStopServerListening (RPCRT4.@)
799 RPC_STATUS WINAPI
RpcMgmtStopServerListening ( RPC_BINDING_HANDLE Binding
)
801 TRACE("(Binding == (RPC_BINDING_HANDLE)^%p)\n", Binding
);
804 FIXME("client-side invocation not implemented.\n");
805 return RPC_S_WRONG_KIND_OF_BINDING
;
809 EnterCriticalSection(&listen_cs
);
811 RPCRT4_stop_listen();
812 LeaveCriticalSection(&listen_cs
);
817 /***********************************************************************
818 * I_RpcServerStartListening (RPCRT4.@)
820 RPC_STATUS WINAPI
I_RpcServerStartListening( void* hWnd
)
822 FIXME( "(%p): stub\n", hWnd
);
827 /***********************************************************************
828 * I_RpcServerStopListening (RPCRT4.@)
830 RPC_STATUS WINAPI
I_RpcServerStopListening( void )
832 FIXME( "(): stub\n" );
837 /***********************************************************************
838 * I_RpcWindowProc (RPCRT4.@)
840 UINT WINAPI
I_RpcWindowProc( void *hWnd
, UINT Message
, UINT wParam
, ULONG lParam
)
842 FIXME( "(%p,%08x,%08x,%08lx): stub\n", hWnd
, Message
, wParam
, lParam
);