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
38 #include "wine/debug.h"
39 #include "wine/exception.h"
41 #include "rpc_server.h"
45 #define MAX_THREADS 128
47 WINE_DEFAULT_DEBUG_CHANNEL(ole
);
49 typedef struct _RpcPacket
51 struct _RpcPacket
* next
;
52 struct _RpcConnection
* conn
;
57 static RpcServerProtseq
* protseqs
;
58 static RpcServerInterface
* ifs
;
60 static CRITICAL_SECTION server_cs
;
61 static CRITICAL_SECTION_DEBUG server_cs_debug
=
64 { &server_cs_debug
.ProcessLocksList
, &server_cs_debug
.ProcessLocksList
},
65 0, 0, { 0, (DWORD
)(__FILE__
": server_cs") }
67 static CRITICAL_SECTION server_cs
= { &server_cs_debug
, -1, 0, 0, 0, 0 };
69 static CRITICAL_SECTION listen_cs
;
70 static CRITICAL_SECTION_DEBUG listen_cs_debug
=
73 { &listen_cs_debug
.ProcessLocksList
, &listen_cs_debug
.ProcessLocksList
},
74 0, 0, { 0, (DWORD
)(__FILE__
": listen_cs") }
76 static CRITICAL_SECTION listen_cs
= { &listen_cs_debug
, -1, 0, 0, 0, 0 };
78 static BOOL std_listen
;
79 static LONG listen_count
= -1;
80 static HANDLE mgr_event
, server_thread
;
82 static CRITICAL_SECTION spacket_cs
;
83 static CRITICAL_SECTION_DEBUG spacket_cs_debug
=
86 { &spacket_cs_debug
.ProcessLocksList
, &spacket_cs_debug
.ProcessLocksList
},
87 0, 0, { 0, (DWORD
)(__FILE__
": spacket_cs") }
89 static CRITICAL_SECTION spacket_cs
= { &spacket_cs_debug
, -1, 0, 0, 0, 0 };
91 static RpcPacket
* spacket_head
;
92 static RpcPacket
* spacket_tail
;
93 static HANDLE server_sem
;
95 static DWORD worker_count
, worker_free
, worker_tls
;
97 static RpcServerInterface
* RPCRT4_find_interface(UUID
* object
, UUID
* if_id
)
100 RpcServerInterface
* cif
= NULL
;
103 /* FIXME: object -> MgrType */
104 EnterCriticalSection(&server_cs
);
107 if (UuidEqual(if_id
, &cif
->If
->InterfaceId
.SyntaxGUID
, &status
) &&
108 UuidEqual(MgrType
, &cif
->MgrTypeUuid
, &status
) &&
109 (std_listen
|| (cif
->Flags
& RPC_IF_AUTOLISTEN
))) break;
112 LeaveCriticalSection(&server_cs
);
116 static void RPCRT4_push_packet(RpcPacket
* packet
)
119 EnterCriticalSection(&spacket_cs
);
120 if (spacket_tail
) spacket_tail
->next
= packet
;
122 spacket_head
= packet
;
123 spacket_tail
= packet
;
125 LeaveCriticalSection(&spacket_cs
);
128 static RpcPacket
* RPCRT4_pop_packet(void)
131 EnterCriticalSection(&spacket_cs
);
132 packet
= spacket_head
;
134 spacket_head
= packet
->next
;
135 if (!spacket_head
) spacket_tail
= NULL
;
137 LeaveCriticalSection(&spacket_cs
);
138 if (packet
) packet
->next
= NULL
;
142 static WINE_EXCEPTION_FILTER(rpc_filter
)
145 msg
= TlsGetValue(worker_tls
);
146 I_RpcFreeBuffer(msg
);
147 msg
->RpcFlags
|= WINE_RPCFLAG_EXCEPTION
;
148 msg
->BufferLength
= sizeof(DWORD
);
150 *(DWORD
*)msg
->Buffer
= GetExceptionCode();
151 return EXCEPTION_EXECUTE_HANDLER
;
154 static void RPCRT4_process_packet(RpcConnection
* conn
, RpcPktHdr
* hdr
, void* buf
)
158 RpcServerInterface
* sif
;
159 RPC_DISPATCH_FUNCTION func
;
161 TlsSetValue(worker_tls
, &msg
);
162 memset(&msg
, 0, sizeof(msg
));
163 msg
.BufferLength
= hdr
->len
;
165 sif
= RPCRT4_find_interface(&hdr
->object
, &hdr
->if_id
);
167 TRACE("packet received for interface %s\n", debugstr_guid(&hdr
->if_id
));
168 msg
.RpcInterfaceInformation
= sif
->If
;
169 /* create temporary binding for dispatch */
170 RPCRT4_MakeBinding(&pbind
, conn
);
171 RPCRT4_SetBindingObject(pbind
, &hdr
->object
);
172 msg
.Handle
= (RPC_BINDING_HANDLE
)pbind
;
174 switch (hdr
->ptype
) {
176 /* find dispatch function */
177 msg
.ProcNum
= hdr
->opnum
;
178 if (sif
->Flags
& RPC_IF_OLE
) {
179 /* native ole32 always gives us a dispatch table with a single entry
180 * (I assume that's a wrapper for IRpcStubBuffer::Invoke) */
181 func
= *sif
->If
->DispatchTable
->DispatchTable
;
183 if (msg
.ProcNum
>= sif
->If
->DispatchTable
->DispatchTableCount
) {
184 ERR("invalid procnum\n");
187 func
= sif
->If
->DispatchTable
->DispatchTable
[msg
.ProcNum
];
190 /* put in the drep. FIXME: is this more universally applicable?
191 perhaps we should move this outward... */
192 msg
.DataRepresentation
=
193 MAKELONG( MAKEWORD(hdr
->drep
[0], hdr
->drep
[1]),
194 MAKEWORD(hdr
->drep
[2], 0));
198 if (func
) func(&msg
);
199 } __EXCEPT(rpc_filter
) {
200 /* failure packet was created in rpc_filter */
201 TRACE("exception caught, returning failure packet\n");
204 /* send response packet */
208 ERR("unknown packet type\n");
212 RPCRT4_DestroyBinding(pbind
);
214 msg
.RpcInterfaceInformation
= NULL
;
217 ERR("got RPC packet to unregistered interface %s\n", debugstr_guid(&hdr
->if_id
));
221 if (msg
.Buffer
== buf
) msg
.Buffer
= NULL
;
222 TRACE("freeing Buffer=%p\n", buf
);
223 HeapFree(GetProcessHeap(), 0, buf
);
224 I_RpcFreeBuffer(&msg
);
226 TlsSetValue(worker_tls
, NULL
);
229 static DWORD CALLBACK
RPCRT4_worker_thread(LPVOID the_arg
)
235 /* idle timeout after 5s */
236 obj
= WaitForSingleObject(server_sem
, 5000);
237 if (obj
== WAIT_TIMEOUT
) {
238 /* if another idle thread exist, self-destruct */
239 if (worker_free
> 1) break;
242 pkt
= RPCRT4_pop_packet();
244 InterlockedDecrement(&worker_free
);
246 RPCRT4_process_packet(pkt
->conn
, &pkt
->hdr
, pkt
->buf
);
247 HeapFree(GetProcessHeap(), 0, pkt
);
248 /* try to grab another packet here without waiting
249 * on the semaphore, in case it hits max */
250 pkt
= RPCRT4_pop_packet();
252 /* decrement semaphore */
253 WaitForSingleObject(server_sem
, 0);
255 InterlockedIncrement(&worker_free
);
257 InterlockedDecrement(&worker_free
);
258 InterlockedDecrement(&worker_count
);
262 static void RPCRT4_create_worker_if_needed(void)
264 if (!worker_free
&& worker_count
< MAX_THREADS
) {
266 InterlockedIncrement(&worker_count
);
267 InterlockedIncrement(&worker_free
);
268 thread
= CreateThread(NULL
, 0, RPCRT4_worker_thread
, NULL
, 0, NULL
);
269 if (thread
) CloseHandle(thread
);
271 InterlockedDecrement(&worker_free
);
272 InterlockedDecrement(&worker_count
);
277 static DWORD CALLBACK
RPCRT4_io_thread(LPVOID the_arg
)
279 RpcConnection
* conn
= (RpcConnection
*)the_arg
;
285 TRACE("(%p)\n", conn
);
288 /* read packet header */
289 #ifdef OVERLAPPED_WORKS
290 if (!ReadFile(conn
->conn
, &hdr
, sizeof(hdr
), &dwRead
, &conn
->ovl
)) {
291 DWORD err
= GetLastError();
292 if (err
!= ERROR_IO_PENDING
) {
293 TRACE("connection lost, error=%08lx\n", err
);
296 if (!GetOverlappedResult(conn
->conn
, &conn
->ovl
, &dwRead
, TRUE
)) break;
299 if (!ReadFile(conn
->conn
, &hdr
, sizeof(hdr
), &dwRead
, NULL
)) {
300 TRACE("connection lost, error=%08lx\n", GetLastError());
304 if (dwRead
!= sizeof(hdr
)) {
305 if (dwRead
) TRACE("protocol error: <hdrsz == %d, dwRead == %lu>\n", sizeof(hdr
), dwRead
);
309 /* read packet body */
310 buf
= HeapAlloc(GetProcessHeap(), 0, hdr
.len
);
311 TRACE("receiving payload=%d\n", hdr
.len
);
312 if (!hdr
.len
) dwRead
= 0; else
313 #ifdef OVERLAPPED_WORKS
314 if (!ReadFile(conn
->conn
, buf
, hdr
.len
, &dwRead
, &conn
->ovl
)) {
315 DWORD err
= GetLastError();
316 if (err
!= ERROR_IO_PENDING
) {
317 TRACE("connection lost, error=%08lx\n", err
);
320 if (!GetOverlappedResult(conn
->conn
, &conn
->ovl
, &dwRead
, TRUE
)) break;
323 if (!ReadFile(conn
->conn
, buf
, hdr
.len
, &dwRead
, NULL
)) {
324 TRACE("connection lost, error=%08lx\n", GetLastError());
328 if (dwRead
!= hdr
.len
) {
329 TRACE("protocol error: <bodylen == %d, dwRead == %lu>\n", hdr
.len
, dwRead
);
334 RPCRT4_process_packet(conn
, &hdr
, buf
);
336 packet
= HeapAlloc(GetProcessHeap(), 0, sizeof(RpcPacket
));
340 RPCRT4_create_worker_if_needed();
341 RPCRT4_push_packet(packet
);
342 ReleaseSemaphore(server_sem
, 1, NULL
);
346 if (buf
) HeapFree(GetProcessHeap(), 0, buf
);
347 RPCRT4_DestroyConnection(conn
);
351 static void RPCRT4_new_client(RpcConnection
* conn
)
353 HANDLE thread
= CreateThread(NULL
, 0, RPCRT4_io_thread
, conn
, 0, NULL
);
355 DWORD err
= GetLastError();
356 ERR("failed to create thread, error=%08lx\n", err
);
357 RPCRT4_DestroyConnection(conn
);
359 /* we could set conn->thread, but then we'd have to make the io_thread wait
360 * for that, otherwise the thread might finish, destroy the connection, and
361 * free the memory we'd write to before we did, causing crashes and stuff -
362 * so let's implement that later, when we really need conn->thread */
364 CloseHandle( thread
);
367 static DWORD CALLBACK
RPCRT4_server_thread(LPVOID the_arg
)
369 HANDLE m_event
= mgr_event
, b_handle
;
372 RpcServerProtseq
* cps
;
374 RpcConnection
* cconn
;
377 EnterCriticalSection(&server_cs
);
378 /* open and count connections */
384 RPCRT4_OpenConnection(conn
);
385 if (conn
->ovl
.hEvent
) count
++;
390 /* make array of connections */
391 objs
= HeapReAlloc(GetProcessHeap(), 0, objs
, count
*sizeof(HANDLE
));
398 if (conn
->ovl
.hEvent
) objs
[count
++] = conn
->ovl
.hEvent
;
403 LeaveCriticalSection(&server_cs
);
406 res
= WaitForMultipleObjects(count
, objs
, FALSE
, INFINITE
);
407 if (res
== WAIT_OBJECT_0
) {
409 if (!std_listen
) break;
411 else if (res
== WAIT_FAILED
) {
412 ERR("wait failed\n");
415 b_handle
= objs
[res
- WAIT_OBJECT_0
];
416 /* find which connection got a RPC */
417 EnterCriticalSection(&server_cs
);
423 if (conn
->ovl
.hEvent
== b_handle
) break;
430 if (conn
) RPCRT4_SpawnConnection(&cconn
, conn
);
431 LeaveCriticalSection(&server_cs
);
433 ERR("failed to locate connection for handle %p\n", b_handle
);
435 if (cconn
) RPCRT4_new_client(cconn
);
438 HeapFree(GetProcessHeap(), 0, objs
);
439 EnterCriticalSection(&server_cs
);
440 /* close connections */
445 RPCRT4_CloseConnection(conn
);
450 LeaveCriticalSection(&server_cs
);
454 static void RPCRT4_start_listen(void)
458 EnterCriticalSection(&listen_cs
);
459 if (! ++listen_count
) {
460 if (!mgr_event
) mgr_event
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
461 if (!server_sem
) server_sem
= CreateSemaphoreA(NULL
, 0, MAX_THREADS
, NULL
);
462 if (!worker_tls
) worker_tls
= TlsAlloc();
464 server_thread
= CreateThread(NULL
, 0, RPCRT4_server_thread
, NULL
, 0, NULL
);
465 LeaveCriticalSection(&listen_cs
);
467 LeaveCriticalSection(&listen_cs
);
472 static void RPCRT4_stop_listen(void)
474 EnterCriticalSection(&listen_cs
);
475 if (listen_count
== -1)
476 LeaveCriticalSection(&listen_cs
);
477 else if (--listen_count
== -1) {
479 LeaveCriticalSection(&listen_cs
);
482 LeaveCriticalSection(&listen_cs
);
483 assert(listen_count
> -2);
486 static RPC_STATUS
RPCRT4_use_protseq(RpcServerProtseq
* ps
)
488 RPCRT4_CreateConnection(&ps
->conn
, TRUE
, ps
->Protseq
, NULL
, ps
->Endpoint
, NULL
, NULL
);
490 EnterCriticalSection(&server_cs
);
493 LeaveCriticalSection(&server_cs
);
495 if (std_listen
) SetEvent(mgr_event
);
500 /***********************************************************************
501 * RpcServerInqBindings (RPCRT4.@)
503 RPC_STATUS WINAPI
RpcServerInqBindings( RPC_BINDING_VECTOR
** BindingVector
)
507 RpcServerProtseq
* ps
;
511 TRACE("(*BindingVector == ^%p)\n", *BindingVector
);
513 ERR("(BindingVector == ^null!!?)\n");
515 EnterCriticalSection(&server_cs
);
516 /* count connections */
528 /* export bindings */
529 *BindingVector
= HeapAlloc(GetProcessHeap(), 0,
530 sizeof(RPC_BINDING_VECTOR
) +
531 sizeof(RPC_BINDING_HANDLE
)*(count
-1));
532 (*BindingVector
)->Count
= count
;
538 RPCRT4_MakeBinding((RpcBinding
**)&(*BindingVector
)->BindingH
[count
],
547 *BindingVector
= NULL
;
548 status
= RPC_S_NO_BINDINGS
;
550 LeaveCriticalSection(&server_cs
);
554 /***********************************************************************
555 * RpcServerUseProtseqEpA (RPCRT4.@)
557 RPC_STATUS WINAPI
RpcServerUseProtseqEpA( LPSTR Protseq
, UINT MaxCalls
, LPSTR Endpoint
, LPVOID SecurityDescriptor
)
561 TRACE( "(%s,%u,%s,%p)\n", Protseq
, MaxCalls
, Endpoint
, SecurityDescriptor
);
563 /* This should provide the default behaviour */
564 policy
.Length
= sizeof( policy
);
565 policy
.EndpointFlags
= 0;
568 return RpcServerUseProtseqEpExA( Protseq
, MaxCalls
, Endpoint
, SecurityDescriptor
, &policy
);
571 /***********************************************************************
572 * RpcServerUseProtseqEpW (RPCRT4.@)
574 RPC_STATUS WINAPI
RpcServerUseProtseqEpW( LPWSTR Protseq
, UINT MaxCalls
, LPWSTR Endpoint
, LPVOID SecurityDescriptor
)
578 TRACE( "(%s,%u,%s,%p)\n", debugstr_w( Protseq
), MaxCalls
, debugstr_w( Endpoint
), SecurityDescriptor
);
580 /* This should provide the default behaviour */
581 policy
.Length
= sizeof( policy
);
582 policy
.EndpointFlags
= 0;
585 return RpcServerUseProtseqEpExW( Protseq
, MaxCalls
, Endpoint
, SecurityDescriptor
, &policy
);
588 /***********************************************************************
589 * RpcServerUseProtseqEpExA (RPCRT4.@)
591 RPC_STATUS WINAPI
RpcServerUseProtseqEpExA( LPSTR Protseq
, UINT MaxCalls
, LPSTR Endpoint
, LPVOID SecurityDescriptor
,
592 PRPC_POLICY lpPolicy
)
594 RpcServerProtseq
* ps
;
596 TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_a( Protseq
), MaxCalls
,
597 debugstr_a( Endpoint
), SecurityDescriptor
,
598 lpPolicy
->Length
, lpPolicy
->EndpointFlags
, lpPolicy
->NICFlags
);
600 ps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(RpcServerProtseq
));
601 ps
->MaxCalls
= MaxCalls
;
602 ps
->Protseq
= RPCRT4_strdupA(Protseq
);
603 ps
->Endpoint
= RPCRT4_strdupA(Endpoint
);
605 return RPCRT4_use_protseq(ps
);
608 /***********************************************************************
609 * RpcServerUseProtseqEpExW (RPCRT4.@)
611 RPC_STATUS WINAPI
RpcServerUseProtseqEpExW( LPWSTR Protseq
, UINT MaxCalls
, LPWSTR Endpoint
, LPVOID SecurityDescriptor
,
612 PRPC_POLICY lpPolicy
)
614 RpcServerProtseq
* ps
;
616 TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_w( Protseq
), MaxCalls
,
617 debugstr_w( Endpoint
), SecurityDescriptor
,
618 lpPolicy
->Length
, lpPolicy
->EndpointFlags
, lpPolicy
->NICFlags
);
620 ps
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(RpcServerProtseq
));
621 ps
->MaxCalls
= MaxCalls
;
622 /* FIXME: Did Ove have these next two as RPCRT4_strdupW for a reason? */
623 ps
->Protseq
= RPCRT4_strdupWtoA(Protseq
);
624 ps
->Endpoint
= RPCRT4_strdupWtoA(Endpoint
);
626 return RPCRT4_use_protseq(ps
);
629 /***********************************************************************
630 * RpcServerUseProtseqA (RPCRT4.@)
632 RPC_STATUS WINAPI
RpcServerUseProtseqA(LPSTR Protseq
, unsigned int MaxCalls
, void *SecurityDescriptor
)
634 TRACE("(Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)", debugstr_a(Protseq
), MaxCalls
, SecurityDescriptor
);
635 return RpcServerUseProtseqEpA(Protseq
, MaxCalls
, NULL
, SecurityDescriptor
);
638 /***********************************************************************
639 * RpcServerUseProtseqW (RPCRT4.@)
641 RPC_STATUS WINAPI
RpcServerUseProtseqW(LPWSTR Protseq
, unsigned int MaxCalls
, void *SecurityDescriptor
)
643 TRACE("Protseq == %s, MaxCalls == %d, SecurityDescriptor == ^%p)", debugstr_w(Protseq
), MaxCalls
, SecurityDescriptor
);
644 return RpcServerUseProtseqEpW(Protseq
, MaxCalls
, NULL
, SecurityDescriptor
);
647 /***********************************************************************
648 * RpcServerRegisterIf (RPCRT4.@)
650 RPC_STATUS WINAPI
RpcServerRegisterIf( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, RPC_MGR_EPV
* MgrEpv
)
652 TRACE("(%p,%s,%p)\n", IfSpec
, debugstr_guid(MgrTypeUuid
), MgrEpv
);
653 return RpcServerRegisterIf2( IfSpec
, MgrTypeUuid
, MgrEpv
, 0, RPC_C_LISTEN_MAX_CALLS_DEFAULT
, (UINT
)-1, NULL
);
656 /***********************************************************************
657 * RpcServerRegisterIfEx (RPCRT4.@)
659 RPC_STATUS WINAPI
RpcServerRegisterIfEx( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, RPC_MGR_EPV
* MgrEpv
,
660 UINT Flags
, UINT MaxCalls
, RPC_IF_CALLBACK_FN
* IfCallbackFn
)
662 TRACE("(%p,%s,%p,%u,%u,%p)\n", IfSpec
, debugstr_guid(MgrTypeUuid
), MgrEpv
, Flags
, MaxCalls
, IfCallbackFn
);
663 return RpcServerRegisterIf2( IfSpec
, MgrTypeUuid
, MgrEpv
, Flags
, MaxCalls
, (UINT
)-1, IfCallbackFn
);
666 /***********************************************************************
667 * RpcServerRegisterIf2 (RPCRT4.@)
669 RPC_STATUS WINAPI
RpcServerRegisterIf2( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, RPC_MGR_EPV
* MgrEpv
,
670 UINT Flags
, UINT MaxCalls
, UINT MaxRpcSize
, RPC_IF_CALLBACK_FN
* IfCallbackFn
)
672 PRPC_SERVER_INTERFACE If
= (PRPC_SERVER_INTERFACE
)IfSpec
;
673 RpcServerInterface
* sif
;
676 TRACE("(%p,%s,%p,%u,%u,%u,%p)\n", IfSpec
, debugstr_guid(MgrTypeUuid
), MgrEpv
, Flags
, MaxCalls
,
677 MaxRpcSize
, IfCallbackFn
);
678 TRACE(" interface id: %s %d.%d\n", debugstr_guid(&If
->InterfaceId
.SyntaxGUID
),
679 If
->InterfaceId
.SyntaxVersion
.MajorVersion
,
680 If
->InterfaceId
.SyntaxVersion
.MinorVersion
);
681 TRACE(" transfer syntax: %s %d.%d\n", debugstr_guid(&If
->TransferSyntax
.SyntaxGUID
),
682 If
->TransferSyntax
.SyntaxVersion
.MajorVersion
,
683 If
->TransferSyntax
.SyntaxVersion
.MinorVersion
);
684 TRACE(" dispatch table: %p\n", If
->DispatchTable
);
685 if (If
->DispatchTable
) {
686 TRACE(" dispatch table count: %d\n", If
->DispatchTable
->DispatchTableCount
);
687 for (i
=0; i
<If
->DispatchTable
->DispatchTableCount
; i
++) {
688 TRACE(" entry %d: %p\n", i
, If
->DispatchTable
->DispatchTable
[i
]);
690 TRACE(" reserved: %ld\n", If
->DispatchTable
->Reserved
);
692 TRACE(" protseq endpoint count: %d\n", If
->RpcProtseqEndpointCount
);
693 TRACE(" default manager epv: %p\n", If
->DefaultManagerEpv
);
694 TRACE(" interpreter info: %p\n", If
->InterpreterInfo
);
695 TRACE(" flags: %08x\n", If
->Flags
);
697 sif
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(RpcServerInterface
));
700 memcpy(&sif
->MgrTypeUuid
, MgrTypeUuid
, sizeof(UUID
));
702 memset(&sif
->MgrTypeUuid
, 0, sizeof(UUID
));
703 sif
->MgrEpv
= MgrEpv
;
705 sif
->MaxCalls
= MaxCalls
;
706 sif
->MaxRpcSize
= MaxRpcSize
;
707 sif
->IfCallbackFn
= IfCallbackFn
;
709 EnterCriticalSection(&server_cs
);
712 LeaveCriticalSection(&server_cs
);
714 if (sif
->Flags
& RPC_IF_AUTOLISTEN
) {
715 /* well, start listening, I think... */
716 RPCRT4_start_listen();
722 /***********************************************************************
723 * RpcServerUnregisterIf (RPCRT4.@)
725 RPC_STATUS WINAPI
RpcServerUnregisterIf( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, UINT WaitForCallsToComplete
)
727 FIXME("(IfSpec == (RPC_IF_HANDLE)^%p, MgrTypeUuid == %s, WaitForCallsToComplete == %u): stub\n",
728 IfSpec
, debugstr_guid(MgrTypeUuid
), WaitForCallsToComplete
);
733 /***********************************************************************
734 * RpcServerUnregisterIfEx (RPCRT4.@)
736 RPC_STATUS WINAPI
RpcServerUnregisterIfEx( RPC_IF_HANDLE IfSpec
, UUID
* MgrTypeUuid
, int RundownContextHandles
)
738 FIXME("(IfSpec == (RPC_IF_HANDLE)^%p, MgrTypeUuid == %s, RundownContextHandles == %d): stub\n",
739 IfSpec
, debugstr_guid(MgrTypeUuid
), RundownContextHandles
);
744 /***********************************************************************
745 * RpcServerRegisterAuthInfoA (RPCRT4.@)
747 RPC_STATUS WINAPI
RpcServerRegisterAuthInfoA( LPSTR ServerPrincName
, ULONG AuthnSvc
, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn
,
750 FIXME( "(%s,%lu,%p,%p): stub\n", ServerPrincName
, AuthnSvc
, GetKeyFn
, Arg
);
752 return RPC_S_UNKNOWN_AUTHN_SERVICE
; /* We don't know any authentication services */
755 /***********************************************************************
756 * RpcServerRegisterAuthInfoW (RPCRT4.@)
758 RPC_STATUS WINAPI
RpcServerRegisterAuthInfoW( LPWSTR ServerPrincName
, ULONG AuthnSvc
, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn
,
761 FIXME( "(%s,%lu,%p,%p): stub\n", debugstr_w( ServerPrincName
), AuthnSvc
, GetKeyFn
, Arg
);
763 return RPC_S_UNKNOWN_AUTHN_SERVICE
; /* We don't know any authentication services */
766 /***********************************************************************
767 * RpcServerListen (RPCRT4.@)
769 RPC_STATUS WINAPI
RpcServerListen( UINT MinimumCallThreads
, UINT MaxCalls
, UINT DontWait
)
771 TRACE("(%u,%u,%u)\n", MinimumCallThreads
, MaxCalls
, DontWait
);
774 return RPC_S_NO_PROTSEQS_REGISTERED
;
776 EnterCriticalSection(&listen_cs
);
779 LeaveCriticalSection(&listen_cs
);
780 return RPC_S_ALREADY_LISTENING
;
783 RPCRT4_start_listen();
785 LeaveCriticalSection(&listen_cs
);
787 if (DontWait
) return RPC_S_OK
;
789 return RpcMgmtWaitServerListen();
792 /***********************************************************************
793 * RpcMgmtServerWaitListen (RPCRT4.@)
795 RPC_STATUS WINAPI
RpcMgmtWaitServerListen( void )
797 RPC_STATUS rslt
= RPC_S_OK
;
801 EnterCriticalSection(&listen_cs
);
804 if ( (rslt
= RpcServerListen(1, 0, TRUE
)) != RPC_S_OK
) {
805 LeaveCriticalSection(&listen_cs
);
809 LeaveCriticalSection(&listen_cs
);
812 WaitForSingleObject(mgr_event
, INFINITE
);
814 Sleep(100); /* don't spin violently */
815 TRACE("spinning.\n");
822 /***********************************************************************
823 * RpcMgmtStopServerListening (RPCRT4.@)
825 RPC_STATUS WINAPI
RpcMgmtStopServerListening ( RPC_BINDING_HANDLE Binding
)
827 TRACE("(Binding == (RPC_BINDING_HANDLE)^%p)\n", Binding
);
830 FIXME("client-side invocation not implemented.\n");
831 return RPC_S_WRONG_KIND_OF_BINDING
;
835 EnterCriticalSection(&listen_cs
);
837 RPCRT4_stop_listen();
838 LeaveCriticalSection(&listen_cs
);
843 /***********************************************************************
844 * I_RpcServerStartListening (RPCRT4.@)
846 RPC_STATUS WINAPI
I_RpcServerStartListening( void* hWnd
)
848 FIXME( "(%p): stub\n", hWnd
);
853 /***********************************************************************
854 * I_RpcServerStopListening (RPCRT4.@)
856 RPC_STATUS WINAPI
I_RpcServerStopListening( void )
858 FIXME( "(): stub\n" );
863 /***********************************************************************
864 * I_RpcWindowProc (RPCRT4.@)
866 UINT WINAPI
I_RpcWindowProc( void *hWnd
, UINT Message
, UINT wParam
, ULONG lParam
)
868 FIXME( "(%p,%08x,%08x,%08lx): stub\n", hWnd
, Message
, wParam
, lParam
);