ReactOS 0.4.16-dev-1605-g7dd1858
rpc_transport.c
Go to the documentation of this file.
1/*
2 * RPC transport layer
3 *
4 * Copyright 2001 Ove Kåven, TransGaming Technologies
5 * Copyright 2003 Mike Hearn
6 * Copyright 2004 Filip Navara
7 * Copyright 2006 Mike McCormack
8 * Copyright 2006 Damjan Jovanovic
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 *
24 */
25
26#include "ntstatus.h"
27#define WIN32_NO_STATUS
28#ifdef __REACTOS__
29#define NONAMELESSUNION
30#endif
31#include "ws2tcpip.h"
32
33#include <stdarg.h>
34#include <stdio.h>
35#include <string.h>
36#include <assert.h>
37
38#include "windef.h"
39#include "winbase.h"
40#include "winnls.h"
41#include "winerror.h"
42#include "wininet.h"
43#include "wine/winternl.h"
44#include "winioctl.h"
45
46#include "rpc.h"
47#include "rpcndr.h"
48
49#include "wine/debug.h"
50
51#include "rpc_binding.h"
52#include "rpc_assoc.h"
53#include "rpc_message.h"
54#include "rpc_server.h"
55#include "epm_towers.h"
56
57#define DEFAULT_NCACN_HTTP_TIMEOUT (60 * 1000)
58
60
61#ifdef __REACTOS__ /* FIXME: Inspect */
63{
65
67 if (io_status.u.Status)
68 {
70 return FALSE;
71 }
72 return TRUE;
73}
74#define CancelIoEx CancelIoEx_
75#endif
76
78
79/**** ncacn_np support ****/
80
81typedef struct _RpcConnection_np
82{
91
93{
95 return &npc->common;
96}
97
99{
100 HANDLE event = InterlockedExchangePointer(&connection->event_cache, NULL);
101 return event ? event : CreateEventW(NULL, TRUE, FALSE, NULL);
102}
103
105{
106 event = InterlockedExchangePointer(&connection->event_cache, event);
107 if (event)
109}
110
111#ifdef __REACTOS__
129static DWORD rpcrt4_create_pipe_security(PSECURITY_DESCRIPTOR *SecDesc)
130{
131 DWORD ErrCode;
132 PACL Dacl;
133 ULONG DaclSize, RelSDSize = 0;
134 PSID EveryoneSid = NULL, AnonymousSid = NULL, AdminsSid = NULL;
135 PSECURITY_DESCRIPTOR AbsSD = NULL, RelSD = NULL;
138
140 1,
142 0, 0, 0, 0, 0, 0, 0,
143 &EveryoneSid))
144 {
145 ERR("rpcrt4_create_pipe_security(): Failed to allocate Everyone SID (error code %d)\n", GetLastError());
146 return GetLastError();
147 }
148
150 1,
152 0, 0, 0, 0, 0, 0, 0,
153 &AnonymousSid))
154 {
155 ERR("rpcrt4_create_pipe_security(): Failed to allocate Anonymous SID (error code %d)\n", GetLastError());
156 ErrCode = GetLastError();
157 goto Quit;
158 }
159
161 2,
164 0, 0, 0, 0, 0, 0,
165 &AdminsSid))
166 {
167 ERR("rpcrt4_create_pipe_security(): Failed to allocate Admins SID (error code %d)\n", GetLastError());
168 ErrCode = GetLastError();
169 goto Quit;
170 }
171
173 if (AbsSD == NULL)
174 {
175 ERR("rpcrt4_create_pipe_security(): Failed to allocate absolute SD!\n");
176 ErrCode = ERROR_OUTOFMEMORY;
177 goto Quit;
178 }
179
181 {
182 ERR("rpcrt4_create_pipe_security(): Failed to create absolute SD (error code %d)\n", GetLastError());
183 ErrCode = GetLastError();
184 goto Quit;
185 }
186
187 DaclSize = sizeof(ACL) +
188 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(EveryoneSid) +
189 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(AnonymousSid) +
190 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(AdminsSid);
191
192
194 if (Dacl == NULL)
195 {
196 ERR("rpcrt4_create_pipe_security(): Failed to allocate DACL!\n");
197 ErrCode = ERROR_OUTOFMEMORY;
198 goto Quit;
199 }
200
202 {
203 ERR("rpcrt4_create_pipe_security(): Failed to create DACL (error code %d)\n", GetLastError());
204 ErrCode = GetLastError();
205 goto Quit;
206 }
207
211 EveryoneSid))
212 {
213 ERR("rpcrt4_create_pipe_security(): Failed to set up ACE for Everyone SID (error code %d)\n", GetLastError());
214 ErrCode = GetLastError();
215 goto Quit;
216 }
217
221 AnonymousSid))
222 {
223 ERR("rpcrt4_create_pipe_security(): Failed to set up ACE for Anonymous SID (error code %d)\n", GetLastError());
224 ErrCode = GetLastError();
225 goto Quit;
226 }
227
231 AdminsSid))
232 {
233 ERR("rpcrt4_create_pipe_security(): Failed to set up ACE for Admins SID (error code %d)\n", GetLastError());
234 ErrCode = GetLastError();
235 goto Quit;
236 }
237
239 {
240 ERR("rpcrt4_create_pipe_security(): Failed to set DACL to absolute SD (error code %d)\n", GetLastError());
241 ErrCode = GetLastError();
242 goto Quit;
243 }
244
245 if (!SetSecurityDescriptorOwner(AbsSD, AdminsSid, FALSE))
246 {
247 ERR("rpcrt4_create_pipe_security(): Failed to set SD owner (error code %d)\n", GetLastError());
248 ErrCode = GetLastError();
249 goto Quit;
250 }
251
252 if (!SetSecurityDescriptorGroup(AbsSD, AdminsSid, FALSE))
253 {
254 ERR("rpcrt4_create_pipe_security(): Failed to set SD group (error code %d)\n", GetLastError());
255 ErrCode = GetLastError();
256 goto Quit;
257 }
258
259 if (!MakeSelfRelativeSD(AbsSD, NULL, &RelSDSize) && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
260 {
261 ERR("rpcrt4_create_pipe_security(): Unexpected error code (error code %d -- must be ERROR_INSUFFICIENT_BUFFER)\n", GetLastError());
262 ErrCode = GetLastError();
263 goto Quit;
264 }
265
266 RelSD = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, RelSDSize);
267 if (RelSD == NULL)
268 {
269 ERR("rpcrt4_create_pipe_security(): Failed to allocate relative SD!\n");
270 ErrCode = ERROR_OUTOFMEMORY;
271 goto Quit;
272 }
273
274 if (!MakeSelfRelativeSD(AbsSD, RelSD, &RelSDSize) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
275 {
276 ERR("rpcrt4_create_pipe_security(): Failed to allocate relative SD, buffer too smal (expected size %lu)\n", RelSDSize);
278 goto Quit;
279 }
280
281 TRACE("rpcrt4_create_pipe_security(): Success!\n");
282 *SecDesc = RelSD;
283 ErrCode = ERROR_SUCCESS;
284
285Quit:
286 if (ErrCode != ERROR_SUCCESS)
287 {
288 if (RelSD != NULL)
289 {
290 HeapFree(GetProcessHeap(), 0, RelSD);
291 }
292 }
293
294 if (EveryoneSid != NULL)
295 {
296 FreeSid(EveryoneSid);
297 }
298
299 if (AnonymousSid != NULL)
300 {
301 FreeSid(AnonymousSid);
302 }
303
304 if (AdminsSid != NULL)
305 {
306 FreeSid(AdminsSid);
307 }
308
309 if (Dacl != NULL)
310 {
312 }
313
314 if (AbsSD != NULL)
315 {
316 HeapFree(GetProcessHeap(), 0, AbsSD);
317 }
318
319 return ErrCode;
320}
321#endif
322
324{
325 RpcConnection_np *connection = (RpcConnection_np *) conn;
326#ifdef __REACTOS__
327 DWORD ErrCode;
328 SECURITY_ATTRIBUTES SecurityAttributes;
329 PSECURITY_DESCRIPTOR PipeSecDesc;
330#endif
331
332 TRACE("listening on %s\n", connection->listen_pipe);
333
334#ifdef __REACTOS__
335 ErrCode = rpcrt4_create_pipe_security(&PipeSecDesc);
336 if (ErrCode != ERROR_SUCCESS)
337 {
338 ERR("rpcrt4_conn_create_pipe(): Pipe security descriptor creation failed!\n");
340 }
341
342 SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
343 SecurityAttributes.lpSecurityDescriptor = PipeSecDesc;
344 SecurityAttributes.bInheritHandle = FALSE;
345
349 RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, &SecurityAttributes);
350 HeapFree(GetProcessHeap(), 0, PipeSecDesc);
351#else
356#endif
357 if (connection->pipe == INVALID_HANDLE_VALUE)
358 {
359 WARN("CreateNamedPipe failed with error %d\n", GetLastError());
361 {
363 }
364 else
365 {
367 }
368 }
369
370 return RPC_S_OK;
371}
372
374{
375 RpcConnection_np *npc = (RpcConnection_np *) Connection;
376 HANDLE pipe;
377 DWORD err, dwMode;
378
379 TRACE("connecting to %s\n", pname);
380
381 while (TRUE) {
382 DWORD dwFlags = 0;
383 if (Connection->QOS)
384 {
386 switch (Connection->QOS->qos->ImpersonationType)
387 {
389 /* FIXME: what to do here? */
390 break;
393 break;
396 break;
399 break;
402 break;
403 }
406 }
409 if (pipe != INVALID_HANDLE_VALUE) break;
410 err = GetLastError();
411 if (err == ERROR_PIPE_BUSY) {
413 TRACE("retrying busy server\n");
414 continue;
415 }
416 TRACE("connection failed, error=%x\n", err);
418#ifdef __REACTOS__
419 } else if (err == ERROR_BAD_NETPATH) {
420 TRACE("connection failed, error=%x\n", err);
422#endif
423 }
424 if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
425 err = GetLastError();
426 WARN("connection failed, error=%x\n", err);
428 }
429 }
430
431 /* success */
432 /* pipe is connected; change to message-read mode. */
433 dwMode = PIPE_READMODE_MESSAGE;
434 SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
435 npc->pipe = pipe;
436
437 return RPC_S_OK;
438}
439
440static char *ncalrpc_pipe_name(const char *endpoint)
441{
442 static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
443 char *pipe_name;
444
445 /* protseq=ncalrpc: supposed to use NT LPC ports,
446 * but we'll implement it with named pipes for now */
447 pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
448 strcat(strcpy(pipe_name, prefix), endpoint);
449 return pipe_name;
450}
451
453{
454 RpcConnection_np *npc = (RpcConnection_np *) Connection;
456 LPSTR pname;
457
458 /* already connected? */
459 if (npc->pipe)
460 return RPC_S_OK;
461
462 pname = ncalrpc_pipe_name(Connection->Endpoint);
463 r = rpcrt4_conn_open_pipe(Connection, pname, TRUE);
465
466 return r;
467}
468
470{
472 RpcConnection *Connection;
473 char generated_endpoint[22];
474
475 if (!endpoint)
476 {
477 static LONG lrpc_nameless_id;
478 DWORD process_id = GetCurrentProcessId();
479 ULONG id = InterlockedIncrement(&lrpc_nameless_id);
480 snprintf(generated_endpoint, sizeof(generated_endpoint),
481 "LRPC%08x.%08x", process_id, id);
482 endpoint = generated_endpoint;
483 }
484
485 r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL,
487 if (r != RPC_S_OK)
488 return r;
489
490 ((RpcConnection_np*)Connection)->listen_pipe = ncalrpc_pipe_name(Connection->Endpoint);
491 r = rpcrt4_conn_create_pipe(Connection);
492
493 EnterCriticalSection(&protseq->cs);
494 list_add_head(&protseq->listeners, &Connection->protseq_entry);
495 Connection->protseq = protseq;
496 LeaveCriticalSection(&protseq->cs);
497
498 return r;
499}
500
501#ifdef __REACTOS__
502static char *ncacn_pipe_name(const char *server, const char *endpoint)
503#else
504static char *ncacn_pipe_name(const char *endpoint)
505#endif
506{
507#ifdef __REACTOS__
508 static const char prefix[] = "\\\\";
509 static const char local[] = ".";
510 char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
511 DWORD bufLen = ARRAY_SIZE(ComputerName);
512#else
513 static const char prefix[] = "\\\\.";
514#endif
515 char *pipe_name;
516
517#ifdef __REACTOS__
518 if (server != NULL && *server != 0)
519 {
520 /* Trim any leading UNC server prefix. */
521 if (server[0] == '\\' && server[1] == '\\')
522 server += 2;
523
524 /* If the server represents the local computer, use instead
525 * the local prefix to avoid a round in UNC name resolution. */
526 if (GetComputerNameA(ComputerName, &bufLen) &&
527 (stricmp(ComputerName, server) == 0))
528 {
529 server = local;
530 }
531 }
532 else
533 {
534 server = local;
535 }
536#endif
537
538 /* protseq=ncacn_np: named pipes */
539#ifdef __REACTOS__
540 pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
541 strcpy(pipe_name, prefix);
542 strcat(pipe_name, server);
543 strcat(pipe_name, endpoint);
544#else
545 pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
546 strcat(strcpy(pipe_name, prefix), endpoint);
547#endif
548 return pipe_name;
549}
550
552{
553 RpcConnection_np *npc = (RpcConnection_np *) Connection;
555 LPSTR pname;
556
557 /* already connected? */
558 if (npc->pipe)
559 return RPC_S_OK;
560
561#ifdef __REACTOS__
562 pname = ncacn_pipe_name(Connection->NetworkAddr, Connection->Endpoint);
563#else
564 pname = ncacn_pipe_name(Connection->Endpoint);
565#endif
566 r = rpcrt4_conn_open_pipe(Connection, pname, FALSE);
568
569 return r;
570}
571
573{
575 RpcConnection *Connection;
576 char generated_endpoint[26];
577
578 if (!endpoint)
579 {
580 static LONG np_nameless_id;
581 DWORD process_id = GetCurrentProcessId();
582 ULONG id = InterlockedExchangeAdd(&np_nameless_id, 1 );
583 snprintf(generated_endpoint, sizeof(generated_endpoint),
584 "\\\\pipe\\\\%08x.%03x", process_id, id);
585 endpoint = generated_endpoint;
586 }
587
588 r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL,
590 if (r != RPC_S_OK)
591 return r;
592
593#ifdef __REACTOS__
594 ((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(NULL, Connection->Endpoint);
595#else
596 ((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(Connection->Endpoint);
597#endif
598 r = rpcrt4_conn_create_pipe(Connection);
599
600 EnterCriticalSection(&protseq->cs);
601 list_add_head(&protseq->listeners, &Connection->protseq_entry);
602 Connection->protseq = protseq;
603 LeaveCriticalSection(&protseq->cs);
604
605 return r;
606}
607
609{
610 /* because of the way named pipes work, we'll transfer the connected pipe
611 * to the child, then reopen the server binding to continue listening */
612
613 new_npc->pipe = old_npc->pipe;
614 old_npc->pipe = 0;
615 assert(!old_npc->listen_event);
616}
617
619{
622
625
626 /* Store the local computer name as the NetworkAddr for ncacn_np as long as
627 * we don't support named pipes over the network. */
628 new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len);
629 if (!GetComputerNameA(new_conn->NetworkAddr, &len))
630 {
631 ERR("Failed to retrieve the computer name, error %u\n", GetLastError());
633 }
634
635 return status;
636}
637
638static RPC_STATUS is_pipe_listening(const char *pipe_name)
639{
640 return WaitNamedPipeA(pipe_name, 1) ? RPC_S_OK : RPC_S_NOT_LISTENING;
641}
642
644{
645 char *pipe_name;
647
648#ifdef __REACTOS__
649 pipe_name = ncacn_pipe_name(NULL, endpoint);
650#else
651 pipe_name = ncacn_pipe_name(endpoint);
652#endif
653 status = is_pipe_listening(pipe_name);
654 I_RpcFree(pipe_name);
655 return status;
656}
657
659{
660 char *pipe_name;
662
663 pipe_name = ncalrpc_pipe_name(endpoint);
664 status = is_pipe_listening(pipe_name);
665 I_RpcFree(pipe_name);
666 return status;
667}
668
670{
673
674 TRACE("%s\n", old_conn->Endpoint);
675
678
679 /* Store the local computer name as the NetworkAddr for ncalrpc. */
680 new_conn->NetworkAddr = HeapAlloc(GetProcessHeap(), 0, len);
681 if (!GetComputerNameA(new_conn->NetworkAddr, &len))
682 {
683 ERR("Failed to retrieve the computer name, error %u\n", GetLastError());
685 }
686
687 return status;
688}
689
690static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int count)
691{
692 RpcConnection_np *connection = (RpcConnection_np *) conn;
695
696 event = get_np_event(connection);
697 if (!event)
698 return -1;
699
700 if (connection->read_closed)
702 else
703 status = NtReadFile(connection->pipe, event, NULL, NULL, &connection->io_status, buffer, count, NULL, NULL);
704 if (status == STATUS_PENDING)
705 {
706 /* check read_closed again before waiting to avoid a race */
707 if (connection->read_closed)
708 {
710#ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
711 NtCancelIoFile(connection->pipe, &io_status);
712#else
713 NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
714#endif
715 }
717 status = connection->io_status.u.Status;
718 }
719 release_np_event(connection, event);
720 return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information;
721}
722
723static int rpcrt4_conn_np_write(RpcConnection *conn, const void *buffer, unsigned int count)
724{
725 RpcConnection_np *connection = (RpcConnection_np *) conn;
729
730 event = get_np_event(connection);
731 if (!event)
732 return -1;
733
735 if (status == STATUS_PENDING)
736 {
738 status = io_status.u.Status;
739 }
740 release_np_event(connection, event);
741 if (status)
742 return -1;
743
744 assert(io_status.Information == count);
745 return count;
746}
747
749{
750 RpcConnection_np *connection = (RpcConnection_np *) conn;
751 if (connection->pipe)
752 {
753 FlushFileBuffers(connection->pipe);
754 CloseHandle(connection->pipe);
755 connection->pipe = 0;
756 }
757 if (connection->listen_event)
758 {
759 CloseHandle(connection->listen_event);
760 connection->listen_event = 0;
761 }
762 if (connection->event_cache)
763 {
764 CloseHandle(connection->event_cache);
765 connection->event_cache = 0;
766 }
767 return 0;
768}
769
771{
772 RpcConnection_np *connection = (RpcConnection_np*)conn;
774
775 connection->read_closed = TRUE;
776#ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
777 NtCancelIoFile(connection->pipe, &io_status);
778#else
779 NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
780#endif
781}
782
784{
785 RpcConnection_np *connection = (RpcConnection_np *)conn;
786 CancelIoEx(connection->pipe, NULL);
787}
788
790{
791 return rpcrt4_conn_np_read(conn, NULL, 0);
792}
793
794static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
795 const char *networkaddr,
796 const char *endpoint)
797{
798 twr_empty_floor_t *smb_floor;
799 twr_empty_floor_t *nb_floor;
800 size_t size;
801 size_t networkaddr_size;
802 size_t endpoint_size;
803
804 TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
805
806 networkaddr_size = networkaddr ? strlen(networkaddr) + 1 : 1;
807 endpoint_size = endpoint ? strlen(endpoint) + 1 : 1;
808 size = sizeof(*smb_floor) + endpoint_size + sizeof(*nb_floor) + networkaddr_size;
809
810 if (!tower_data)
811 return size;
812
813 smb_floor = (twr_empty_floor_t *)tower_data;
814
815 tower_data += sizeof(*smb_floor);
816
817 smb_floor->count_lhs = sizeof(smb_floor->protid);
818 smb_floor->protid = EPM_PROTOCOL_SMB;
819 smb_floor->count_rhs = endpoint_size;
820
821 if (endpoint)
822 memcpy(tower_data, endpoint, endpoint_size);
823 else
824 tower_data[0] = 0;
825 tower_data += endpoint_size;
826
827 nb_floor = (twr_empty_floor_t *)tower_data;
828
829 tower_data += sizeof(*nb_floor);
830
831 nb_floor->count_lhs = sizeof(nb_floor->protid);
832 nb_floor->protid = EPM_PROTOCOL_NETBIOS;
833 nb_floor->count_rhs = networkaddr_size;
834
835 if (networkaddr)
836 memcpy(tower_data, networkaddr, networkaddr_size);
837 else
838 tower_data[0] = 0;
839
840 return size;
841}
842
843static RPC_STATUS rpcrt4_ncacn_np_parse_top_of_tower(const unsigned char *tower_data,
844 size_t tower_size,
845 char **networkaddr,
846 char **endpoint)
847{
848 const twr_empty_floor_t *smb_floor = (const twr_empty_floor_t *)tower_data;
849 const twr_empty_floor_t *nb_floor;
850
851 TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
852
853 if (tower_size < sizeof(*smb_floor))
855
856 tower_data += sizeof(*smb_floor);
857 tower_size -= sizeof(*smb_floor);
858
859 if ((smb_floor->count_lhs != sizeof(smb_floor->protid)) ||
860 (smb_floor->protid != EPM_PROTOCOL_SMB) ||
861 (smb_floor->count_rhs > tower_size) ||
862 (tower_data[smb_floor->count_rhs - 1] != '\0'))
864
865 if (endpoint)
866 {
867 *endpoint = I_RpcAllocate(smb_floor->count_rhs);
868 if (!*endpoint)
870 memcpy(*endpoint, tower_data, smb_floor->count_rhs);
871 }
872 tower_data += smb_floor->count_rhs;
873 tower_size -= smb_floor->count_rhs;
874
875 if (tower_size < sizeof(*nb_floor))
877
878 nb_floor = (const twr_empty_floor_t *)tower_data;
879
880 tower_data += sizeof(*nb_floor);
881 tower_size -= sizeof(*nb_floor);
882
883 if ((nb_floor->count_lhs != sizeof(nb_floor->protid)) ||
884 (nb_floor->protid != EPM_PROTOCOL_NETBIOS) ||
885 (nb_floor->count_rhs > tower_size) ||
886 (tower_data[nb_floor->count_rhs - 1] != '\0'))
888
889 if (networkaddr)
890 {
891 *networkaddr = I_RpcAllocate(nb_floor->count_rhs);
892 if (!*networkaddr)
893 {
894 if (endpoint)
895 {
897 *endpoint = NULL;
898 }
900 }
901 memcpy(*networkaddr, tower_data, nb_floor->count_rhs);
902 }
903
904 return RPC_S_OK;
905}
906
908{
909 RpcConnection_np *npc = (RpcConnection_np *)conn;
910 BOOL ret;
911
912 TRACE("(%p)\n", conn);
913
914 if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
916
918 if (!ret)
919 {
921 WARN("ImpersonateNamedPipeClient failed with error %u\n", error);
922 switch (error)
923 {
926 }
927 }
928 return RPC_S_OK;
929}
930
932{
933 BOOL ret;
934
935 TRACE("(%p)\n", conn);
936
937 if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
939
940 ret = RevertToSelf();
941 if (!ret)
942 {
943 WARN("RevertToSelf failed with error %u\n", GetLastError());
945 }
946 return RPC_S_OK;
947}
948
950{
954
956{
958 if (ps)
960 return &ps->common;
961}
962
964{
966 SetEvent(npps->mgr_event);
967}
968
969static void *rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
970{
971 HANDLE *objs = prev_array;
972 RpcConnection_np *conn;
974
975 EnterCriticalSection(&protseq->cs);
976
977 /* open and count connections */
978 *count = 1;
979 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry)
980 {
981 if (!conn->pipe && rpcrt4_conn_create_pipe(&conn->common) != RPC_S_OK)
982 continue;
983 if (!conn->listen_event)
984 {
987
988 event = get_np_event(conn);
989 if (!event)
990 continue;
991
993 switch (status)
994 {
995 case STATUS_SUCCESS:
997 conn->io_status.u.Status = status;
999 break;
1000 case STATUS_PENDING:
1001 break;
1002 default:
1003 ERR("pipe listen error %x\n", status);
1004 continue;
1005 }
1006
1007 conn->listen_event = event;
1008 }
1009 (*count)++;
1010 }
1011
1012 /* make array of connections */
1013 if (objs)
1014 objs = HeapReAlloc(GetProcessHeap(), 0, objs, *count*sizeof(HANDLE));
1015 else
1016 objs = HeapAlloc(GetProcessHeap(), 0, *count*sizeof(HANDLE));
1017 if (!objs)
1018 {
1019 ERR("couldn't allocate objs\n");
1020 LeaveCriticalSection(&protseq->cs);
1021 return NULL;
1022 }
1023
1024 objs[0] = npps->mgr_event;
1025 *count = 1;
1026 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry)
1027 {
1028 if (conn->listen_event)
1029 objs[(*count)++] = conn->listen_event;
1030 }
1031 LeaveCriticalSection(&protseq->cs);
1032 return objs;
1033}
1034
1036{
1038}
1039
1040static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array)
1041{
1042 HANDLE b_handle;
1043 HANDLE *objs = wait_array;
1044 DWORD res;
1045 RpcConnection *cconn = NULL;
1046 RpcConnection_np *conn;
1047
1048 if (!objs)
1049 return -1;
1050
1051 do
1052 {
1053 /* an alertable wait isn't strictly necessary, but due to our
1054 * overlapped I/O implementation in Wine we need to free some memory
1055 * by the file user APC being called, even if no completion routine was
1056 * specified at the time of starting the async operation */
1058 } while (res == WAIT_IO_COMPLETION);
1059
1060 if (res == WAIT_OBJECT_0)
1061 return 0;
1062 else if (res == WAIT_FAILED)
1063 {
1064 ERR("wait failed with error %d\n", GetLastError());
1065 return -1;
1066 }
1067 else
1068 {
1069 b_handle = objs[res - WAIT_OBJECT_0];
1070 /* find which connection got a RPC */
1071 EnterCriticalSection(&protseq->cs);
1072 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry)
1073 {
1074 if (b_handle == conn->listen_event)
1075 {
1076 release_np_event(conn, conn->listen_event);
1077 conn->listen_event = NULL;
1079 cconn = rpcrt4_spawn_connection(&conn->common);
1080 else
1081 ERR("listen failed %x\n", conn->io_status.u.Status);
1082 break;
1083 }
1084 }
1085 LeaveCriticalSection(&protseq->cs);
1086 if (!cconn)
1087 {
1088 ERR("failed to locate connection for handle %p\n", b_handle);
1089 return -1;
1090 }
1091 RPCRT4_new_client(cconn);
1092 return 1;
1093 }
1094}
1095
1096static size_t rpcrt4_ncalrpc_get_top_of_tower(unsigned char *tower_data,
1097 const char *networkaddr,
1098 const char *endpoint)
1099{
1100 twr_empty_floor_t *pipe_floor;
1101 size_t size;
1102 size_t endpoint_size;
1103
1104 TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
1105
1106 endpoint_size = strlen(endpoint) + 1;
1107 size = sizeof(*pipe_floor) + endpoint_size;
1108
1109 if (!tower_data)
1110 return size;
1111
1112 pipe_floor = (twr_empty_floor_t *)tower_data;
1113
1114 tower_data += sizeof(*pipe_floor);
1115
1116 pipe_floor->count_lhs = sizeof(pipe_floor->protid);
1117 pipe_floor->protid = EPM_PROTOCOL_PIPE;
1118 pipe_floor->count_rhs = endpoint_size;
1119
1120 memcpy(tower_data, endpoint, endpoint_size);
1121
1122 return size;
1123}
1124
1125static RPC_STATUS rpcrt4_ncalrpc_parse_top_of_tower(const unsigned char *tower_data,
1126 size_t tower_size,
1127 char **networkaddr,
1128 char **endpoint)
1129{
1130 const twr_empty_floor_t *pipe_floor = (const twr_empty_floor_t *)tower_data;
1131
1132 TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1133
1134 if (tower_size < sizeof(*pipe_floor))
1135 return EPT_S_NOT_REGISTERED;
1136
1137 tower_data += sizeof(*pipe_floor);
1138 tower_size -= sizeof(*pipe_floor);
1139
1140 if ((pipe_floor->count_lhs != sizeof(pipe_floor->protid)) ||
1141 (pipe_floor->protid != EPM_PROTOCOL_PIPE) ||
1142 (pipe_floor->count_rhs > tower_size) ||
1143 (tower_data[pipe_floor->count_rhs - 1] != '\0'))
1144 return EPT_S_NOT_REGISTERED;
1145
1146 if (networkaddr)
1147 *networkaddr = NULL;
1148
1149 if (endpoint)
1150 {
1151 *endpoint = I_RpcAllocate(pipe_floor->count_rhs);
1152 if (!*endpoint)
1154 memcpy(*endpoint, tower_data, pipe_floor->count_rhs);
1155 }
1156
1157 return RPC_S_OK;
1158}
1159
1161{
1162 return FALSE;
1163}
1164
1166 unsigned char *in_buffer,
1167 unsigned int in_size,
1168 unsigned char *out_buffer,
1169 unsigned int *out_size)
1170{
1171 /* since this protocol is local to the machine there is no need to
1172 * authenticate the caller */
1173 *out_size = 0;
1174 return RPC_S_OK;
1175}
1176
1179 RpcPktHdr *hdr, unsigned int hdr_size,
1180 unsigned char *stub_data, unsigned int stub_data_size,
1181 RpcAuthVerifier *auth_hdr,
1182 unsigned char *auth_value, unsigned int auth_value_size)
1183{
1184 /* since this protocol is local to the machine there is no need to secure
1185 * the packet */
1186 return RPC_S_OK;
1187}
1188
1190 RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name,
1191 ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
1192{
1193 TRACE("(%p, %p, %p, %p, %p, %p, 0x%x)\n", conn, privs,
1194 server_princ_name, authn_level, authn_svc, authz_svc, flags);
1195
1196 if (privs)
1197 {
1198 FIXME("privs not implemented\n");
1199 *privs = NULL;
1200 }
1201 if (server_princ_name)
1202 {
1203 FIXME("server_princ_name not implemented\n");
1204 *server_princ_name = NULL;
1205 }
1206 if (authn_level) *authn_level = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
1207 if (authn_svc) *authn_svc = RPC_C_AUTHN_WINNT;
1208 if (authz_svc)
1209 {
1210 FIXME("authorization service not implemented\n");
1211 *authz_svc = RPC_C_AUTHZ_NONE;
1212 }
1213 if (flags)
1214 FIXME("flags 0x%x not implemented\n", flags);
1215
1216 return RPC_S_OK;
1217}
1218
1219/**** ncacn_ip_tcp support ****/
1220
1221static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data,
1222 const char *networkaddr,
1223 unsigned char tcp_protid,
1224 const char *endpoint)
1225{
1226 twr_tcp_floor_t *tcp_floor;
1227 twr_ipv4_floor_t *ipv4_floor;
1228 struct addrinfo *ai;
1229 struct addrinfo hints;
1230 int ret;
1231 size_t size = sizeof(*tcp_floor) + sizeof(*ipv4_floor);
1232
1233 TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
1234
1235 if (!tower_data)
1236 return size;
1237
1238 tcp_floor = (twr_tcp_floor_t *)tower_data;
1239 tower_data += sizeof(*tcp_floor);
1240
1241 ipv4_floor = (twr_ipv4_floor_t *)tower_data;
1242
1243 tcp_floor->count_lhs = sizeof(tcp_floor->protid);
1244 tcp_floor->protid = tcp_protid;
1245 tcp_floor->count_rhs = sizeof(tcp_floor->port);
1246
1247 ipv4_floor->count_lhs = sizeof(ipv4_floor->protid);
1248 ipv4_floor->protid = EPM_PROTOCOL_IP;
1249 ipv4_floor->count_rhs = sizeof(ipv4_floor->ipv4addr);
1250
1251 hints.ai_flags = AI_NUMERICHOST;
1252 /* FIXME: only support IPv4 at the moment. how is IPv6 represented by the EPM? */
1253 hints.ai_family = PF_INET;
1254 hints.ai_socktype = SOCK_STREAM;
1255 hints.ai_protocol = IPPROTO_TCP;
1256 hints.ai_addrlen = 0;
1257 hints.ai_addr = NULL;
1258 hints.ai_canonname = NULL;
1259 hints.ai_next = NULL;
1260
1261#ifdef __REACTOS__
1262 static BOOL wsa_inited;
1263 if (!wsa_inited)
1264 {
1265 WSADATA wsadata;
1266 WSAStartup(MAKEWORD(2, 2), &wsadata);
1267 /* Note: WSAStartup can be called more than once so we don't bother with
1268 * making accesses to wsa_inited thread-safe */
1269 wsa_inited = TRUE;
1270 }
1271#endif
1272
1273 ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
1274 if (ret)
1275 {
1276 ret = getaddrinfo("0.0.0.0", endpoint, &hints, &ai);
1277 if (ret)
1278 {
1279 ERR("getaddrinfo failed: %s\n", gai_strerror(ret));
1280 return 0;
1281 }
1282 }
1283
1284 if (ai->ai_family == PF_INET)
1285 {
1286 const struct sockaddr_in *sin = (const struct sockaddr_in *)ai->ai_addr;
1287 tcp_floor->port = sin->sin_port;
1288 ipv4_floor->ipv4addr = sin->sin_addr.s_addr;
1289 }
1290 else
1291 {
1292 ERR("unexpected protocol family %d\n", ai->ai_family);
1293 freeaddrinfo(ai);
1294 return 0;
1295 }
1296
1297 freeaddrinfo(ai);
1298
1299 return size;
1300}
1301
1302static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower(const unsigned char *tower_data,
1303 size_t tower_size,
1304 char **networkaddr,
1305 unsigned char tcp_protid,
1306 char **endpoint)
1307{
1308 const twr_tcp_floor_t *tcp_floor = (const twr_tcp_floor_t *)tower_data;
1309 const twr_ipv4_floor_t *ipv4_floor;
1310 struct in_addr in_addr;
1311
1312 TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1313
1314 if (tower_size < sizeof(*tcp_floor))
1315 return EPT_S_NOT_REGISTERED;
1316
1317 tower_data += sizeof(*tcp_floor);
1318 tower_size -= sizeof(*tcp_floor);
1319
1320 if (tower_size < sizeof(*ipv4_floor))
1321 return EPT_S_NOT_REGISTERED;
1322
1323 ipv4_floor = (const twr_ipv4_floor_t *)tower_data;
1324
1325 if ((tcp_floor->count_lhs != sizeof(tcp_floor->protid)) ||
1326 (tcp_floor->protid != tcp_protid) ||
1327 (tcp_floor->count_rhs != sizeof(tcp_floor->port)) ||
1328 (ipv4_floor->count_lhs != sizeof(ipv4_floor->protid)) ||
1329 (ipv4_floor->protid != EPM_PROTOCOL_IP) ||
1330 (ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
1331 return EPT_S_NOT_REGISTERED;
1332
1333 if (endpoint)
1334 {
1335 *endpoint = I_RpcAllocate(6 /* sizeof("65535") + 1 */);
1336 if (!*endpoint)
1338 sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
1339 }
1340
1341 if (networkaddr)
1342 {
1343 *networkaddr = I_RpcAllocate(INET_ADDRSTRLEN);
1344 if (!*networkaddr)
1345 {
1346 if (endpoint)
1347 {
1349 *endpoint = NULL;
1350 }
1352 }
1353 in_addr.s_addr = ipv4_floor->ipv4addr;
1354 if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
1355 {
1356 ERR("inet_ntop: %u\n", WSAGetLastError());
1357 I_RpcFree(*networkaddr);
1358 *networkaddr = NULL;
1359 if (endpoint)
1360 {
1362 *endpoint = NULL;
1363 }
1364 return EPT_S_NOT_REGISTERED;
1365 }
1366 }
1367
1368 return RPC_S_OK;
1369}
1370
1372{
1374 int sock;
1378
1380{
1381 static BOOL wsa_inited;
1382 if (!wsa_inited)
1383 {
1384 WSADATA wsadata;
1385 WSAStartup(MAKEWORD(2, 2), &wsadata);
1386 /* Note: WSAStartup can be called more than once so we don't bother with
1387 * making accesses to wsa_inited thread-safe */
1388 wsa_inited = TRUE;
1389 }
1392 if (!tcpc->sock_event || !tcpc->cancel_event)
1393 {
1394 ERR("event creation failed\n");
1395 if (tcpc->sock_event) CloseHandle(tcpc->sock_event);
1396 return FALSE;
1397 }
1398 return TRUE;
1399}
1400
1402{
1403 HANDLE wait_handles[2];
1404 DWORD res;
1406 {
1407 ERR("WSAEventSelect() failed with error %d\n", WSAGetLastError());
1408 return FALSE;
1409 }
1410 wait_handles[0] = tcpc->sock_event;
1411 wait_handles[1] = tcpc->cancel_event;
1412 res = WaitForMultipleObjects(2, wait_handles, FALSE, INFINITE);
1413 switch (res)
1414 {
1415 case WAIT_OBJECT_0:
1416 return TRUE;
1417 case WAIT_OBJECT_0 + 1:
1418 return FALSE;
1419 default:
1420 ERR("WaitForMultipleObjects() failed with error %d\n", GetLastError());
1421 return FALSE;
1422 }
1423}
1424
1426{
1427 DWORD res;
1429 {
1430 ERR("WSAEventSelect() failed with error %d\n", WSAGetLastError());
1431 return FALSE;
1432 }
1434 switch (res)
1435 {
1436 case WAIT_OBJECT_0:
1437 return TRUE;
1438 default:
1439 ERR("WaitForMultipleObjects() failed with error %d\n", GetLastError());
1440 return FALSE;
1441 }
1442}
1443
1445{
1446 RpcConnection_tcp *tcpc;
1448 if (tcpc == NULL)
1449 return NULL;
1450 tcpc->sock = -1;
1451 if (!rpcrt4_sock_wait_init(tcpc))
1452 {
1453 HeapFree(GetProcessHeap(), 0, tcpc);
1454 return NULL;
1455 }
1456 return &tcpc->common;
1457}
1458
1460{
1461 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1462 int sock;
1463 int ret;
1464 struct addrinfo *ai;
1465 struct addrinfo *ai_cur;
1466 struct addrinfo hints;
1467
1468 TRACE("(%s, %s)\n", Connection->NetworkAddr, Connection->Endpoint);
1469
1470 if (tcpc->sock != -1)
1471 return RPC_S_OK;
1472
1473 hints.ai_flags = 0;
1474 hints.ai_family = PF_UNSPEC;
1475 hints.ai_socktype = SOCK_STREAM;
1476 hints.ai_protocol = IPPROTO_TCP;
1477 hints.ai_addrlen = 0;
1478 hints.ai_addr = NULL;
1479 hints.ai_canonname = NULL;
1480 hints.ai_next = NULL;
1481
1482 ret = getaddrinfo(Connection->NetworkAddr, Connection->Endpoint, &hints, &ai);
1483 if (ret)
1484 {
1485 ERR("getaddrinfo for %s:%s failed: %s\n", Connection->NetworkAddr,
1486 Connection->Endpoint, gai_strerror(ret));
1488 }
1489
1490 for (ai_cur = ai; ai_cur; ai_cur = ai_cur->ai_next)
1491 {
1492 int val;
1493 u_long nonblocking;
1494
1495 if (ai_cur->ai_family != AF_INET && ai_cur->ai_family != AF_INET6)
1496 {
1497 TRACE("skipping non-IP/IPv6 address family\n");
1498 continue;
1499 }
1500
1501 if (TRACE_ON(rpc))
1502 {
1503 char host[256];
1504 char service[256];
1505 getnameinfo(ai_cur->ai_addr, ai_cur->ai_addrlen,
1506 host, sizeof(host), service, sizeof(service),
1508 TRACE("trying %s:%s\n", host, service);
1509 }
1510
1511 sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol);
1512 if (sock == -1)
1513 {
1514 WARN("socket() failed: %u\n", WSAGetLastError());
1515 continue;
1516 }
1517
1518 if (0>connect(sock, ai_cur->ai_addr, ai_cur->ai_addrlen))
1519 {
1520 WARN("connect() failed: %u\n", WSAGetLastError());
1522 continue;
1523 }
1524
1525 /* RPC depends on having minimal latency so disable the Nagle algorithm */
1526 val = 1;
1527 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
1528 nonblocking = 1;
1529 ioctlsocket(sock, FIONBIO, &nonblocking);
1530
1531 tcpc->sock = sock;
1532
1533 freeaddrinfo(ai);
1534 TRACE("connected\n");
1535 return RPC_S_OK;
1536 }
1537
1538 freeaddrinfo(ai);
1539 ERR("couldn't connect to %s:%s\n", Connection->NetworkAddr, Connection->Endpoint);
1541}
1542
1544{
1546 int sock;
1547 int ret;
1548 struct addrinfo *ai;
1549 struct addrinfo *ai_cur;
1550 struct addrinfo hints;
1551
1552 TRACE("(%p, %s)\n", protseq, endpoint);
1553
1554 hints.ai_flags = AI_PASSIVE /* for non-localhost addresses */;
1555 hints.ai_family = PF_UNSPEC;
1556 hints.ai_socktype = SOCK_STREAM;
1557 hints.ai_protocol = IPPROTO_TCP;
1558 hints.ai_addrlen = 0;
1559 hints.ai_addr = NULL;
1560 hints.ai_canonname = NULL;
1561 hints.ai_next = NULL;
1562
1563 ret = getaddrinfo(NULL, endpoint ? endpoint : "0", &hints, &ai);
1564 if (ret)
1565 {
1566 ERR("getaddrinfo for port %s failed: %s\n", endpoint,
1567 gai_strerror(ret));
1568 if ((ret == EAI_SERVICE) || (ret == EAI_NONAME))
1571 }
1572
1573 for (ai_cur = ai; ai_cur; ai_cur = ai_cur->ai_next)
1574 {
1575 RpcConnection_tcp *tcpc;
1576 RPC_STATUS create_status;
1577 struct sockaddr_storage sa;
1578 socklen_t sa_len;
1579 char service[NI_MAXSERV];
1580 u_long nonblocking;
1581
1582 if (ai_cur->ai_family != AF_INET && ai_cur->ai_family != AF_INET6)
1583 {
1584 TRACE("skipping non-IP/IPv6 address family\n");
1585 continue;
1586 }
1587
1588 if (TRACE_ON(rpc))
1589 {
1590 char host[256];
1591 getnameinfo(ai_cur->ai_addr, ai_cur->ai_addrlen,
1592 host, sizeof(host), service, sizeof(service),
1594 TRACE("trying %s:%s\n", host, service);
1595 }
1596
1597 sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol);
1598 if (sock == -1)
1599 {
1600 WARN("socket() failed: %u\n", WSAGetLastError());
1602 continue;
1603 }
1604
1605 ret = bind(sock, ai_cur->ai_addr, ai_cur->ai_addrlen);
1606 if (ret < 0)
1607 {
1608 WARN("bind failed: %u\n", WSAGetLastError());
1612 else
1614 continue;
1615 }
1616
1617 sa_len = sizeof(sa);
1618 if (getsockname(sock, (struct sockaddr *)&sa, &sa_len))
1619 {
1620 WARN("getsockname() failed: %u\n", WSAGetLastError());
1623 continue;
1624 }
1625
1626 ret = getnameinfo((struct sockaddr *)&sa, sa_len,
1627 NULL, 0, service, sizeof(service),
1629 if (ret)
1630 {
1631 WARN("getnameinfo failed: %s\n", gai_strerror(ret));
1634 continue;
1635 }
1636
1637 create_status = RPCRT4_CreateConnection((RpcConnection **)&tcpc, TRUE,
1638 protseq->Protseq, NULL,
1639 service, NULL, NULL, NULL, NULL);
1640 if (create_status != RPC_S_OK)
1641 {
1643 status = create_status;
1644 continue;
1645 }
1646
1647 tcpc->sock = sock;
1648 ret = listen(sock, protseq->MaxCalls);
1649 if (ret < 0)
1650 {
1651 WARN("listen failed: %u\n", WSAGetLastError());
1654 continue;
1655 }
1656 /* need a non-blocking socket, otherwise accept() has a potential
1657 * race-condition (poll() says it is readable, connection drops,
1658 * and accept() blocks until the next connection comes...)
1659 */
1660 nonblocking = 1;
1661 ret = ioctlsocket(sock, FIONBIO, &nonblocking);
1662 if (ret < 0)
1663 {
1664 WARN("couldn't make socket non-blocking, error %d\n", ret);
1667 continue;
1668 }
1669
1670 EnterCriticalSection(&protseq->cs);
1671 list_add_tail(&protseq->listeners, &tcpc->common.protseq_entry);
1672 tcpc->common.protseq = protseq;
1673 LeaveCriticalSection(&protseq->cs);
1674
1675 freeaddrinfo(ai);
1676
1677 /* since IPv4 and IPv6 share the same port space, we only need one
1678 * successful bind to listen for both */
1679 TRACE("listening on %s\n", endpoint);
1680 return RPC_S_OK;
1681 }
1682
1683 freeaddrinfo(ai);
1684 ERR("couldn't listen on port %s\n", endpoint);
1685 return status;
1686}
1687
1689{
1690 int ret;
1691 struct sockaddr_in address;
1692 socklen_t addrsize;
1695 u_long nonblocking;
1696
1697 addrsize = sizeof(address);
1698 ret = accept(server->sock, (struct sockaddr*) &address, &addrsize);
1699 if (ret < 0)
1700 {
1701 ERR("Failed to accept a TCP connection: error %d\n", ret);
1703 }
1704
1705 nonblocking = 1;
1706 ioctlsocket(ret, FIONBIO, &nonblocking);
1707 client->sock = ret;
1708
1709 client->common.NetworkAddr = HeapAlloc(GetProcessHeap(), 0, INET6_ADDRSTRLEN);
1710 ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
1711 if (ret != 0)
1712 {
1713 ERR("Failed to retrieve the IP address, error %d\n", ret);
1715 }
1716
1717 TRACE("Accepted a new TCP connection from %s\n", client->common.NetworkAddr);
1718 return RPC_S_OK;
1719}
1720
1722 void *buffer, unsigned int count)
1723{
1724 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1725 int bytes_read = 0;
1726 while (bytes_read != count)
1727 {
1728 int r = recv(tcpc->sock, (char *)buffer + bytes_read, count - bytes_read, 0);
1729 if (!r)
1730 return -1;
1731 else if (r > 0)
1732 bytes_read += r;
1733 else if (WSAGetLastError() == WSAEINTR)
1734 continue;
1735 else if (WSAGetLastError() != WSAEWOULDBLOCK)
1736 {
1737 WARN("recv() failed: %u\n", WSAGetLastError());
1738 return -1;
1739 }
1740 else
1741 {
1742 if (!rpcrt4_sock_wait_for_recv(tcpc))
1743 return -1;
1744 }
1745 }
1746 TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_read);
1747 return bytes_read;
1748}
1749
1751 const void *buffer, unsigned int count)
1752{
1753 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1754 int bytes_written = 0;
1755 while (bytes_written != count)
1756 {
1757 int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
1758 if (r >= 0)
1759 bytes_written += r;
1760 else if (WSAGetLastError() == WSAEINTR)
1761 continue;
1762 else if (WSAGetLastError() != WSAEWOULDBLOCK)
1763 return -1;
1764 else
1765 {
1766 if (!rpcrt4_sock_wait_for_send(tcpc))
1767 return -1;
1768 }
1769 }
1770 TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_written);
1771 return bytes_written;
1772}
1773
1775{
1776 RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1777
1778 TRACE("%d\n", connection->sock);
1779
1780 if (connection->sock != -1)
1781 closesocket(connection->sock);
1782 connection->sock = -1;
1783 CloseHandle(connection->sock_event);
1784 CloseHandle(connection->cancel_event);
1785 return 0;
1786}
1787
1789{
1790 RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1791 shutdown(connection->sock, SD_RECEIVE);
1792}
1793
1795{
1796 RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1797
1798 TRACE("%p\n", connection);
1799
1800 SetEvent(connection->cancel_event);
1801}
1802
1804{
1805 FIXME("\n");
1806 return RPC_S_ACCESS_DENIED;
1807}
1808
1810{
1811 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1812
1813 TRACE("%p\n", Connection);
1814
1815 if (!rpcrt4_sock_wait_for_recv(tcpc))
1816 return -1;
1817 return 0;
1818}
1819
1820static size_t rpcrt4_ncacn_ip_tcp_get_top_of_tower(unsigned char *tower_data,
1821 const char *networkaddr,
1822 const char *endpoint)
1823{
1824 return rpcrt4_ip_tcp_get_top_of_tower(tower_data, networkaddr,
1826}
1827
1829{
1833
1835{
1837 if (ps)
1838 {
1839 static BOOL wsa_inited;
1840 if (!wsa_inited)
1841 {
1842 WSADATA wsadata;
1843 WSAStartup(MAKEWORD(2, 2), &wsadata);
1844 /* Note: WSAStartup can be called more than once so we don't bother with
1845 * making accesses to wsa_inited thread-safe */
1846 wsa_inited = TRUE;
1847 }
1849 }
1850 return &ps->common;
1851}
1852
1854{
1856 SetEvent(sockps->mgr_event);
1857}
1858
1859static void *rpcrt4_protseq_sock_get_wait_array(RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
1860{
1861 HANDLE *objs = prev_array;
1862 RpcConnection_tcp *conn;
1864
1865 EnterCriticalSection(&protseq->cs);
1866
1867 /* open and count connections */
1868 *count = 1;
1869 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_tcp, common.protseq_entry)
1870 {
1871 if (conn->sock != -1)
1872 (*count)++;
1873 }
1874
1875 /* make array of connections */
1876 if (objs)
1877 objs = HeapReAlloc(GetProcessHeap(), 0, objs, *count*sizeof(HANDLE));
1878 else
1879 objs = HeapAlloc(GetProcessHeap(), 0, *count*sizeof(HANDLE));
1880 if (!objs)
1881 {
1882 ERR("couldn't allocate objs\n");
1883 LeaveCriticalSection(&protseq->cs);
1884 return NULL;
1885 }
1886
1887 objs[0] = sockps->mgr_event;
1888 *count = 1;
1889 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_tcp, common.protseq_entry)
1890 {
1891 if (conn->sock != -1)
1892 {
1893 int res = WSAEventSelect(conn->sock, conn->sock_event, FD_ACCEPT);
1894 if (res == SOCKET_ERROR)
1895 ERR("WSAEventSelect() failed with error %d\n", WSAGetLastError());
1896 else
1897 {
1898 objs[*count] = conn->sock_event;
1899 (*count)++;
1900 }
1901 }
1902 }
1903 LeaveCriticalSection(&protseq->cs);
1904 return objs;
1905}
1906
1908{
1910}
1911
1912static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array)
1913{
1914 HANDLE b_handle;
1915 HANDLE *objs = wait_array;
1916 DWORD res;
1917 RpcConnection *cconn = NULL;
1918 RpcConnection_tcp *conn;
1919
1920 if (!objs)
1921 return -1;
1922
1923 do
1924 {
1925 /* an alertable wait isn't strictly necessary, but due to our
1926 * overlapped I/O implementation in Wine we need to free some memory
1927 * by the file user APC being called, even if no completion routine was
1928 * specified at the time of starting the async operation */
1930 } while (res == WAIT_IO_COMPLETION);
1931
1932 if (res == WAIT_OBJECT_0)
1933 return 0;
1934 if (res == WAIT_FAILED)
1935 {
1936 ERR("wait failed with error %d\n", GetLastError());
1937 return -1;
1938 }
1939
1940 b_handle = objs[res - WAIT_OBJECT_0];
1941
1942 /* find which connection got a RPC */
1943 EnterCriticalSection(&protseq->cs);
1944 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_tcp, common.protseq_entry)
1945 {
1946 if (b_handle == conn->sock_event)
1947 {
1948 cconn = rpcrt4_spawn_connection(&conn->common);
1949 break;
1950 }
1951 }
1952 LeaveCriticalSection(&protseq->cs);
1953 if (!cconn)
1954 {
1955 ERR("failed to locate connection for handle %p\n", b_handle);
1956 return -1;
1957 }
1958
1959 RPCRT4_new_client(cconn);
1960 return 1;
1961}
1962
1963static RPC_STATUS rpcrt4_ncacn_ip_tcp_parse_top_of_tower(const unsigned char *tower_data,
1964 size_t tower_size,
1965 char **networkaddr,
1966 char **endpoint)
1967{
1968 return rpcrt4_ip_tcp_parse_top_of_tower(tower_data, tower_size,
1969 networkaddr, EPM_PROTOCOL_TCP,
1970 endpoint);
1971}
1972
1973/**** ncacn_http support ****/
1974
1975/* 60 seconds is the period native uses */
1976#define HTTP_IDLE_TIME 60000
1977
1978/* reference counted to avoid a race between a cancelled call's connection
1979 * being destroyed and the asynchronous InternetReadFileEx call being
1980 * completed */
1981typedef struct _RpcHttpAsyncData
1982{
1989
1991{
1992 return InterlockedIncrement(&data->refs);
1993}
1994
1996{
1997 ULONG refs = InterlockedDecrement(&data->refs);
1998 if (!refs)
1999 {
2000 TRACE("destroying async data %p\n", data);
2001 CloseHandle(data->completion_event);
2002 HeapFree(GetProcessHeap(), 0, data->inet_buffers.lpvBuffer);
2003 data->cs.DebugInfo->Spare[0] = 0;
2006 }
2007 return refs;
2008}
2009
2011{
2012 ResetEvent(async_data->completion_event);
2013 RpcHttpAsyncData_AddRef(async_data);
2014}
2015
2016static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
2017{
2018 HANDLE handles[2] = { async_data->completion_event, cancel_event };
2019 DWORD res;
2020
2021 if(call_ret) {
2022 RpcHttpAsyncData_Release(async_data);
2023 return RPC_S_OK;
2024 }
2025
2027 RpcHttpAsyncData_Release(async_data);
2028 ERR("Request failed with error %d\n", GetLastError());
2030 }
2031
2033 if(res != WAIT_OBJECT_0) {
2034 TRACE("Cancelled\n");
2035 return RPC_S_CALL_CANCELLED;
2036 }
2037
2038 if(async_data->async_result) {
2039 ERR("Async request failed with error %d\n", async_data->async_result);
2041 }
2042
2043 return RPC_S_OK;
2044}
2045
2047{
2054 char *data;
2055 unsigned int data_len;
2056 BOOL finished; /* finished authenticating */
2057};
2058
2060{
2071 ULONG flow_control_mark; /* send a control packet to the server when this many bytes received */
2072 ULONG flow_control_increment; /* number of bytes to increment flow_control_mark by */
2078
2080{
2081 RpcConnection_http *httpc;
2082 httpc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*httpc));
2083 if (!httpc) return NULL;
2085 if (!httpc->async_data)
2086 {
2087 HeapFree(GetProcessHeap(), 0, httpc);
2088 return NULL;
2089 }
2090 TRACE("async data = %p\n", httpc->async_data);
2092 httpc->async_data->refs = 1;
2095 httpc->async_data->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcHttpAsyncData.cs");
2096 return &httpc->common;
2097}
2098
2100{
2105
2107{
2108 HINTERNET in_request = param;
2109 RpcPktHdr *idle_pkt;
2110
2112 0, 0);
2113 if (idle_pkt)
2114 {
2115 DWORD bytes_written;
2116 InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written);
2117 RPCRT4_FreeHeader(idle_pkt);
2118 }
2119}
2120
2121static inline DWORD rpcrt4_http_timer_calc_timeout(DWORD *last_sent_time)
2122{
2124 DWORD cached_last_sent_time = *last_sent_time;
2125 return HTTP_IDLE_TIME - (cur_time - cached_last_sent_time > HTTP_IDLE_TIME ? 0 : cur_time - cached_last_sent_time);
2126}
2127
2129{
2130 HttpTimerThreadData *data_in = param;
2132 DWORD timeout;
2133
2134 data = *data_in;
2135 HeapFree(GetProcessHeap(), 0, data_in);
2136
2137 for (timeout = HTTP_IDLE_TIME;
2138 WaitForSingleObject(data.timer_cancelled, timeout) == WAIT_TIMEOUT;
2140 {
2141 /* are we too soon after last send? */
2142 if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
2143 continue;
2145 }
2146
2147 CloseHandle(data.timer_cancelled);
2148 return 0;
2149}
2150
2152 HINTERNET hInternet,
2153 DWORD_PTR dwContext,
2154 DWORD dwInternetStatus,
2155 LPVOID lpvStatusInformation,
2156 DWORD dwStatusInformationLength)
2157{
2158 RpcHttpAsyncData *async_data = (RpcHttpAsyncData *)dwContext;
2159
2160 switch (dwInternetStatus)
2161 {
2163 TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
2164 if (async_data)
2165 {
2166 INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
2167
2168 async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
2169 SetEvent(async_data->completion_event);
2170 RpcHttpAsyncData_Release(async_data);
2171 }
2172 break;
2173 }
2174}
2175
2177{
2178 BOOL ret;
2180 DWORD size;
2181 DWORD index;
2182 WCHAR buf[32];
2183 WCHAR *status_text = buf;
2184 TRACE("\n");
2185
2186 index = 0;
2187 size = sizeof(status_code);
2189 if (!ret)
2190 return GetLastError();
2192 return RPC_S_OK;
2193 index = 0;
2194 size = sizeof(buf);
2195 ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
2197 {
2198 status_text = HeapAlloc(GetProcessHeap(), 0, size);
2199 ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
2200 }
2201
2202 ERR("server returned: %d %s\n", status_code, ret ? debugstr_w(status_text) : "<status text unavailable>");
2203 if(status_text != buf) HeapFree(GetProcessHeap(), 0, status_text);
2204
2206 return ERROR_ACCESS_DENIED;
2208}
2209
2211{
2212 static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0};
2213 LPWSTR proxy = NULL;
2214 LPWSTR user = NULL;
2216 LPWSTR servername = NULL;
2217 const WCHAR *option;
2219
2220 if (httpc->common.QOS &&
2222 {
2223 const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_cred = httpc->common.QOS->qos->u.HttpCredentials;
2224 if (http_cred->TransportCredentials)
2225 {
2226 WCHAR *p;
2227 const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials;
2228 ULONG len = cred->DomainLength + 1 + cred->UserLength;
2229 user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
2230 if (!user)
2232 p = user;
2233 if (cred->DomainLength)
2234 {
2235 memcpy(p, cred->Domain, cred->DomainLength * sizeof(WCHAR));
2236 p += cred->DomainLength;
2237 *p = '\\';
2238 p++;
2239 }
2240 memcpy(p, cred->User, cred->UserLength * sizeof(WCHAR));
2241 p[cred->UserLength] = 0;
2242
2244 }
2245 }
2246
2247 for (option = httpc->common.NetworkOptions; option;
2248 option = (wcschr(option, ',') ? wcschr(option, ',')+1 : NULL))
2249 {
2250 static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
2251 static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
2252
2253 if (!_wcsnicmp(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1))
2254 {
2255 const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1;
2256 const WCHAR *value_end;
2257 const WCHAR *p;
2258
2259 value_end = wcschr(option, ',');
2260 if (!value_end)
2261 value_end = value_start + lstrlenW(value_start);
2262 for (p = value_start; p < value_end; p++)
2263 if (*p == ':')
2264 {
2265 port = wcstol(p+1, NULL, 10);
2266 value_end = p;
2267 break;
2268 }
2269 TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2270 servername = RPCRT4_strndupW(value_start, value_end-value_start);
2271 }
2272 else if (!_wcsnicmp(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1))
2273 {
2274 const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1;
2275 const WCHAR *value_end;
2276
2277 value_end = wcschr(option, ',');
2278 if (!value_end)
2279 value_end = value_start + lstrlenW(value_start);
2280 TRACE("HttpProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2281 proxy = RPCRT4_strndupW(value_start, value_end-value_start);
2282 }
2283 else
2284 FIXME("unhandled option %s\n", debugstr_w(option));
2285 }
2286
2289 if (!httpc->app_info)
2290 {
2294 HeapFree(GetProcessHeap(), 0, servername);
2295 ERR("InternetOpenW failed with error %d\n", GetLastError());
2297 }
2299
2300 /* if no RpcProxy option specified, set the HTTP server address to the
2301 * RPC server address */
2302 if (!servername)
2303 {
2304 servername = HeapAlloc(GetProcessHeap(), 0, (strlen(httpc->common.NetworkAddr) + 1)*sizeof(WCHAR));
2305 if (!servername)
2306 {
2311 }
2312 MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
2313 }
2314
2315 port = (httpc->common.QOS &&
2319
2320 httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
2321 INTERNET_SERVICE_HTTP, 0, 0);
2322
2326
2327 if (!httpc->session)
2328 {
2329 ERR("InternetConnectW failed with error %d\n", GetLastError());
2330 HeapFree(GetProcessHeap(), 0, servername);
2332 }
2333 httpc->servername = servername;
2334 return RPC_S_OK;
2335}
2336
2337static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event,
2338 void *buffer, unsigned int count)
2339{
2340 char *buf = buffer;
2341 BOOL ret;
2342 unsigned int bytes_left = count;
2344
2346
2347 while (bytes_left)
2348 {
2349 async_data->inet_buffers.dwBufferLength = bytes_left;
2350 prepare_async_request(async_data);
2351 ret = InternetReadFileExW(req, &async_data->inet_buffers, IRF_ASYNC, 0);
2352 status = wait_async_request(async_data, ret, cancel_event);
2353 if (status != RPC_S_OK)
2354 {
2356 TRACE("call cancelled\n");
2357 break;
2358 }
2359
2360 if (!async_data->inet_buffers.dwBufferLength)
2361 break;
2362 memcpy(buf, async_data->inet_buffers.lpvBuffer,
2363 async_data->inet_buffers.dwBufferLength);
2364
2365 bytes_left -= async_data->inet_buffers.dwBufferLength;
2366 buf += async_data->inet_buffers.dwBufferLength;
2367 }
2368
2369 HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer);
2370 async_data->inet_buffers.lpvBuffer = NULL;
2371
2372 TRACE("%p %p %u -> %u\n", req, buffer, count, status);
2373 return status == RPC_S_OK ? count : -1;
2374}
2375
2376static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
2377{
2378 BYTE buf[20];
2379 BOOL ret;
2381
2382 TRACE("sending echo request to server\n");
2383
2384 prepare_async_request(async_data);
2385 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
2386 status = wait_async_request(async_data, ret, cancel_event);
2387 if (status != RPC_S_OK) return status;
2388
2390 if (status != RPC_S_OK) return status;
2391
2392 rpcrt4_http_async_read(req, async_data, cancel_event, buf, sizeof(buf));
2393 /* FIXME: do something with retrieved data */
2394
2395 return RPC_S_OK;
2396}
2397
2399{
2400 static const WCHAR fmtW[] =
2401 {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
2402 WCHAR header[ARRAY_SIZE(fmtW) + 10];
2403
2404 swprintf(header, fmtW, len);
2407}
2408
2409/* prepare the in pipe for use by RPC packets */
2410static RPC_STATUS rpcrt4_http_prepare_in_pipe(HINTERNET in_request, RpcHttpAsyncData *async_data, HANDLE cancel_event,
2411 const UUID *connection_uuid, const UUID *in_pipe_uuid,
2412 const UUID *association_uuid, BOOL authorized)
2413{
2414 BOOL ret;
2416 RpcPktHdr *hdr;
2417 INTERNET_BUFFERSW buffers_in;
2418 DWORD bytes_written;
2419
2420 if (!authorized)
2421 {
2422 /* ask wininet to authorize, if necessary */
2423 status = send_echo_request(in_request, async_data, cancel_event);
2424 if (status != RPC_S_OK) return status;
2425 }
2426 memset(&buffers_in, 0, sizeof(buffers_in));
2427 buffers_in.dwStructSize = sizeof(buffers_in);
2428 /* FIXME: get this from the registry */
2429 buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
2430 status = insert_content_length_header(in_request, buffers_in.dwBufferTotal);
2431 if (status != RPC_S_OK) return status;
2432
2433 prepare_async_request(async_data);
2434 ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
2435 status = wait_async_request(async_data, ret, cancel_event);
2436 if (status != RPC_S_OK) return status;
2437
2438 TRACE("sending HTTP connect header to server\n");
2439 hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
2440 if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2441 ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
2443 if (!ret)
2444 {
2445 ERR("InternetWriteFile failed with error %d\n", GetLastError());
2447 }
2448
2449 return RPC_S_OK;
2450}
2451
2453 HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
2454{
2455 unsigned short data_len;
2456 unsigned int size;
2457
2458 if (rpcrt4_http_async_read(request, async_data, cancel_event, hdr, sizeof(hdr->common)) < 0)
2460 if (hdr->common.ptype != PKT_HTTP || hdr->common.frag_len < sizeof(hdr->http))
2461 {
2462 ERR("wrong packet type received %d or wrong frag_len %d\n",
2463 hdr->common.ptype, hdr->common.frag_len);
2464 return RPC_S_PROTOCOL_ERROR;
2465 }
2466
2467 size = sizeof(hdr->http) - sizeof(hdr->common);
2468 if (rpcrt4_http_async_read(request, async_data, cancel_event, &hdr->common + 1, size) < 0)
2470
2471 data_len = hdr->common.frag_len - sizeof(hdr->http);
2472 if (data_len)
2473 {
2474 *data = HeapAlloc(GetProcessHeap(), 0, data_len);
2475 if (!*data)
2477 if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0)
2478 {
2481 }
2482 }
2483 else
2484 *data = NULL;
2485
2486 if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len))
2487 {
2488 ERR("invalid http packet\n");
2490 return RPC_S_PROTOCOL_ERROR;
2491 }
2492
2493 return RPC_S_OK;
2494}
2495
2496/* prepare the out pipe for use by RPC packets */
2498 HANDLE cancel_event, const UUID *connection_uuid,
2499 const UUID *out_pipe_uuid, ULONG *flow_control_increment,
2500 BOOL authorized)
2501{
2502 BOOL ret;
2504 RpcPktHdr *hdr;
2505 BYTE *data_from_server;
2506 RpcPktHdr pkt_from_server;
2507 ULONG field1, field3;
2508 BYTE buf[20];
2509
2510 if (!authorized)
2511 {
2512 /* ask wininet to authorize, if necessary */
2513 status = send_echo_request(out_request, async_data, cancel_event);
2514 if (status != RPC_S_OK) return status;
2515 }
2516 else
2517 rpcrt4_http_async_read(out_request, async_data, cancel_event, buf, sizeof(buf));
2518
2519 hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
2520 if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2521
2522 status = insert_content_length_header(out_request, hdr->common.frag_len);
2523 if (status != RPC_S_OK)
2524 {
2526 return status;
2527 }
2528
2529 TRACE("sending HTTP connect header to server\n");
2530 prepare_async_request(async_data);
2531 ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
2532 status = wait_async_request(async_data, ret, cancel_event);
2534 if (status != RPC_S_OK) return status;
2535
2536 status = rpcrt4_http_check_response(out_request);
2537 if (status != RPC_S_OK) return status;
2538
2539 status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2540 &pkt_from_server, &data_from_server);
2541 if (status != RPC_S_OK) return status;
2542 status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server,
2543 &field1);
2544 HeapFree(GetProcessHeap(), 0, data_from_server);
2545 if (status != RPC_S_OK) return status;
2546 TRACE("received (%d) from first prepare header\n", field1);
2547
2548 for (;;)
2549 {
2550 status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2551 &pkt_from_server, &data_from_server);
2552 if (status != RPC_S_OK) return status;
2553 if (pkt_from_server.http.flags != 0x0001) break;
2554
2555 TRACE("http idle packet, waiting for real packet\n");
2556 HeapFree(GetProcessHeap(), 0, data_from_server);
2557 if (pkt_from_server.http.num_data_items != 0)
2558 {
2559 ERR("HTTP idle packet should have no data items instead of %d\n",
2560 pkt_from_server.http.num_data_items);
2561 return RPC_S_PROTOCOL_ERROR;
2562 }
2563 }
2564 status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
2565 &field1, flow_control_increment,
2566 &field3);
2567 HeapFree(GetProcessHeap(), 0, data_from_server);
2568 if (status != RPC_S_OK) return status;
2569 TRACE("received (0x%08x 0x%08x %d) from second prepare header\n", field1, *flow_control_increment, field3);
2570
2571 return RPC_S_OK;
2572}
2573
2574static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
2575{
2576 static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2577 UINT i = 0, x;
2578
2579 while (len > 0)
2580 {
2581 /* first 6 bits, all from bin[0] */
2582 base64[i++] = enc[(bin[0] & 0xfc) >> 2];
2583 x = (bin[0] & 3) << 4;
2584
2585 /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
2586 if (len == 1)
2587 {
2588 base64[i++] = enc[x];
2589 base64[i++] = '=';
2590 base64[i++] = '=';
2591 break;
2592 }
2593 base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
2594 x = (bin[1] & 0x0f) << 2;
2595
2596 /* next 6 bits 4 from bin[1] and 2 from bin[2] */
2597 if (len == 2)
2598 {
2599 base64[i++] = enc[x];
2600 base64[i++] = '=';
2601 break;
2602 }
2603 base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
2604
2605 /* last 6 bits, all from bin [2] */
2606 base64[i++] = enc[bin[2] & 0x3f];
2607 bin += 3;
2608 len -= 3;
2609 }
2610 base64[i] = 0;
2611 return i;
2612}
2613
2614static inline char decode_char( WCHAR c )
2615{
2616 if (c >= 'A' && c <= 'Z') return c - 'A';
2617 if (c >= 'a' && c <= 'z') return c - 'a' + 26;
2618 if (c >= '0' && c <= '9') return c - '0' + 52;
2619 if (c == '+') return 62;
2620 if (c == '/') return 63;
2621 return 64;
2622}
2623
2624static unsigned int decode_base64( const WCHAR *base64, unsigned int len, char *buf )
2625{
2626 unsigned int i = 0;
2627 char c0, c1, c2, c3;
2628 const WCHAR *p = base64;
2629
2630 while (len > 4)
2631 {
2632 if ((c0 = decode_char( p[0] )) > 63) return 0;
2633 if ((c1 = decode_char( p[1] )) > 63) return 0;
2634 if ((c2 = decode_char( p[2] )) > 63) return 0;
2635 if ((c3 = decode_char( p[3] )) > 63) return 0;
2636
2637 if (buf)
2638 {
2639 buf[i + 0] = (c0 << 2) | (c1 >> 4);
2640 buf[i + 1] = (c1 << 4) | (c2 >> 2);
2641 buf[i + 2] = (c2 << 6) | c3;
2642 }
2643 len -= 4;
2644 i += 3;
2645 p += 4;
2646 }
2647 if (p[2] == '=')
2648 {
2649 if ((c0 = decode_char( p[0] )) > 63) return 0;
2650 if ((c1 = decode_char( p[1] )) > 63) return 0;
2651
2652 if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
2653 i++;
2654 }
2655 else if (p[3] == '=')
2656 {
2657 if ((c0 = decode_char( p[0] )) > 63) return 0;
2658 if ((c1 = decode_char( p[1] )) > 63) return 0;
2659 if ((c2 = decode_char( p[2] )) > 63) return 0;
2660
2661 if (buf)
2662 {
2663 buf[i + 0] = (c0 << 2) | (c1 >> 4);
2664 buf[i + 1] = (c1 << 4) | (c2 >> 2);
2665 }
2666 i += 2;
2667 }
2668 else
2669 {
2670 if ((c0 = decode_char( p[0] )) > 63) return 0;
2671 if ((c1 = decode_char( p[1] )) > 63) return 0;
2672 if ((c2 = decode_char( p[2] )) > 63) return 0;
2673 if ((c3 = decode_char( p[3] )) > 63) return 0;
2674
2675 if (buf)
2676 {
2677 buf[i + 0] = (c0 << 2) | (c1 >> 4);
2678 buf[i + 1] = (c1 << 4) | (c2 >> 2);
2679 buf[i + 2] = (c2 << 6) | c3;
2680 }
2681 i += 3;
2682 }
2683 return i;
2684}
2685
2686static struct authinfo *alloc_authinfo(void)
2687{
2688 struct authinfo *ret;
2689
2690 if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret) ))) return NULL;
2691
2692 SecInvalidateHandle(&ret->cred);
2693 SecInvalidateHandle(&ret->ctx);
2694 memset(&ret->exp, 0, sizeof(ret->exp));
2695 ret->scheme = 0;
2696 ret->attr = 0;
2697 ret->max_token = 0;
2698 ret->data = NULL;
2699 ret->data_len = 0;
2700 ret->finished = FALSE;
2701 return ret;
2702}
2703
2704static void destroy_authinfo(struct authinfo *info)
2705{
2706 if (!info) return;
2707
2708 if (SecIsValidHandle(&info->ctx))
2710 if (SecIsValidHandle(&info->cred))
2712
2713 HeapFree(GetProcessHeap(), 0, info->data);
2715}
2716
2717static const WCHAR basicW[] = {'B','a','s','i','c',0};
2718static const WCHAR ntlmW[] = {'N','T','L','M',0};
2719static const WCHAR passportW[] = {'P','a','s','s','p','o','r','t',0};
2720static const WCHAR digestW[] = {'D','i','g','e','s','t',0};
2721static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
2722
2723static const struct
2724{
2725 const WCHAR *str;
2726 unsigned int len;
2728}
2729auth_schemes[] =
2730{
2737
2739{
2740 unsigned int i;
2741 for (i = 0; i < ARRAY_SIZE(auth_schemes); i++)
2742 {
2744 (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
2745 }
2746 return 0;
2747}
2748
2750{
2751 DWORD len, index = 0;
2752 for (;;)
2753 {
2754 len = buflen;
2756 if (auth_scheme_from_header(buffer) == scheme) break;
2757 }
2758 return TRUE;
2759}
2760
2762 const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
2763{
2764 struct authinfo *info = *auth_ptr;
2767
2768 if ((!info && !(info = alloc_authinfo()))) return RPC_S_SERVER_UNAVAILABLE;
2769
2770 switch (creds->AuthnSchemes[0])
2771 {
2773 {
2774 int userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
2775 int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
2776
2777 info->data_len = userlen + passlen + 1;
2778 if (!(info->data = HeapAlloc(GetProcessHeap(), 0, info->data_len)))
2779 {
2781 break;
2782 }
2783 WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, info->data, userlen, NULL, NULL);
2784 info->data[userlen] = ':';
2785 WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, info->data + userlen + 1, passlen, NULL, NULL);
2786
2788 info->finished = TRUE;
2789 status = RPC_S_OK;
2790 break;
2791 }
2794 {
2795
2796 static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
2798 SecBufferDesc out_desc, in_desc;
2799 SecBuffer out, in;
2802 int scheme_len;
2803 const WCHAR *p;
2804 WCHAR auth_value[2048];
2805 DWORD size = sizeof(auth_value);
2806 BOOL first = FALSE;
2807
2809 else scheme = negotiateW;
2810 scheme_len = lstrlenW( scheme );
2811
2812 if (!*auth_ptr)
2813 {
2814 TimeStamp exp;
2815 SecPkgInfoW *pkg_info;
2816
2818 if (ret != SEC_E_OK) break;
2819
2820 ret = QuerySecurityPackageInfoW(scheme, &pkg_info);
2821 if (ret != SEC_E_OK) break;
2822
2823 info->max_token = pkg_info->cbMaxToken;
2824 FreeContextBuffer(pkg_info);
2825 first = TRUE;
2826 }
2827 else
2828 {
2829 if (info->finished || !get_authvalue(request, creds->AuthnSchemes[0], auth_value, size)) break;
2830 if (auth_scheme_from_header(auth_value) != info->scheme)
2831 {
2832 ERR("authentication scheme changed\n");
2833 break;
2834 }
2835 }
2836 in.BufferType = SECBUFFER_TOKEN;
2837 in.cbBuffer = 0;
2838 in.pvBuffer = NULL;
2839
2840 in_desc.ulVersion = 0;
2841 in_desc.cBuffers = 1;
2842 in_desc.pBuffers = &in;
2843
2844 p = auth_value + scheme_len;
2845 if (!first && *p == ' ')
2846 {
2847 int len = lstrlenW(++p);
2848 in.cbBuffer = decode_base64(p, len, NULL);
2849 if (!(in.pvBuffer = HeapAlloc(GetProcessHeap(), 0, in.cbBuffer))) break;
2850 decode_base64(p, len, in.pvBuffer);
2851 }
2852 out.BufferType = SECBUFFER_TOKEN;
2853 out.cbBuffer = info->max_token;
2854 if (!(out.pvBuffer = HeapAlloc(GetProcessHeap(), 0, out.cbBuffer)))
2855 {
2856 HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2857 break;
2858 }
2859 out_desc.ulVersion = 0;
2860 out_desc.cBuffers = 1;
2861 out_desc.pBuffers = &out;
2862
2863 ret = InitializeSecurityContextW(first ? &info->cred : NULL, first ? NULL : &info->ctx,
2864 first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP,
2865 in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc,
2866 &info->attr, &info->exp);
2867 HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2868 if (ret == SEC_E_OK)
2869 {
2870 HeapFree(GetProcessHeap(), 0, info->data);
2871 info->data = out.pvBuffer;
2872 info->data_len = out.cbBuffer;
2873 info->finished = TRUE;
2874 TRACE("sending last auth packet\n");
2875 status = RPC_S_OK;
2876 }
2877 else if (ret == SEC_I_CONTINUE_NEEDED)
2878 {
2879 HeapFree(GetProcessHeap(), 0, info->data);
2880 info->data = out.pvBuffer;
2881 info->data_len = out.cbBuffer;
2882 TRACE("sending next auth packet\n");
2883 status = RPC_S_OK;
2884 }
2885 else
2886 {
2887 ERR("InitializeSecurityContextW failed with error 0x%08x\n", ret);
2888 HeapFree(GetProcessHeap(), 0, out.pvBuffer);
2889 break;
2890 }
2891 info->scheme = creds->AuthnSchemes[0];
2892 break;
2893 }
2894 default:
2895 FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]);
2896 break;
2897 }
2898
2899 if (status != RPC_S_OK)
2900 {
2902 *auth_ptr = NULL;
2903 return status;
2904 }
2905 *auth_ptr = info;
2906 return RPC_S_OK;
2907}
2908
2910{
2911 static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' '};
2912 static const WCHAR basicW[] = {'B','a','s','i','c',' '};
2913 static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
2914 static const WCHAR ntlmW[] = {'N','T','L','M',' '};
2915 int scheme_len, auth_len = ARRAY_SIZE(authW), len = ((data_len + 2) * 4) / 3;
2916 const WCHAR *scheme_str;
2917 WCHAR *header, *ptr;
2919
2920 switch (scheme)
2921 {
2923 scheme_str = basicW;
2924 scheme_len = ARRAY_SIZE(basicW);
2925 break;
2927 scheme_str = negotiateW;
2928 scheme_len = ARRAY_SIZE(negotiateW);
2929 break;
2931 scheme_str = ntlmW;
2932 scheme_len = ARRAY_SIZE(ntlmW);
2933 break;
2934 default:
2935 ERR("unknown scheme %u\n", scheme);
2937 }
2938 if ((header = HeapAlloc(GetProcessHeap(), 0, (auth_len + scheme_len + len + 2) * sizeof(WCHAR))))
2939 {
2940 memcpy(header, authW, auth_len * sizeof(WCHAR));
2941 ptr = header + auth_len;
2942 memcpy(ptr, scheme_str, scheme_len * sizeof(WCHAR));
2943 ptr += scheme_len;
2945 ptr[len++] = '\r';
2946 ptr[len++] = '\n';
2947 ptr[len] = 0;
2949 status = RPC_S_OK;
2951 }
2952 return status;
2953}
2954
2955static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
2956{
2957 DWORD count, len = 0, size = sizeof(len);
2958 char buf[2048];
2959
2961 if (!len) return;
2962 for (;;)
2963 {
2964 count = min(sizeof(buf), len);
2965 if (rpcrt4_http_async_read(request, async_data, cancel_event, buf, count) <= 0) return;
2966 len -= count;
2967 }
2968}
2969
2971{
2972 static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0};
2973 struct authinfo *info = NULL;
2975 BOOL ret;
2976
2977 for (;;)
2978 {
2980 if (status != RPC_S_OK) break;
2981
2982 status = insert_authorization_header(request, info->scheme, info->data, info->data_len);
2983 if (status != RPC_S_OK) break;
2984
2988 if (status != RPC_S_OK || info->finished) break;
2989
2991 if (status != RPC_S_OK && status != ERROR_ACCESS_DENIED) break;
2993 }
2994
2995 if (info->scheme != RPC_C_HTTP_AUTHN_SCHEME_BASIC)
2997
2999 return status;
3000}
3001
3003{
3006
3008 return FALSE;
3009
3010 creds = httpc->common.QOS->qos->u.HttpCredentials;
3012 return FALSE;
3013
3014 id = creds->TransportCredentials;
3015 if (!id || !id->User || !id->Password) return FALSE;
3016
3017 return TRUE;
3018}
3019
3021{
3022 return httpc->common.QOS &&
3025}
3026
3028{
3029 static WCHAR httpW[] = {'h','t','t','p',0};
3030 static WCHAR httpsW[] = {'h','t','t','p','s',0};
3031 URL_COMPONENTSW uc;
3032 DWORD len;
3033 WCHAR *url;
3034 BOOL ret;
3035
3036 if (!value) return RPC_S_OK;
3037
3038 uc.dwStructSize = sizeof(uc);
3039 uc.lpszScheme = is_secure(httpc) ? httpsW : httpW;
3040 uc.dwSchemeLength = 0;
3041 uc.lpszHostName = httpc->servername;
3042 uc.dwHostNameLength = 0;
3043 uc.nPort = 0;
3044 uc.lpszUserName = NULL;
3045 uc.dwUserNameLength = 0;
3046 uc.lpszPassword = NULL;
3047 uc.dwPasswordLength = 0;
3048 uc.lpszUrlPath = NULL;
3049 uc.dwUrlPathLength = 0;
3050 uc.lpszExtraInfo = NULL;
3051 uc.dwExtraInfoLength = 0;
3052
3055
3056 if (!(url = HeapAlloc(GetProcessHeap(), 0, len))) return RPC_S_OUT_OF_MEMORY;
3057
3058 len = len / sizeof(WCHAR) - 1;
3059 if (!InternetCreateUrlW(&uc, 0, url, &len))
3060 {
3063 }
3064
3067 if (!ret) return RPC_S_SERVER_UNAVAILABLE;
3068
3069 return RPC_S_OK;
3070}
3071
3073{
3074 RpcConnection_http *httpc = (RpcConnection_http *)Connection;
3075 static const WCHAR wszVerbIn[] = {'R','P','C','_','I','N','_','D','A','T','A',0};
3076 static const WCHAR wszVerbOut[] = {'R','P','C','_','O','U','T','_','D','A','T','A',0};
3077 static const WCHAR wszRpcProxyPrefix[] = {'/','r','p','c','/','r','p','c','p','r','o','x','y','.','d','l','l','?',0};
3078 static const WCHAR wszColon[] = {':',0};
3079 static const WCHAR wszAcceptType[] = {'a','p','p','l','i','c','a','t','i','o','n','/','r','p','c',0};
3080 LPCWSTR wszAcceptTypes[] = { wszAcceptType, NULL };
3081 DWORD flags;
3082 WCHAR *url;
3084 BOOL secure, credentials;
3085 HttpTimerThreadData *timer_data;
3086 HANDLE thread;
3087
3088 TRACE("(%s, %s)\n", Connection->NetworkAddr, Connection->Endpoint);
3089
3090 if (Connection->server)
3091 {
3092 ERR("ncacn_http servers not supported yet\n");
3094 }
3095
3096 if (httpc->in_request)
3097 return RPC_S_OK;
3098
3100
3101 UuidCreate(&httpc->connection_uuid);
3102 UuidCreate(&httpc->in_pipe_uuid);
3103 UuidCreate(&httpc->out_pipe_uuid);
3104
3106 if (status != RPC_S_OK)
3107 return status;
3108
3109 url = HeapAlloc(GetProcessHeap(), 0, sizeof(wszRpcProxyPrefix) + (strlen(Connection->NetworkAddr) + 1 + strlen(Connection->Endpoint))*sizeof(WCHAR));
3110 if (!url)
3111 return RPC_S_OUT_OF_MEMORY;
3112 memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix));
3113 MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+ARRAY_SIZE(wszRpcProxyPrefix)-1,
3114 strlen(Connection->NetworkAddr)+1);
3115 lstrcatW(url, wszColon);
3116 MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1, url+lstrlenW(url), strlen(Connection->Endpoint)+1);
3117
3118 secure = is_secure(httpc);
3119 credentials = has_credentials(httpc);
3120
3124 if (credentials) flags |= INTERNET_FLAG_NO_AUTH;
3125
3126 status = set_auth_cookie(httpc, Connection->CookieAuth);
3127 if (status != RPC_S_OK)
3128 {
3130 return status;
3131 }
3132 httpc->in_request = HttpOpenRequestW(httpc->session, wszVerbIn, url, NULL, NULL, wszAcceptTypes,
3133 flags, (DWORD_PTR)httpc->async_data);
3134 if (!httpc->in_request)
3135 {
3136 ERR("HttpOpenRequestW failed with error %d\n", GetLastError());
3139 }
3140
3141 if (credentials)
3142 {
3143 status = authorize_request(httpc, httpc->in_request);
3144 if (status != RPC_S_OK)
3145 {
3147 return status;
3148 }
3150 if (status != RPC_S_OK)
3151 {
3153 return status;
3154 }
3155 drain_content(httpc->in_request, httpc->async_data, httpc->cancel_event);
3156 }
3157
3158 httpc->out_request = HttpOpenRequestW(httpc->session, wszVerbOut, url, NULL, NULL, wszAcceptTypes,
3159 flags, (DWORD_PTR)httpc->async_data);
3161 if (!httpc->out_request)
3162 {
3163 ERR("HttpOpenRequestW failed with error %d\n", GetLastError());
3165 }
3166
3167 if (credentials)
3168 {
3169 status = authorize_request(httpc, httpc->out_request);
3170 if (status != RPC_S_OK)
3171 return status;
3172 }
3173
3175 &httpc->connection_uuid, &httpc->in_pipe_uuid,
3176 &Connection->assoc->http_uuid, credentials);
3177 if (status != RPC_S_OK)
3178 return status;
3179
3181 &httpc->connection_uuid, &httpc->out_pipe_uuid,
3182 &httpc->flow_control_increment, credentials);
3183 if (status != RPC_S_OK)
3184 return status;
3185
3186 httpc->flow_control_mark = httpc->flow_control_increment / 2;
3187 httpc->last_sent_time = GetTickCount();
3189
3190 timer_data = HeapAlloc(GetProcessHeap(), 0, sizeof(*timer_data));
3191 if (!timer_data)
3192 return ERROR_OUTOFMEMORY;
3193 timer_data->timer_param = httpc->in_request;
3194 timer_data->last_sent_time = &httpc->last_sent_time;
3195 timer_data->timer_cancelled = httpc->timer_cancelled;
3196 /* FIXME: should use CreateTimerQueueTimer when implemented */
3197 thread = CreateThread(NULL, 0, rpcrt4_http_timer_thread, timer_data, 0, NULL);
3198 if (!thread)
3199 {
3200 HeapFree(GetProcessHeap(), 0, timer_data);
3201 return GetLastError();
3202 }
3204
3205 return RPC_S_OK;
3206}
3207
3209{
3210 assert(0);
3212}
3213
3215 void *buffer, unsigned int count)
3216{
3217 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3218 return rpcrt4_http_async_read(httpc->out_request, httpc->async_data, httpc->cancel_event, buffer, count);
3219}
3220
3222{
3223 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3225 DWORD hdr_length;
3226 LONG dwRead;
3227 RpcPktCommonHdr common_hdr;
3228
3229 *Header = NULL;
3230
3231 TRACE("(%p, %p, %p)\n", Connection, Header, Payload);
3232
3233again:
3234 /* read packet common header */
3235 dwRead = rpcrt4_ncacn_http_read(Connection, &common_hdr, sizeof(common_hdr));
3236 if (dwRead != sizeof(common_hdr)) {
3237 WARN("Short read of header, %d bytes\n", dwRead);
3239 goto fail;
3240 }
3241 if (!memcmp(&common_hdr, "HTTP/1.1", sizeof("HTTP/1.1")) ||
3242 !memcmp(&common_hdr, "HTTP/1.0", sizeof("HTTP/1.0")))
3243 {
3244 FIXME("server returned %s\n", debugstr_a((const char *)&common_hdr));
3246 goto fail;
3247 }
3248
3249 status = RPCRT4_ValidateCommonHeader(&common_hdr);
3250 if (status != RPC_S_OK) goto fail;
3251
3252 hdr_length = RPCRT4_GetHeaderSize((RpcPktHdr*)&common_hdr);
3253 if (hdr_length == 0) {
3254 WARN("header length == 0\n");
3256 goto fail;
3257 }
3258
3259 *Header = HeapAlloc(GetProcessHeap(), 0, hdr_length);
3260 if (!*Header)
3261 {
3263 goto fail;
3264 }
3265 memcpy(*Header, &common_hdr, sizeof(common_hdr));
3266
3267 /* read the rest of packet header */
3268 dwRead = rpcrt4_ncacn_http_read(Connection, &(*Header)->common + 1, hdr_length - sizeof(common_hdr));
3269 if (dwRead != hdr_length - sizeof(common_hdr)) {
3270 WARN("bad header length, %d bytes, hdr_length %d\n", dwRead, hdr_length);
3272 goto fail;
3273 }
3274
3275 if (common_hdr.frag_len - hdr_length)
3276 {
3277 *Payload = HeapAlloc(GetProcessHeap(), 0, common_hdr.frag_len - hdr_length);
3278 if (!*Payload)
3279 {
3281 goto fail;
3282 }
3283
3284 dwRead = rpcrt4_ncacn_http_read(Connection, *Payload, common_hdr.frag_len - hdr_length);
3285 if (dwRead != common_hdr.frag_len - hdr_length)
3286 {
3287 WARN("bad data length, %d/%d\n", dwRead, common_hdr.frag_len - hdr_length);
3289 goto fail;
3290 }
3291 }
3292 else
3293 *Payload = NULL;
3294
3295 if ((*Header)->common.ptype == PKT_HTTP)
3296 {
3297 if (!RPCRT4_IsValidHttpPacket(*Header, *Payload, common_hdr.frag_len - hdr_length))
3298 {
3299 ERR("invalid http packet of length %d bytes\n", (*Header)->common.frag_len);
3301 goto fail;
3302 }
3303 if ((*Header)->http.flags == 0x0001)
3304 {
3305 TRACE("http idle packet, waiting for real packet\n");
3306 if ((*Header)->http.num_data_items != 0)
3307 {
3308 ERR("HTTP idle packet should have no data items instead of %d\n", (*Header)->http.num_data_items);
3310 goto fail;
3311 }
3312 }
3313 else if ((*Header)->http.flags == 0x0002)
3314 {
3315 ULONG bytes_transmitted;
3316 ULONG flow_control_increment;
3317 UUID pipe_uuid;
3319 Connection->server,
3320 &bytes_transmitted,
3321 &flow_control_increment,
3322 &pipe_uuid);
3323 if (status != RPC_S_OK)
3324 goto fail;
3325 TRACE("received http flow control header (0x%x, 0x%x, %s)\n",
3326 bytes_transmitted, flow_control_increment, debugstr_guid(&pipe_uuid));
3327 /* FIXME: do something with parsed data */
3328 }
3329 else
3330 {
3331 FIXME("unrecognised http packet with flags 0x%04x\n", (*Header)->http.flags);
3333 goto fail;
3334 }
3336 *Header = NULL;
3337 HeapFree(GetProcessHeap(), 0, *Payload);
3338 *Payload = NULL;
3339 goto again;
3340 }
3341
3342 /* success */
3343 status = RPC_S_OK;
3344
3345 httpc->bytes_received += common_hdr.frag_len;
3346
3347 TRACE("httpc->bytes_received = 0x%x\n", httpc->bytes_received);
3348
3349 if (httpc->bytes_received > httpc->flow_control_mark)
3350 {
3352 httpc->bytes_received,
3354 &httpc->out_pipe_uuid);
3355 if (hdr)
3356 {
3357 DWORD bytes_written;
3358 BOOL ret2;
3359 TRACE("sending flow control packet at 0x%x\n", httpc->bytes_received);
3360 ret2 = InternetWriteFile(httpc->in_request, hdr, hdr->common.frag_len, &bytes_written);
3362 if (ret2)
3363 httpc->flow_control_mark = httpc->bytes_received + httpc->flow_control_increment / 2;
3364 }
3365 }
3366
3367fail:
3368 if (status != RPC_S_OK) {
3370 *Header = NULL;
3371 HeapFree(GetProcessHeap(), 0, *Payload);
3372 *Payload = NULL;
3373 }
3374 return status;
3375}
3376
3378 const void *buffer, unsigned int count)
3379{
3380 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3381 DWORD bytes_written;
3382 BOOL ret;
3383
3384 httpc->last_sent_time = ~0U; /* disable idle packet sending */
3385 ret = InternetWriteFile(httpc->in_request, buffer, count, &bytes_written);
3386 httpc->last_sent_time = GetTickCount();
3387 TRACE("%p %p %u -> %s\n", httpc->in_request, buffer, count, ret ? "TRUE" : "FALSE");
3388 return ret ? bytes_written : -1;
3389}
3390
3392{
3393 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3394
3395 TRACE("\n");
3396
3397 SetEvent(httpc->timer_cancelled);
3398 if (httpc->in_request)
3400 httpc->in_request = NULL;
3401 if (httpc->out_request)
3403 httpc->out_request = NULL;
3404 if (httpc->app_info)
3406 httpc->app_info = NULL;
3407 if (httpc->session)
3409 httpc->session = NULL;
3411 if (httpc->cancel_event)
3412 CloseHandle(httpc->cancel_event);
3413 HeapFree(GetProcessHeap(), 0, httpc->servername);
3414 httpc->servername = NULL;
3415
3416 return 0;
3417}
3418
3420{
3421 rpcrt4_ncacn_http_close(conn); /* FIXME */
3422}
3423
3425{
3426 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3427
3428 SetEvent(httpc->cancel_event);
3429}
3430
3432{
3433 FIXME("\n");
3434 return RPC_S_ACCESS_DENIED;
3435}
3436
3438{
3439 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3440 BOOL ret;
3442
3447 return status == RPC_S_OK ? 0 : -1;
3448}
3449
3450static size_t rpcrt4_ncacn_http_get_top_of_tower(unsigned char *tower_data,
3451 const char *networkaddr,
3452 const char *endpoint)
3453{
3454 return rpcrt4_ip_tcp_get_top_of_tower(tower_data, networkaddr,
3456}
3457
3458static RPC_STATUS rpcrt4_ncacn_http_parse_top_of_tower(const unsigned char *tower_data,
3459 size_t tower_size,
3460 char **networkaddr,
3461 char **endpoint)
3462{
3463 return rpcrt4_ip_tcp_parse_top_of_tower(tower_data, tower_size,
3464 networkaddr, EPM_PROTOCOL_HTTP,
3465 endpoint);
3466}
3467
3468static const struct connection_ops conn_protseq_list[] = {
3469 { "ncacn_np",
3483 NULL,
3490 },
3491 { "ncalrpc",
3505 NULL,
3512 },
3513 { "ncacn_ip_tcp",
3527 NULL,
3534 },
3535 { "ncacn_http",
3556 },
3557};
3558
3559
3560static const struct protseq_ops protseq_list[] =
3561{
3562 {
3563 "ncacn_np",
3570 },
3571 {
3572 "ncalrpc",
3579 },
3580 {
3581 "ncacn_ip_tcp",
3588 },
3589};
3590
3591const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq)
3592{
3593 unsigned int i;
3594 for(i = 0; i < ARRAY_SIZE(protseq_list); i++)
3595 if (!strcmp(protseq_list[i].name, protseq))
3596 return &protseq_list[i];
3597 return NULL;
3598}
3599
3600static const struct connection_ops *rpcrt4_get_conn_protseq_ops(const char *protseq)
3601{
3602 unsigned int i;
3603 for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
3604 if (!strcmp(conn_protseq_list[i].name, protseq))
3605 return &conn_protseq_list[i];
3606 return NULL;
3607}
3608
3609/**** interface to rest of code ****/
3610
3612{
3613 TRACE("(Connection == ^%p)\n", Connection);
3614
3615 assert(!Connection->server);
3616 return Connection->ops->open_connection_client(Connection);
3617}
3618
3620{
3621 TRACE("(Connection == ^%p)\n", Connection);
3622 if (SecIsValidHandle(&Connection->ctx))
3623 {
3624 DeleteSecurityContext(&Connection->ctx);
3625 SecInvalidateHandle(&Connection->ctx);
3626 }
3627 rpcrt4_conn_close(Connection);
3628 return RPC_S_OK;
3629}
3630
3632 LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint,
3633 LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS, LPCWSTR CookieAuth)
3634{
3635 static LONG next_id;
3636 const struct connection_ops *ops;
3637 RpcConnection* NewConnection;
3638
3639 ops = rpcrt4_get_conn_protseq_ops(Protseq);
3640 if (!ops)
3641 {
3642 FIXME("not supported for protseq %s\n", Protseq);
3644 }
3645
3646 NewConnection = ops->alloc();
3647 NewConnection->ref = 1;
3648 NewConnection->server = server;
3649 NewConnection->ops = ops;
3650 NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
3651 NewConnection->Endpoint = RPCRT4_strdupA(Endpoint);
3652 NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions);
3653 NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth);
3655 NewConnection->NextCallId = 1;
3656
3657 SecInvalidateHandle(&NewConnection->ctx);
3658 if (AuthInfo) RpcAuthInfo_AddRef(AuthInfo);
3659 NewConnection->AuthInfo = AuthInfo;
3660 NewConnection->auth_context_id = InterlockedIncrement( &next_id );
3662 NewConnection->QOS = QOS;
3663
3664 list_init(&NewConnection->conn_pool_entry);
3665 list_init(&NewConnection->protseq_entry);
3666
3667 TRACE("connection: %p\n", NewConnection);
3668 *Connection = NewConnection;
3669
3670 return RPC_S_OK;
3671}
3672
3674{
3675 RpcConnection *connection;
3677
3678 err = RPCRT4_CreateConnection(&connection, old_connection->server, rpcrt4_conn_get_name(old_connection),
3679 old_connection->NetworkAddr, old_connection->Endpoint, NULL,
3680 old_connection->AuthInfo, old_connection->QOS, old_connection->CookieAuth);
3681 if (err != RPC_S_OK)
3682 return NULL;
3683
3684 rpcrt4_conn_handoff(old_connection, connection);
3685 if (old_connection->protseq)
3686 {
3687 EnterCriticalSection(&old_connection->protseq->cs);
3688 connection->protseq = old_connection->protseq;
3689 list_add_tail(&old_connection->protseq->connections, &connection->protseq_entry);
3690 LeaveCriticalSection(&old_connection->protseq->cs);
3691 }
3692 return connection;
3693}
3694
3696{
3697 HANDLE event = NULL;
3698
3699 if (connection->ref > 1)
3700 event = connection->wait_release = CreateEventW(NULL, TRUE, FALSE, NULL);
3701
3702 RPCRT4_ReleaseConnection(connection);
3703
3704 if(event)
3705 {
3708 }
3709}
3710
3712{
3713 LONG ref = InterlockedIncrement(&connection->ref);
3714 TRACE("%p ref=%u\n", connection, ref);
3715 return connection;
3716}
3717
3719{
3720 LONG ref;
3721
3722 /* protseq stores a list of active connections, but does not own references to them.
3723 * It may need to grab a connection from the list, which could lead to a race if
3724 * connection is being released, but not yet removed from the list. We handle that
3725 * by synchronizing on CS here. */
3726 if (connection->protseq)
3727 {
3728 EnterCriticalSection(&connection->protseq->cs);
3729 ref = InterlockedDecrement(&connection->ref);
3730 if (!ref)
3731 list_remove(&connection->protseq_entry);
3732 LeaveCriticalSection(&connection->protseq->cs);
3733 }
3734 else
3735 {
3736 ref = InterlockedDecrement(&connection->ref);
3737 }
3738
3739 TRACE("%p ref=%u\n", connection, ref);
3740
3741 if (!ref)
3742 {
3743 RPCRT4_CloseConnection(connection);
3744 RPCRT4_strfree(connection->Endpoint);
3745 RPCRT4_strfree(connection->NetworkAddr);
3746 HeapFree(GetProcessHeap(), 0, connection->NetworkOptions);
3747 HeapFree(GetProcessHeap(), 0, connection->CookieAuth);
3748 if (connection->AuthInfo) RpcAuthInfo_Release(connection->AuthInfo);
3749 if (connection->QOS) RpcQualityOfService_Release(connection->QOS);
3750
3751 /* server-only */
3752 if (connection->server_binding) RPCRT4_ReleaseBinding(connection->server_binding);
3753 else if (connection->assoc) RpcAssoc_ConnectionReleased(connection->assoc);
3754
3755 if (connection->wait_release) SetEvent(connection->wait_release);
3756
3757 HeapFree(GetProcessHeap(), 0, connection);
3758 }
3759}
3760
3761RPC_STATUS RPCRT4_IsServerListening(const char *protseq, const char *endpoint)
3762{
3763 const struct connection_ops *ops;
3764
3765 ops = rpcrt4_get_conn_protseq_ops(protseq);
3766 if (!ops)
3767 {
3768 FIXME("not supported for protseq %s\n", protseq);
3769 return RPC_S_INVALID_BINDING;
3770 }
3771
3772 return ops->is_server_listening(endpoint);
3773}
3774
3775RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data,
3776 size_t *tower_size,
3777 const char *protseq,
3778 const char *networkaddr,
3779 const char *endpoint)
3780{
3781 twr_empty_floor_t *protocol_floor;
3783
3784 *tower_size = 0;
3785
3786 if (!protseq_ops)
3788
3789 if (!tower_data)
3790 {
3791 *tower_size = sizeof(*protocol_floor);
3792 *tower_size += protseq_ops->get_top_of_tower(NULL, networkaddr, endpoint);
3793 return RPC_S_OK;
3794 }
3795
3796 protocol_floor = (twr_empty_floor_t *)tower_data;
3797 protocol_floor->count_lhs = sizeof(protocol_floor->protid);
3798 protocol_floor->protid = protseq_ops->epm_protocols[0];
3799 protocol_floor->count_rhs = 0;
3800
3801 tower_data += sizeof(*protocol_floor);
3802
3803 *tower_size = protseq_ops->get_top_of_tower(tower_data, networkaddr, endpoint);
3804 if (!*tower_size)
3805 return EPT_S_NOT_REGISTERED;
3806
3807 *tower_size += sizeof(*protocol_floor);
3808
3809 return RPC_S_OK;
3810}
3811
3812RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data,
3813 size_t tower_size,
3814 char **protseq,
3815 char **networkaddr,
3816 char **endpoint)
3817{
3818 const twr_empty_floor_t *protocol_floor;
3819 const twr_empty_floor_t *floor4;
3820 const struct connection_ops *protseq_ops = NULL;
3822 unsigned int i;
3823
3824 if (tower_size < sizeof(*protocol_floor))
3825 return EPT_S_NOT_REGISTERED;
3826
3827 protocol_floor = (const twr_empty_floor_t *)tower_data;
3828 tower_data += sizeof(*protocol_floor);
3829 tower_size -= sizeof(*protocol_floor);
3830 if ((protocol_floor->count_lhs != sizeof(protocol_floor->protid)) ||
3831 (protocol_floor->count_rhs > tower_size))
3832 return EPT_S_NOT_REGISTERED;
3833 tower_data += protocol_floor->count_rhs;
3834 tower_size -= protocol_floor->count_rhs;
3835
3836 floor4 = (const twr_empty_floor_t *)tower_data;
3837 if ((tower_size < sizeof(*floor4)) ||
3838 (floor4->count_lhs != sizeof(floor4->protid)))
3839 return EPT_S_NOT_REGISTERED;
3840
3841 for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
3842 if ((protocol_floor->protid == conn_protseq_list[i].epm_protocols[0]) &&
3843 (floor4->protid == conn_protseq_list[i].epm_protocols[1]))
3844 {
3846 break;
3847 }
3848
3849 if (!protseq_ops)
3850 return EPT_S_NOT_REGISTERED;
3851
3852 status = protseq_ops->parse_top_of_tower(tower_data, tower_size, networkaddr, endpoint);
3853
3854 if ((status == RPC_S_OK) && protseq)
3855 {
3856 *protseq = I_RpcAllocate(strlen(protseq_ops->name) + 1);
3857 strcpy(*protseq, protseq_ops->name);
3858 }
3859
3860 return status;
3861}
3862
3863/***********************************************************************
3864 * RpcNetworkIsProtseqValidW (RPCRT4.@)
3865 *
3866 * Checks if the given protocol sequence is known by the RPC system.
3867 * If it is, returns RPC_S_OK, otherwise RPC_S_PROTSEQ_NOT_SUPPORTED.
3868 *
3869 */
3871{
3872 char ps[0x10];
3873
3874 WideCharToMultiByte(CP_ACP, 0, protseq, -1,
3875 ps, sizeof ps, NULL, NULL);
3877 return RPC_S_OK;
3878
3879 FIXME("Unknown protseq %s\n", debugstr_w(protseq));
3880
3882}
3883
3884/***********************************************************************
3885 * RpcNetworkIsProtseqValidA (RPCRT4.@)
3886 */
3888{
3889 UNICODE_STRING protseqW;
3890
3891 if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
3892 {
3894 RtlFreeUnicodeString(&protseqW);
3895 return ret;
3896 }
3897 return RPC_S_OUT_OF_MEMORY;
3898}
3899
3900/***********************************************************************
3901 * RpcProtseqVectorFreeA (RPCRT4.@)
3902 */
3904{
3905 TRACE("(%p)\n", protseqs);
3906
3907 if (*protseqs)
3908 {
3909 unsigned int i;
3910 for (i = 0; i < (*protseqs)->Count; i++)
3911 HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3913 *protseqs = NULL;
3914 }
3915 return RPC_S_OK;
3916}
3917
3918/***********************************************************************
3919 * RpcProtseqVectorFreeW (RPCRT4.@)
3920 */
3922{
3923 TRACE("(%p)\n", protseqs);
3924
3925 if (*protseqs)
3926 {
3927 unsigned int i;
3928 for (i = 0; i < (*protseqs)->Count; i++)
3929 HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3931 *protseqs = NULL;
3932 }
3933 return RPC_S_OK;
3934}
3935
3936/***********************************************************************
3937 * RpcNetworkInqProtseqsW (RPCRT4.@)
3938 */
3940{
3941 RPC_PROTSEQ_VECTORW *pvector;
3942 unsigned int i;
3944
3945 TRACE("(%p)\n", protseqs);
3946
3947 *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAY_SIZE(protseq_list)));
3948 if (!*protseqs)
3949 goto end;
3950 pvector = *protseqs;
3951 pvector->Count = 0;
3952 for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3953 {
3954 pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
3955 if (pvector->Protseq[i] == NULL)
3956 goto end;
3958 (WCHAR*)pvector->Protseq[i], strlen(protseq_list[i].name) + 1);
3959 pvector->Count++;
3960 }
3961 status = RPC_S_OK;
3962
3963end:
3964 if (status != RPC_S_OK)
3966 return status;
3967}
3968
3969/***********************************************************************
3970 * RpcNetworkInqProtseqsA (RPCRT4.@)
3971 */
3973{
3974 RPC_PROTSEQ_VECTORA *pvector;
3975 unsigned int i;
3977
3978 TRACE("(%p)\n", protseqs);
3979
3980 *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAY_SIZE(protseq_list)));
3981 if (!*protseqs)
3982 goto end;
3983 pvector = *protseqs;
3984 pvector->Count = 0;
3985 for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3986 {
3987 pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
3988 if (pvector->Protseq[i] == NULL)
3989 goto end;
3990 strcpy((char*)pvector->Protseq[i], protseq_list[i].name);
3991 pvector->Count++;
3992 }
3993 status = RPC_S_OK;
3994
3995end:
3996 if (status != RPC_S_OK)
3998 return status;
3999}
unsigned char BOOLEAN
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
unsigned int dir
Definition: maze.c:112
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
LONG NTSTATUS
Definition: precomp.h:26
#define index(s, c)
Definition: various.h:29
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define ARRAY_SIZE(A)
Definition: main.h:20
#define U(x)
Definition: wordpad.c:45
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
static void list_init(struct list_entry *head)
Definition: list.h:51
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
static HANDLE thread
Definition: service.c:33
static SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: security.c:40
Definition: Header.h:9
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
time_t cur_time
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:674
BOOL WINAPI InitializeAcl(PACL pAcl, DWORD nAclLength, DWORD dwAclRevision)
Definition: security.c:1006
BOOL WINAPI ImpersonateNamedPipeClient(HANDLE hNamedPipe)
Definition: security.c:1024
BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision)
Definition: security.c:929
BOOL WINAPI AddAccessAllowedAce(PACL pAcl, DWORD dwAceRevision, DWORD AccessMask, PSID pSid)
Definition: security.c:1039
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:698
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define CP_ACP
Definition: compat.h:109
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define TRACE_ON(x)
Definition: compat.h:75
#define stricmp(_String1, _String2)
Definition: compat.h:24
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define lstrlenW
Definition: compat.h:750
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
BOOL WINAPI DECLSPEC_HOTPATCH CancelIoEx(HANDLE handle, LPOVERLAPPED overlapped)
Definition: file.c:3005
BOOL WINAPI RevertToSelf(void)
Definition: security.c:855
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182
static SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: security.c:14
USHORT port
Definition: uri.c:228
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1297
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5595
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersIn, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5500
HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:3469
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2114
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2248
BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags, LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
Definition: internet.c:4425
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(HINTERNET hInternet, INTERNET_STATUS_CALLBACK lpfnIntCB)
Definition: internet.c:2075
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3959
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1258
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
#define swprintf
Definition: precomp.h:40
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
INT WSAAPI WSAEventSelect(IN SOCKET s, IN WSAEVENT hEventObject, IN LONG lNetworkEvents)
Definition: select.c:182
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define assert(x)
Definition: debug.h:53
return ret
Definition: mutex.c:146
#define IPPROTO_TCP
Definition: ip.h:196
unsigned long u_long
Definition: linux.h:269
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
#define INFINITE
Definition: serial.h:102
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
#define EPM_PROTOCOL_NETBIOS
Definition: epm_towers.h:39
#define EPM_PROTOCOL_SMB
Definition: epm_towers.h:37
#define EPM_PROTOCOL_PIPE
Definition: epm_towers.h:38
#define EPM_PROTOCOL_IP
Definition: epm_towers.h:31
#define EPM_PROTOCOL_NCALRPC
Definition: epm_towers.h:34
#define EPM_PROTOCOL_TCP
Definition: epm_towers.h:29
#define EPM_PROTOCOL_HTTP
Definition: epm_towers.h:49
#define EPM_PROTOCOL_NCACN
Definition: epm_towers.h:33
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
#define local
Definition: zutil.h:30
int proxy
Definition: main.c:67
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
struct _cl_event * event
Definition: glext.h:7739
GLuint res
Definition: glext.h:9613
GLuint address
Definition: glext.h:9393
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLuint index
Definition: glext.h:6031
GLenum pname
Definition: glext.h:5645
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLbitfield flags
Definition: glext.h:7161
const GLint * first
Definition: glext.h:5794
GLuint GLfloat * val
Definition: glext.h:7180
GLfloat GLfloat p
Definition: glext.h:8902
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static unsigned char * in_buffer
Definition: iccvid.c:87
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define InterlockedExchangeAdd
Definition: interlocked.h:196
char hdr[14]
Definition: iptest.cpp:33
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_wn
Definition: kernel32.h:33
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define INET_ADDRSTRLEN
Definition: inet.h:142
#define error(str)
Definition: mkdosfs.c:1605
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ntohs(x)
Definition: module.h:210
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
int socklen_t
Definition: tcp.c:35
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37
static PVOID ptr
Definition: dispmode.c:27
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static const WCHAR url[]
Definition: encode.c:1384
static struct _PeImage bin
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:56
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
Definition: file.c:100
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
Definition: file.c:100
static int secure
Definition: server.c:138
static const WCHAR httpW[]
Definition: assoc.c:94
DWORD exp
Definition: msg.c:16058
static WCHAR password[]
Definition: url.c:33
#define min(a, b)
Definition: monoChain.cc:55
struct _ACL ACL
struct _ACCESS_ALLOWED_ACE ACCESS_ALLOWED_ACE
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:93
#define ioctlsocket
Definition: ncftp.h:481
#define closesocket
Definition: ncftp.h:477
unsigned int UINT
Definition: ndis.h:50
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1617
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG DaclSize
Definition: rtlfuncs.h:1618
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:433
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
#define GENERIC_ALL
Definition: nt_native.h:92
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define READ_CONTROL
Definition: nt_native.h:58
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FSCTL_PIPE_LISTEN
Definition: pipe.c:63
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4020
#define STATUS_PIPE_CONNECTED
Definition: ntstatus.h:508
long LONG
Definition: pedump.c:60
LONG SECURITY_STATUS
Definition: sspi.h:34
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:291
#define SECBUFFER_TOKEN
Definition: sspi.h:161
#define SECURITY_NETWORK_DREP
Definition: sspi.h:474
#define ISC_REQ_DELEGATE
Definition: sspi.h:362
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:363
#define SecInvalidateHandle(x)
Definition: sspi.h:58
WCHAR SEC_WCHAR
Definition: sspi.h:29
#define ISC_REQ_CONNECTION
Definition: sspi.h:373
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:371
#define err(...)
void RpcAssoc_ConnectionReleased(RpcAssoc *assoc)
Definition: rpc_assoc.c:447
ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1183
ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos)
Definition: rpc_binding.c:1360
ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1188
void RPCRT4_strfree(LPSTR src)
Definition: rpc_binding.c:104
RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding *Binding)
Definition: rpc_binding.c:254
LPWSTR RPCRT4_strndupW(LPCWSTR src, INT slen)
Definition: rpc_binding.c:91
ULONG RpcQualityOfService_Release(RpcQualityOfService *qos)
Definition: rpc_binding.c:1365
static const char * rpcrt4_conn_get_name(const RpcConnection *Connection)
Definition: rpc_binding.h:183
static RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
Definition: rpc_binding.h:215
#define RPCRT4_strdupA(x)
Definition: rpc_binding.h:151
secure_packet_direction
Definition: rpc_binding.h:31
#define RPCRT4_strdupW(x)
Definition: rpc_binding.h:152
static int rpcrt4_conn_close(RpcConnection *Connection)
Definition: rpc_binding.h:200
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
@ PKT_HTTP
Definition: rpc_defs.h:208
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len)
Definition: rpc_message.c:483
RPC_STATUS RPCRT4_default_authorize(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size)
Definition: rpc_message.c:872
RpcPktHdr * RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size)
Definition: rpc_message.c:291
BOOL RPCRT4_default_is_authorized(RpcConnection *Connection)
Definition: rpc_message.c:1122
RPC_STATUS RPCRT4_ValidateCommonHeader(const RpcPktCommonHdr *hdr)
Definition: rpc_message.c:1255
RPC_STATUS RPCRT4_default_inquire_auth_client(RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
Definition: rpc_message.c:1189
RPC_STATUS RPCRT4_ParseHttpFlowControlHeader(RpcPktHdr *header, unsigned char *data, BOOL server, ULONG *bytes_transmitted, ULONG *flow_control_increment, UUID *pipe_uuid)
Definition: rpc_message.c:637
DWORD RPCRT4_GetHeaderSize(const RpcPktHdr *Header)
Definition: rpc_message.c:57
RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn)
Definition: rpc_message.c:1159
RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3)
Definition: rpc_message.c:591
RPC_STATUS RPCRT4_default_secure_packet(RpcConnection *Connection, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size)
Definition: rpc_message.c:682
RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1)
Definition: rpc_message.c:566
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:344
RpcPktHdr * RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid)
Definition: rpc_message.c:384
RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn)
Definition: rpc_message.c:1131
void RPCRT4_new_client(RpcConnection *conn)
Definition: rpc_server.c:625
static struct list protseqs
Definition: rpc_server.c:68
#define HTTP_IDLE_TIME
static RPC_STATUS is_pipe_listening(const char *pipe_name)
static VOID WINAPI rpcrt4_http_internet_callback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
static HANDLE get_np_event(RpcConnection_np *connection)
Definition: rpc_transport.c:98
RPC_STATUS RPCRT4_IsServerListening(const char *protseq, const char *endpoint)
RPC_STATUS WINAPI RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA **protseqs)
static void * rpcrt4_protseq_sock_get_wait_array(RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
const struct protseq_ops * rpcrt4_get_protseq_ops(const char *protseq)
static int rpcrt4_ncacn_http_read(RpcConnection *Connection, void *buffer, unsigned int count)
static RpcConnection * rpcrt4_conn_tcp_alloc(void)
static RPC_STATUS rpcrt4_http_internet_connect(RpcConnection_http *httpc)
static void rpcrt4_ncacn_http_cancel_call(RpcConnection *Connection)
static const WCHAR digestW[]
static void release_np_event(RpcConnection_np *connection, HANDLE event)
static int rpcrt4_conn_np_close(RpcConnection *conn)
struct _RpcConnection_tcp RpcConnection_tcp
static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
static const struct @592 auth_schemes[]
static RPC_STATUS rpcrt4_ncacn_np_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
static void rpcrt4_conn_tcp_cancel_call(RpcConnection *conn)
static void rpcrt4_protseq_np_free_wait_array(RpcServerProtseq *protseq, void *array)
RPC_STATUS WINAPI RpcNetworkInqProtseqsA(RPC_PROTSEQ_VECTORA **protseqs)
static RPC_STATUS rpcrt4_ncacn_http_parse_top_of_tower(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
static RPC_STATUS rpcrt4_http_read_http_packet(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
static DWORD auth_scheme_from_header(const WCHAR *header)
static RPC_STATUS rpcrt4_http_prepare_out_pipe(HINTERNET out_request, RpcHttpAsyncData *async_data, HANDLE cancel_event, const UUID *connection_uuid, const UUID *out_pipe_uuid, ULONG *flow_control_increment, BOOL authorized)
static const WCHAR passportW[]
static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower(const unsigned char *tower_data, size_t tower_size, char **networkaddr, unsigned char tcp_protid, char **endpoint)
static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, unsigned char tcp_protid, const char *endpoint)
static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array)
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW(RPC_WSTR protseq)
static BOOL is_secure(RpcConnection_http *httpc)
RPC_STATUS RPCRT4_CreateConnection(RpcConnection **Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo *AuthInfo, RpcQualityOfService *QOS, LPCWSTR CookieAuth)
static BOOL rpcrt4_ncalrpc_is_authorized(RpcConnection *conn)
static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
static RPC_STATUS rpcrt4_http_prepare_in_pipe(HINTERNET in_request, RpcHttpAsyncData *async_data, HANDLE cancel_event, const UUID *connection_uuid, const UUID *in_pipe_uuid, const UUID *association_uuid, BOOL authorized)
static void rpcrt4_conn_np_cancel_call(RpcConnection *conn)
static const WCHAR basicW[]
static int rpcrt4_conn_tcp_wait_for_incoming_data(RpcConnection *Connection)
struct _HttpTimerThreadData HttpTimerThreadData
static RpcConnection * rpcrt4_ncacn_http_alloc(void)
static RpcServerProtseq * rpcrt4_protseq_np_alloc(void)
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
static void rpcrt4_conn_np_close_read(RpcConnection *conn)
static unsigned int decode_base64(const WCHAR *base64, unsigned int len, char *buf)
struct _RpcServerProtseq_sock RpcServerProtseq_sock
static RPC_STATUS rpcrt4_ncalrpc_secure_packet(RpcConnection *conn, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size)
static int rpcrt4_conn_tcp_close(RpcConnection *conn)
static const struct protseq_ops protseq_list[]
RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint)
static DWORD rpcrt4_http_timer_calc_timeout(DWORD *last_sent_time)
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
const WCHAR * str
static const WCHAR negotiateW[]
static RPC_STATUS authorize_request(RpcConnection_http *httpc, HINTERNET request)
#define DEFAULT_NCACN_HTTP_TIMEOUT
Definition: rpc_transport.c:57
static char decode_char(WCHAR c)
static RPC_STATUS rpcrt4_conn_np_revert_to_self(RpcConnection *conn)
static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int count)
static RPC_STATUS rpcrt4_ncacn_ip_tcp_open(RpcConnection *Connection)
static RPC_STATUS rpcrt4_ncalrpc_np_is_server_listening(const char *endpoint)
RPC_STATUS WINAPI RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW **protseqs)
static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint(RpcServerProtseq *protseq, const char *endpoint)
static RPC_STATUS rpcrt4_conn_open_pipe(RpcConnection *Connection, LPCSTR pname, BOOL wait)
static DWORD CALLBACK rpcrt4_http_timer_thread(PVOID param)
static RPC_STATUS rpcrt4_conn_tcp_is_server_listening(const char *endpoint)
unsigned int len
struct _RpcHttpAsyncData RpcHttpAsyncData
static void * rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
struct _RpcConnection_http RpcConnection_http
static int rpcrt4_conn_np_write(RpcConnection *conn, const void *buffer, unsigned int count)
static RPC_STATUS rpcrt4_ncalrpc_open(RpcConnection *Connection)
static struct authinfo * alloc_authinfo(void)
static RpcConnection * rpcrt4_conn_np_alloc(void)
Definition: rpc_transport.c:92
static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
static RPC_STATUS rpcrt4_ncacn_np_is_server_listening(const char *endpoint)
RPC_STATUS RPCRT4_CloseConnection(RpcConnection *Connection)
static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, char *data, int data_len)
static char * ncacn_pipe_name(const char *endpoint)
static RpcConnection * rpcrt4_spawn_connection(RpcConnection *old_connection)
static void rpcrt4_protseq_sock_free_wait_array(RpcServerProtseq *protseq, void *array)
static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, const char *endpoint)
RPC_STATUS RPCRT4_OpenClientConnection(RpcConnection *Connection)
static RPC_STATUS rpcrt4_ncacn_http_receive_fragment(RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
static size_t rpcrt4_ncalrpc_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, const char *endpoint)
static BOOL has_credentials(RpcConnection_http *httpc)
static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *conn)
static RPC_STATUS rpcrt4_ncacn_np_parse_top_of_tower(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
static void prepare_async_request(RpcHttpAsyncData *async_data)
static RPC_STATUS rpcrt4_ncacn_ip_tcp_parse_top_of_tower(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
struct _RpcServerProtseq_np RpcServerProtseq_np
static void rpcrt4_conn_tcp_close_read(RpcConnection *conn)
static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
static ULONG RpcHttpAsyncData_AddRef(RpcHttpAsyncData *data)
static BOOL get_authvalue(HINTERNET request, DWORD scheme, WCHAR *buffer, DWORD buflen)
static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(RpcServerProtseq *protseq, const char *endpoint)
static RPC_STATUS set_auth_cookie(RpcConnection_http *httpc, const WCHAR *value)
static int rpcrt4_ncacn_http_write(RpcConnection *Connection, const void *buffer, unsigned int count)
static BOOL rpcrt4_sock_wait_for_send(RpcConnection_tcp *tcpc)
static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array)
static RPC_STATUS rpcrt4_ncalrpc_parse_top_of_tower(const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint)
static const struct connection_ops conn_protseq_list[]
static RPC_STATUS rpcrt4_ncacn_http_open(RpcConnection *Connection)
static RPC_STATUS rpcrt4_ncacn_http_is_server_listening(const char *endpoint)
static RpcServerProtseq * rpcrt4_protseq_sock_alloc(void)
void rpcrt4_conn_release_and_wait(RpcConnection *connection)
static char * ncalrpc_pipe_name(const char *endpoint)
static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data)
RpcConnection * RPCRT4_GrabConnection(RpcConnection *connection)
static int rpcrt4_ncacn_http_close(RpcConnection *Connection)
static int rpcrt4_conn_tcp_read(RpcConnection *Connection, void *buffer, unsigned int count)
RPC_STATUS WINAPI RpcNetworkInqProtseqsW(RPC_PROTSEQ_VECTORW **protseqs)
static void rpcrt4_protseq_sock_signal_state_changed(RpcServerProtseq *protseq)
static int rpcrt4_conn_np_wait_for_incoming_data(RpcConnection *conn)
static size_t rpcrt4_ncacn_ip_tcp_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, const char *endpoint)
static RPC_STATUS rpcrt4_ncacn_np_open(RpcConnection *Connection)
static void destroy_authinfo(struct authinfo *info)
static RPC_STATUS rpcrt4_conn_np_impersonate_client(RpcConnection *conn)
static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc)
static int rpcrt4_conn_tcp_write(RpcConnection *Connection, const void *buffer, unsigned int count)
struct _RpcConnection_np RpcConnection_np
static VOID rpcrt4_http_keep_connection_active_timer_proc(PVOID param, BOOLEAN dummy)
static void rpcrt4_ncacn_http_close_read(RpcConnection *conn)
static RPC_STATUS rpcrt4_ncacn_http_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
static RPC_STATUS rpcrt4_ncalrpc_inquire_auth_client(RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
static BOOL rpcrt4_sock_wait_init(RpcConnection_tcp *tcpc)
static void rpcrt4_conn_np_handoff(RpcConnection_np *old_npc, RpcConnection_np *new_npc)
static RPC_STATUS rpcrt4_ncalrpc_authorize(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size)
static void rpcrt4_protseq_np_signal_state_changed(RpcServerProtseq *protseq)
static const WCHAR ntlmW[]
static RPC_STATUS rpcrt4_ncalrpc_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
DWORD scheme
static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint(RpcServerProtseq *protseq, const char *endpoint)
void RPCRT4_ReleaseConnection(RpcConnection *connection)
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
static size_t rpcrt4_ncacn_http_get_top_of_tower(unsigned char *tower_data, const char *networkaddr, const char *endpoint)
static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
static int rpcrt4_ncacn_http_wait_for_incoming_data(RpcConnection *Connection)
RPC_STATUS WINAPI RpcNetworkIsProtseqValidA(RPC_CSTR protseq)
static RPC_STATUS rpcrt4_conn_tcp_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
#define RPC_C_HTTP_FLAG_USE_SSL
Definition: rpcdce.h:198
unsigned short * RPC_WSTR
Definition: rpcdce.h:46
#define RPC_C_HTTP_AUTHN_SCHEME_PASSPORT
Definition: rpcdce.h:207
unsigned char * RPC_CSTR
Definition: rpcdce.h:45
#define RPC_C_IMP_LEVEL_IDENTIFY
Definition: rpcdce.h:175
#define RPC_C_AUTHZ_NONE
Definition: rpcdce.h:167
#define RPC_C_HTTP_AUTHN_SCHEME_DIGEST
Definition: rpcdce.h:208
#define RPC_C_QOS_IDENTITY_DYNAMIC
Definition: rpcdce.h:181
#define RPC_C_AUTHN_LEVEL_PKT_PRIVACY
Definition: rpcdce.h:151
#define RPC_C_HTTP_AUTHN_TARGET_SERVER
Definition: rpcdce.h:202
#define RPC_C_IMP_LEVEL_DELEGATE
Definition: rpcdce.h:177
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176
#define RPC_C_IMP_LEVEL_ANONYMOUS
Definition: rpcdce.h:174
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
#define RPC_C_AUTHN_WINNT
Definition: rpcdce.h:158
#define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE
Definition: rpcdce.h:209
#define RPC_C_HTTP_AUTHN_SCHEME_NTLM
Definition: rpcdce.h:206
#define RPC_C_IMP_LEVEL_DEFAULT
Definition: rpcdce.h:173
#define NDR_LOCAL_DATA_REPRESENTATION
Definition: rpcndr.h:107
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
#define RPC_S_OK
Definition: rpcnterr.h:22
#define RPC_S_ACCESS_DENIED
Definition: rpcnterr.h:29
void WINAPI I_RpcFree(void *Object)
Definition: rpcrt4_main.c:724
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:305
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:716
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define CP_UTF8
Definition: nls.h:20
long RPC_STATUS
Definition: rpc.h:48
strcat
Definition: string.h:92
strcpy
Definition: string.h:131
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
#define memset(x, y, z)
Definition: compat.h:39
static FILE * client
Definition: client.c:41
BOOL WINAPI SetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl, BOOL bDaclDefaulted)
Definition: sec.c:262
BOOL WINAPI SetSecurityDescriptorOwner(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pOwner, BOOL bOwnerDefaulted)
Definition: sec.c:312
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR pAbsoluteSecurityDescriptor, PSECURITY_DESCRIPTOR pSelfRelativeSecurityDescriptor, LPDWORD lpdwBufferLength)
Definition: sec.c:214
BOOL WINAPI SetSecurityDescriptorGroup(PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID pGroup, BOOL bGroupDefaulted)
Definition: sec.c:288
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
INT WSAAPI listen(IN SOCKET s, IN INT backlog)
Definition: sockctrl.c:123
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define TRACE(s)
Definition: solgame.cpp:4
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
DWORD_PTR dwResult
Definition: wininet.h:155
unsigned short frag_len
Definition: rpc_defs.h:33
unsigned short num_data_items
Definition: rpc_defs.h:139
unsigned short flags
Definition: rpc_defs.h:138
DWORD dwStructSize
Definition: wininet.h:211
DWORD dwUrlPathLength
Definition: wininet.h:223
DWORD dwExtraInfoLength
Definition: wininet.h:225
LPWSTR lpszPassword
Definition: wininet.h:220
LPWSTR lpszHostName
Definition: wininet.h:215
DWORD dwUserNameLength
Definition: wininet.h:219
DWORD dwHostNameLength
Definition: wininet.h:216
LPWSTR lpszScheme
Definition: wininet.h:212
LPWSTR lpszUserName
Definition: wininet.h:218
LPWSTR lpszUrlPath
Definition: wininet.h:222
LPWSTR lpszExtraInfo
Definition: wininet.h:224
DWORD dwPasswordLength
Definition: wininet.h:221
INTERNET_PORT nPort
Definition: wininet.h:217
DWORD dwSchemeLength
Definition: wininet.h:213
DWORD dwBufferLength
Definition: wininet.h:278
DWORD dwBufferTotal
Definition: wininet.h:279
LPVOID lpvBuffer
Definition: wininet.h:277
DWORD dwStructSize
Definition: wininet.h:272
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
unsigned char * Protseq[1]
Definition: rpcdce.h:91
unsigned int Count
Definition: rpcdce.h:90
unsigned int Count
Definition: rpcdce.h:96
unsigned short * Protseq[1]
Definition: rpcdce.h:97
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
union _RPC_SECURITY_QOS_V2_W::@3406 u
PRTL_CRITICAL_SECTION_DEBUG DebugInfo
Definition: rtltypes.h:1450
RpcConnection common
RpcHttpAsyncData * async_data
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:87
RpcConnection common
Definition: rpc_transport.c:83
RpcConnection common
LPSTR NetworkAddr
Definition: rpc_binding.h:67
struct _RpcAssoc * assoc
Definition: rpc_binding.h:88
struct list conn_pool_entry
Definition: rpc_binding.h:85
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
USHORT NextCallId
Definition: rpc_binding.h:93
LPWSTR NetworkOptions
Definition: rpc_binding.h:69
struct _RpcBinding * server_binding
Definition: rpc_binding.h:96
USHORT MaxTransmissionSize
Definition: rpc_binding.h:71
HANDLE wait_release
Definition: rpc_binding.h:66
const struct connection_ops * ops
Definition: rpc_binding.h:70
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
struct list protseq_entry
Definition: rpc_binding.h:94
struct _RpcServerProtseq * protseq
Definition: rpc_binding.h:95
LPWSTR CookieAuth
Definition: rpc_binding.h:82
CtxtHandle ctx
Definition: rpc_binding.h:74
ULONG auth_context_id
Definition: rpc_binding.h:78
INTERNET_BUFFERSW inet_buffers
CRITICAL_SECTION cs
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
RpcServerProtseq common
RpcServerProtseq common
struct list listeners
Definition: rpc_server.h:36
CRITICAL_SECTION cs
Definition: rpc_server.h:38
LPVOID lpSecurityDescriptor
Definition: compat.h:193
unsigned short * Domain
Definition: rpcdce.h:225
unsigned short * User
Definition: rpcdce.h:223
unsigned short * Password
Definition: rpcdce.h:227
ULONG cBuffers
Definition: sspi.h:182
ULONG ulVersion
Definition: sspi.h:181
ULONG cbMaxToken
Definition: sspi.h:117
size_t ai_addrlen
Definition: ws2def.h:669
struct sockaddr * ai_addr
Definition: ws2def.h:671
int ai_socktype
Definition: ws2def.h:667
int ai_protocol
Definition: ws2def.h:668
struct addrinfo * ai_next
Definition: ws2def.h:672
int ai_family
Definition: ws2def.h:666
char * data
DWORD scheme
CredHandle cred
CtxtHandle ctx
TimeStamp exp
unsigned int data_len
ULONG max_token
RpcConnection *(* alloc)(void)
Definition: rpc_binding.h:102
RPC_STATUS(* is_server_listening)(const char *endpoint)
Definition: rpc_binding.h:110
Definition: nis.h:10
Definition: txthost.c:37
Definition: tcpip.h:126
in_addr_t s_addr
Definition: inet.h:64
Definition: name.c:39
Definition: getopt.h:109
const char * name
Definition: rpc_server.h:50
Definition: send.c:48
Definition: tftpd.h:86
Definition: tcpcore.h:1455
Definition: ps.c:97
Definition: dhcpd.h:245
u_int16 count_lhs
Definition: epm_towers.h:83
u_int16 count_rhs
Definition: epm_towers.h:85
u_int16 count_lhs
Definition: epm_towers.h:75
u_int16 count_rhs
Definition: epm_towers.h:77
u_int32 ipv4addr
Definition: epm_towers.h:78
u_int16 count_lhs
Definition: epm_towers.h:67
u_int16 port
Definition: epm_towers.h:70
u_int16 count_rhs
Definition: epm_towers.h:69
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
Definition: synch.c:151
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
DWORD WINAPI WaitForMultipleObjectsEx(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:169
#define TCP_NODELAY
Definition: tcpdef.h:117
#define STATUS_PENDING
Definition: telnetd.h:14
Character const *const prefix
Definition: tempnam.cpp:195
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define MAKEWORD(a, b)
Definition: typedefs.h:248
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
static EFI_HANDLE * handles
Definition: uefidisk.c:62
RpcPktHttpHdr http
Definition: rpc_defs.h:159
RpcPktCommonHdr common
Definition: rpc_defs.h:152
Definition: pdh_main.c:96
const char *WSAAPI inet_ntop(int af, const void *src, char *dst, size_t cnt)
Definition: unix_func.c:8
static rfbScreenInfoPtr server
Definition: vnc.c:74
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define NMPWAIT_WAIT_FOREVER
Definition: winbase.h:135
#define SECURITY_DELEGATION
Definition: winbase.h:523
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:136
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:166
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define WAIT_IO_COMPLETION
Definition: winbase.h:388
#define SECURITY_IMPERSONATION
Definition: winbase.h:522
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
#define SECURITY_ANONYMOUS
Definition: winbase.h:520
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:172
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define SECURITY_SQOS_PRESENT
Definition: winbase.h:526
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define SECURITY_IDENTIFICATION
Definition: winbase.h:521
#define WAIT_OBJECT_0
Definition: winbase.h:383
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:170
#define WAIT_FAILED
Definition: winbase.h:390
#define PIPE_UNLIMITED_INSTANCES
Definition: winbase.h:177
#define SECURITY_CONTEXT_TRACKING
Definition: winbase.h:524
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:267
#define WINAPI
Definition: msvc.h:6
#define RPC_S_SERVER_TOO_BUSY
Definition: winerror.h:1390
#define RPC_S_PROTSEQ_NOT_SUPPORTED
Definition: winerror.h:1370
#define ERROR_BAD_NETPATH
Definition: winerror.h:267
#define SEC_E_OK
Definition: winerror.h:3450
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1388
#define EPT_S_NOT_REGISTERED
Definition: winerror.h:1418
#define WSAEWOULDBLOCK
Definition: winerror.h:2851
#define RPC_S_CANT_CREATE_ENDPOINT
Definition: winerror.h:1387
#define RPC_S_CALL_CANCELLED
Definition: winerror.h:1482
#define ERROR_PIPE_BUSY
Definition: winerror.h:405
#define ERROR_FILE_EXISTS
Definition: winerror.h:287
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1395
#define ERROR_CANNOT_IMPERSONATE
Definition: winerror.h:1194
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1430
#define RPC_S_NOT_LISTENING
Definition: winerror.h:1382
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:4324
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1389
#define RPC_S_INVALID_ENDPOINT_FORMAT
Definition: winerror.h:1373
#define WSAEADDRINUSE
Definition: winerror.h:2864
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1369
#define RPC_S_DUPLICATE_ENDPOINT
Definition: winerror.h:1405
#define RPC_S_INVALID_RPC_PROTSEQ
Definition: winerror.h:1371
#define WSAEINTR
Definition: winerror.h:2841
#define HTTP_STATUS_OK
Definition: winhttp.h:240
WORD INTERNET_PORT
Definition: winhttp.h:38
#define HTTP_STATUS_DENIED
Definition: winhttp.h:256
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:37
BOOL WINAPI InternetSetCookieW(const WCHAR *url, const WCHAR *name, const WCHAR *data)
Definition: cookie.c:1122
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
struct _INTERNET_BUFFERSW INTERNET_BUFFERSW
#define INTERNET_FLAG_PRAGMA_NOCACHE
Definition: wininet.h:85
#define INTERNET_FLAG_NO_AUTO_REDIRECT
Definition: wininet.h:73
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
#define INTERNET_FLAG_KEEP_CONNECTION
Definition: wininet.h:72
#define HTTP_QUERY_STATUS_TEXT
Definition: wininet.h:1543
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define INTERNET_FLAG_NO_CACHE_WRITE
Definition: wininet.h:66
#define INTERNET_FLAG_SECURE
Definition: wininet.h:71
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
#define HTTP_QUERY_WWW_AUTHENTICATE
Definition: wininet.h:1563
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
#define INTERNET_FLAG_NO_AUTH
Definition: wininet.h:76
#define IRF_ASYNC
Definition: wininet.h:622
struct _QualityOfService QOS
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:131
#define FD_READ
Definition: winsock.h:405
#define FD_WRITE
Definition: winsock.h:406
#define PF_INET
Definition: winsock.h:373
#define FD_CLOSE
Definition: winsock.h:410
#define PF_UNSPEC
Definition: winsock.h:371
#define SOCKET_ERROR
Definition: winsock.h:333
#define AF_INET6
Definition: winsock.h:369
#define SD_RECEIVE
Definition: winsock.h:54
#define FIONBIO
Definition: winsock.h:149
#define FD_ACCEPT
Definition: winsock.h:408
#define snprintf
Definition: wintirpc.h:48
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
#define AI_NUMERICHOST
Definition: ws2def.h:295
#define NI_NUMERICHOST
Definition: ws2def.h:354
#define AI_PASSIVE
Definition: ws2def.h:293
#define NI_MAXSERV
Definition: ws2def.h:360
#define NI_NUMERICSERV
Definition: ws2def.h:356
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define EAI_NONAME
Definition: ws2tcpip.h:38
#define EAI_SERVICE
Definition: ws2tcpip.h:39
#define getaddrinfo
Definition: wspiapi.h:44
#define getnameinfo
Definition: wspiapi.h:45
#define freeaddrinfo
Definition: wspiapi.h:46
#define SECURITY_ANONYMOUS_LOGON_RID
Definition: setypes.h:563
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:581
#define SECURITY_WORLD_SID_AUTHORITY
Definition: setypes.h:527
#define SECURITY_WORLD_RID
Definition: setypes.h:541
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:652
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193