ReactOS 0.4.16-dev-1946-g52006dd
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#include "ws2tcpip.h"
29
30#include <stdarg.h>
31#include <stdio.h>
32#include <string.h>
33#include <assert.h>
34
35#include "windef.h"
36#include "winbase.h"
37#include "winnls.h"
38#include "winerror.h"
39#include "wininet.h"
40#include "winternl.h"
41#include "winioctl.h"
42
43#include "rpc.h"
44#include "rpcndr.h"
45
46#include "wine/debug.h"
47
48#include "rpc_binding.h"
49#include "rpc_assoc.h"
50#include "rpc_message.h"
51#include "rpc_server.h"
52#include "epm_towers.h"
53
54#define DEFAULT_NCACN_HTTP_TIMEOUT (60 * 1000)
55
57
58#ifdef __REACTOS__ /* FIXME: Inspect */
60{
62
64 if (io_status.Status)
65 {
67 return FALSE;
68 }
69 return TRUE;
70}
71#define CancelIoEx CancelIoEx_
72#endif
73
75
76/**** ncacn_np support ****/
77
78typedef struct _RpcConnection_np
79{
88
90{
91 RpcConnection_np *npc = calloc(1, sizeof(RpcConnection_np));
92 return &npc->common;
93}
94
96{
98 return event ? event : CreateEventW(NULL, TRUE, FALSE, NULL);
99}
100
102{
103 event = InterlockedExchangePointer(&connection->event_cache, event);
104 if (event)
106}
107
108#ifdef __REACTOS__
126static DWORD
127rpcrt4_create_pipe_security(PSECURITY_DESCRIPTOR *SecDesc)
128{
129 DWORD ErrCode;
130 PACL Dacl;
131 ULONG DaclSize, RelSDSize = 0;
132 PSID EveryoneSid = NULL, AnonymousSid = NULL, AdminsSid = NULL;
133 PSECURITY_DESCRIPTOR AbsSD = NULL, RelSD = NULL;
136
138 1,
140 0, 0, 0, 0, 0, 0, 0,
141 &EveryoneSid))
142 {
143 ErrCode = GetLastError();
144 ERR("rpcrt4_create_pipe_security(): Failed to allocate Everyone SID (error %lu)\n", ErrCode);
145 return ErrCode;
146 }
147
149 1,
151 0, 0, 0, 0, 0, 0, 0,
152 &AnonymousSid))
153 {
154 ErrCode = GetLastError();
155 ERR("rpcrt4_create_pipe_security(): Failed to allocate Anonymous SID (error %lu)\n", ErrCode);
156 goto Quit;
157 }
158
160 2,
163 0, 0, 0, 0, 0, 0,
164 &AdminsSid))
165 {
166 ErrCode = GetLastError();
167 ERR("rpcrt4_create_pipe_security(): Failed to allocate Admins SID (error %lu)\n", ErrCode);
168 goto Quit;
169 }
170
172 if (AbsSD == NULL)
173 {
174 ErrCode = ERROR_OUTOFMEMORY;
175 ERR("rpcrt4_create_pipe_security(): Failed to allocate absolute SD\n");
176 goto Quit;
177 }
178
180 {
181 ErrCode = GetLastError();
182 ERR("rpcrt4_create_pipe_security(): Failed to create absolute SD (error %lu)\n", ErrCode);
183 goto Quit;
184 }
185
186 DaclSize = sizeof(ACL) +
187 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(EveryoneSid) +
188 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(AnonymousSid) +
189 sizeof(ACCESS_ALLOWED_ACE) + RtlLengthSid(AdminsSid);
190
192 if (Dacl == NULL)
193 {
194 ErrCode = ERROR_OUTOFMEMORY;
195 ERR("rpcrt4_create_pipe_security(): Failed to allocate DACL\n");
196 goto Quit;
197 }
198
200 {
201 ErrCode = GetLastError();
202 ERR("rpcrt4_create_pipe_security(): Failed to create DACL (error %lu)\n", ErrCode);
203 goto Quit;
204 }
205
209 EveryoneSid))
210 {
211 ErrCode = GetLastError();
212 ERR("rpcrt4_create_pipe_security(): Failed to set up ACE for Everyone SID (error %lu)\n", ErrCode);
213 goto Quit;
214 }
215
219 AnonymousSid))
220 {
221 ErrCode = GetLastError();
222 ERR("rpcrt4_create_pipe_security(): Failed to set up ACE for Anonymous SID (error %lu)\n", ErrCode);
223 goto Quit;
224 }
225
229 AdminsSid))
230 {
231 ErrCode = GetLastError();
232 ERR("rpcrt4_create_pipe_security(): Failed to set up ACE for Admins SID (error %lu)\n", ErrCode);
233 goto Quit;
234 }
235
237 {
238 ErrCode = GetLastError();
239 ERR("rpcrt4_create_pipe_security(): Failed to set DACL to absolute SD (error %lu)\n", ErrCode);
240 goto Quit;
241 }
242
243 if (!SetSecurityDescriptorOwner(AbsSD, AdminsSid, FALSE))
244 {
245 ErrCode = GetLastError();
246 ERR("rpcrt4_create_pipe_security(): Failed to set SD owner (error %lu)\n", ErrCode);
247 goto Quit;
248 }
249
250 if (!SetSecurityDescriptorGroup(AbsSD, AdminsSid, FALSE))
251 {
252 ErrCode = GetLastError();
253 ERR("rpcrt4_create_pipe_security(): Failed to set SD group (error %lu)\n", ErrCode);
254 goto Quit;
255 }
256
257 if (MakeSelfRelativeSD(AbsSD, NULL, &RelSDSize) ||
259 {
260 ErrCode = GetLastError();
261 ERR("rpcrt4_create_pipe_security(): error %lu, expected ERROR_INSUFFICIENT_BUFFER\n", ErrCode);
262 goto Quit;
263 }
264
265 RelSD = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, RelSDSize);
266 if (RelSD == NULL)
267 {
268 ErrCode = ERROR_OUTOFMEMORY;
269 ERR("rpcrt4_create_pipe_security(): Failed to allocate relative SD\n");
270 goto Quit;
271 }
272
273 if (!MakeSelfRelativeSD(AbsSD, RelSD, &RelSDSize))
274 {
275 ErrCode = GetLastError();
276 ERR("rpcrt4_create_pipe_security(): Failed to allocate relative SD (error %lu)\n", ErrCode);
277 HeapFree(GetProcessHeap(), 0, RelSD);
278 goto Quit;
279 }
280
281 *SecDesc = RelSD;
282 ErrCode = ERROR_SUCCESS;
283
284Quit:
285 if (EveryoneSid != NULL)
286 FreeSid(EveryoneSid);
287
288 if (AnonymousSid != NULL)
289 FreeSid(AnonymousSid);
290
291 if (AdminsSid != NULL)
292 FreeSid(AdminsSid);
293
294 if (Dacl != NULL)
296
297 if (AbsSD != NULL)
298 HeapFree(GetProcessHeap(), 0, AbsSD);
299
300 return ErrCode;
301}
302#endif
303
305{
306 RpcConnection_np *connection = (RpcConnection_np *) conn;
307#ifdef __REACTOS__
308 DWORD ErrCode;
309 SECURITY_ATTRIBUTES SecurityAttributes;
310 PSECURITY_DESCRIPTOR PipeSecDesc;
311#endif
312
313 TRACE("listening on %s\n", connection->listen_pipe);
314
315#ifdef __REACTOS__
316 ErrCode = rpcrt4_create_pipe_security(&PipeSecDesc);
317 if (ErrCode != ERROR_SUCCESS)
318 {
319 ERR("rpcrt4_conn_create_pipe(): Pipe security descriptor creation failed\n");
321 }
322
323 SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
324 SecurityAttributes.lpSecurityDescriptor = PipeSecDesc;
325 SecurityAttributes.bInheritHandle = FALSE;
326
330 RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, &SecurityAttributes);
331 HeapFree(GetProcessHeap(), 0, PipeSecDesc);
332#else
337#endif
338 if (connection->pipe == INVALID_HANDLE_VALUE)
339 {
340 WARN("CreateNamedPipe failed with error %ld\n", GetLastError());
342 {
344 }
345 else
346 {
348 }
349 }
350
351 return RPC_S_OK;
352}
353
355{
356 RpcConnection_np *npc = (RpcConnection_np *) Connection;
357 HANDLE pipe;
358 DWORD err, dwMode;
359
360 TRACE("connecting to %s\n", pname);
361
362 while (TRUE) {
363 DWORD dwFlags = 0;
364 if (Connection->QOS)
365 {
367 switch (Connection->QOS->qos->ImpersonationType)
368 {
370 /* FIXME: what to do here? */
371 break;
374 break;
377 break;
380 break;
383 break;
384 }
387 }
390 if (pipe != INVALID_HANDLE_VALUE) break;
391 err = GetLastError();
392 if (err == ERROR_PIPE_BUSY) {
394 TRACE("retrying busy server\n");
395 continue;
396 }
397 TRACE("connection failed, error=%lx\n", err);
399#ifdef __REACTOS__
400 } else if (err == ERROR_BAD_NETPATH) {
401 TRACE("connection failed, error=%x\n", err);
403#endif
404 }
405 if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
406 err = GetLastError();
407 WARN("connection failed, error=%lx\n", err);
409 }
410 }
411
412 /* success */
413 /* pipe is connected; change to message-read mode. */
414 dwMode = PIPE_READMODE_MESSAGE;
415 SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
416 npc->pipe = pipe;
417
418 return RPC_S_OK;
419}
420
421static char *ncalrpc_pipe_name(const char *endpoint)
422{
423 static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
424 char *pipe_name;
425
426 /* protseq=ncalrpc: supposed to use NT LPC ports,
427 * but we'll implement it with named pipes for now */
428 pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
429 strcat(strcpy(pipe_name, prefix), endpoint);
430 return pipe_name;
431}
432
434{
435 RpcConnection_np *npc = (RpcConnection_np *) Connection;
437 LPSTR pname;
438
439 /* already connected? */
440 if (npc->pipe)
441 return RPC_S_OK;
442
443 pname = ncalrpc_pipe_name(Connection->Endpoint);
444 r = rpcrt4_conn_open_pipe(Connection, pname, TRUE);
446
447 return r;
448}
449
451{
453 RpcConnection *Connection;
454 char generated_endpoint[22];
455
456 if (!endpoint)
457 {
458 static LONG lrpc_nameless_id;
459 DWORD process_id = GetCurrentProcessId();
460 ULONG id = InterlockedIncrement(&lrpc_nameless_id);
461 snprintf(generated_endpoint, sizeof(generated_endpoint),
462 "LRPC%08lx.%08lx", process_id, id);
463 endpoint = generated_endpoint;
464 }
465
466 r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL,
468 if (r != RPC_S_OK)
469 return r;
470
471 ((RpcConnection_np*)Connection)->listen_pipe = ncalrpc_pipe_name(Connection->Endpoint);
472 r = rpcrt4_conn_create_pipe(Connection);
473
474 EnterCriticalSection(&protseq->cs);
475 list_add_head(&protseq->listeners, &Connection->protseq_entry);
476 Connection->protseq = protseq;
477 LeaveCriticalSection(&protseq->cs);
478
479 return r;
480}
481
482#ifdef __REACTOS__
483static char *ncacn_pipe_name(const char *server, const char *endpoint)
484#else
485static char *ncacn_pipe_name(const char *endpoint)
486#endif
487{
488#ifdef __REACTOS__
489 static const char prefix[] = "\\\\";
490 static const char local[] = ".";
491 char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
492 DWORD bufLen = ARRAY_SIZE(ComputerName);
493#else
494 static const char prefix[] = "\\\\.";
495#endif
496 char *pipe_name;
497
498#ifdef __REACTOS__
499 if (server != NULL && *server != 0)
500 {
501 /* Trim any leading UNC server prefix. */
502 if (server[0] == '\\' && server[1] == '\\')
503 server += 2;
504
505 /* If the server represents the local computer, use instead
506 * the local prefix to avoid a round in UNC name resolution. */
507 if (GetComputerNameA(ComputerName, &bufLen) &&
508 (stricmp(ComputerName, server) == 0))
509 {
510 server = local;
511 }
512 }
513 else
514 {
515 server = local;
516 }
517#endif
518
519 /* protseq=ncacn_np: named pipes */
520#ifdef __REACTOS__
521 pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
522 strcpy(pipe_name, prefix);
523 strcat(pipe_name, server);
524 strcat(pipe_name, endpoint);
525#else
526 pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
527 strcat(strcpy(pipe_name, prefix), endpoint);
528#endif
529 return pipe_name;
530}
531
533{
534 RpcConnection_np *npc = (RpcConnection_np *) Connection;
536 LPSTR pname;
537
538 /* already connected? */
539 if (npc->pipe)
540 return RPC_S_OK;
541
542#ifdef __REACTOS__
543 pname = ncacn_pipe_name(Connection->NetworkAddr, Connection->Endpoint);
544#else
545 pname = ncacn_pipe_name(Connection->Endpoint);
546#endif
547 r = rpcrt4_conn_open_pipe(Connection, pname, FALSE);
549
550 return r;
551}
552
554{
556 RpcConnection *Connection;
557 char generated_endpoint[26];
558
559 if (!endpoint)
560 {
561 static LONG np_nameless_id;
562 DWORD process_id = GetCurrentProcessId();
563 ULONG id = InterlockedExchangeAdd(&np_nameless_id, 1 );
564 snprintf(generated_endpoint, sizeof(generated_endpoint),
565 "\\\\pipe\\\\%08lx.%03lx", process_id, id);
566 endpoint = generated_endpoint;
567 }
568
569 r = RPCRT4_CreateConnection(&Connection, TRUE, protseq->Protseq, NULL,
571 if (r != RPC_S_OK)
572 return r;
573
574#ifdef __REACTOS__
575 ((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(NULL, Connection->Endpoint);
576#else
577 ((RpcConnection_np*)Connection)->listen_pipe = ncacn_pipe_name(Connection->Endpoint);
578#endif
579 r = rpcrt4_conn_create_pipe(Connection);
580
581 EnterCriticalSection(&protseq->cs);
582 list_add_head(&protseq->listeners, &Connection->protseq_entry);
583 Connection->protseq = protseq;
584 LeaveCriticalSection(&protseq->cs);
585
586 return r;
587}
588
590{
591 /* because of the way named pipes work, we'll transfer the connected pipe
592 * to the child, then reopen the server binding to continue listening */
593
594 new_npc->pipe = old_npc->pipe;
595 old_npc->pipe = 0;
596 assert(!old_npc->listen_event);
597}
598
600{
603
606
607 /* Store the local computer name as the NetworkAddr for ncacn_np as long as
608 * we don't support named pipes over the network. */
609 new_conn->NetworkAddr = malloc(len);
610 if (!GetComputerNameA(new_conn->NetworkAddr, &len))
611 {
612 ERR("Failed to retrieve the computer name, error %lu\n", GetLastError());
614 }
615
616 return status;
617}
618
619static RPC_STATUS is_pipe_listening(const char *pipe_name)
620{
621 return WaitNamedPipeA(pipe_name, 1) ? RPC_S_OK : RPC_S_NOT_LISTENING;
622}
623
625{
626 char *pipe_name;
628
629#ifdef __REACTOS__
630 pipe_name = ncacn_pipe_name(NULL, endpoint);
631#else
632 pipe_name = ncacn_pipe_name(endpoint);
633#endif
634 status = is_pipe_listening(pipe_name);
635 I_RpcFree(pipe_name);
636 return status;
637}
638
640{
641 char *pipe_name;
643
644 pipe_name = ncalrpc_pipe_name(endpoint);
645 status = is_pipe_listening(pipe_name);
646 I_RpcFree(pipe_name);
647 return status;
648}
649
651{
654
655 TRACE("%s\n", old_conn->Endpoint);
656
659
660 /* Store the local computer name as the NetworkAddr for ncalrpc. */
661 new_conn->NetworkAddr = malloc(len);
662 if (!GetComputerNameA(new_conn->NetworkAddr, &len))
663 {
664 ERR("Failed to retrieve the computer name, error %lu\n", GetLastError());
666 }
667
668 return status;
669}
670
671static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int count)
672{
673 RpcConnection_np *connection = (RpcConnection_np *) conn;
676
677 event = get_np_event(connection);
678 if (!event)
679 return -1;
680
681 if (connection->read_closed)
683 else
684 status = NtReadFile(connection->pipe, event, NULL, NULL, &connection->io_status, buffer, count, NULL, NULL);
685 if (status == STATUS_PENDING)
686 {
687 /* check read_closed again before waiting to avoid a race */
688 if (connection->read_closed)
689 {
691#ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
692 NtCancelIoFile(connection->pipe, &io_status);
693#else
694 NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
695#endif
696 }
698 status = connection->io_status.Status;
699 }
700 release_np_event(connection, event);
701 return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information;
702}
703
704static int rpcrt4_conn_np_write(RpcConnection *conn, const void *buffer, unsigned int count)
705{
706 RpcConnection_np *connection = (RpcConnection_np *) conn;
710
711 event = get_np_event(connection);
712 if (!event)
713 return -1;
714
716 if (status == STATUS_PENDING)
717 {
719 status = io_status.Status;
720 }
721 release_np_event(connection, event);
722 if (status)
723 return -1;
724
725 assert(io_status.Information == count);
726 return count;
727}
728
730{
731 RpcConnection_np *connection = (RpcConnection_np *) conn;
732 if (connection->pipe)
733 {
734 FlushFileBuffers(connection->pipe);
735 CloseHandle(connection->pipe);
736 connection->pipe = 0;
737 }
738 if (connection->listen_event)
739 {
740 CloseHandle(connection->listen_event);
741 connection->listen_event = 0;
742 }
743 if (connection->event_cache)
744 {
745 CloseHandle(connection->event_cache);
746 connection->event_cache = 0;
747 }
748 return 0;
749}
750
752{
753 RpcConnection_np *connection = (RpcConnection_np*)conn;
755
756 connection->read_closed = TRUE;
757#ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
758 NtCancelIoFile(connection->pipe, &io_status);
759#else
760 NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
761#endif
762}
763
765{
766 RpcConnection_np *connection = (RpcConnection_np *)conn;
767 CancelIoEx(connection->pipe, NULL);
768}
769
771{
772 return rpcrt4_conn_np_read(conn, NULL, 0);
773}
774
775static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
776 const char *networkaddr,
777 const char *endpoint)
778{
779 twr_empty_floor_t *smb_floor;
780 twr_empty_floor_t *nb_floor;
781 size_t size;
782 size_t networkaddr_size;
783 size_t endpoint_size;
784
785 TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
786
787 networkaddr_size = networkaddr ? strlen(networkaddr) + 1 : 1;
788 endpoint_size = endpoint ? strlen(endpoint) + 1 : 1;
789 size = sizeof(*smb_floor) + endpoint_size + sizeof(*nb_floor) + networkaddr_size;
790
791 if (!tower_data)
792 return size;
793
794 smb_floor = (twr_empty_floor_t *)tower_data;
795
796 tower_data += sizeof(*smb_floor);
797
798 smb_floor->count_lhs = sizeof(smb_floor->protid);
799 smb_floor->protid = EPM_PROTOCOL_SMB;
800 smb_floor->count_rhs = endpoint_size;
801
802 if (endpoint)
803 memcpy(tower_data, endpoint, endpoint_size);
804 else
805 tower_data[0] = 0;
806 tower_data += endpoint_size;
807
808 nb_floor = (twr_empty_floor_t *)tower_data;
809
810 tower_data += sizeof(*nb_floor);
811
812 nb_floor->count_lhs = sizeof(nb_floor->protid);
813 nb_floor->protid = EPM_PROTOCOL_NETBIOS;
814 nb_floor->count_rhs = networkaddr_size;
815
816 if (networkaddr)
817 memcpy(tower_data, networkaddr, networkaddr_size);
818 else
819 tower_data[0] = 0;
820
821 return size;
822}
823
824static RPC_STATUS rpcrt4_ncacn_np_parse_top_of_tower(const unsigned char *tower_data,
825 size_t tower_size,
826 char **networkaddr,
827 char **endpoint)
828{
829 const twr_empty_floor_t *smb_floor = (const twr_empty_floor_t *)tower_data;
830 const twr_empty_floor_t *nb_floor;
831
832 TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
833
834 if (tower_size < sizeof(*smb_floor))
836
837 tower_data += sizeof(*smb_floor);
838 tower_size -= sizeof(*smb_floor);
839
840 if ((smb_floor->count_lhs != sizeof(smb_floor->protid)) ||
841 (smb_floor->protid != EPM_PROTOCOL_SMB) ||
842 (smb_floor->count_rhs > tower_size) ||
843 (tower_data[smb_floor->count_rhs - 1] != '\0'))
845
846 if (endpoint)
847 {
848 *endpoint = I_RpcAllocate(smb_floor->count_rhs);
849 if (!*endpoint)
851 memcpy(*endpoint, tower_data, smb_floor->count_rhs);
852 }
853 tower_data += smb_floor->count_rhs;
854 tower_size -= smb_floor->count_rhs;
855
856 if (tower_size < sizeof(*nb_floor))
858
859 nb_floor = (const twr_empty_floor_t *)tower_data;
860
861 tower_data += sizeof(*nb_floor);
862 tower_size -= sizeof(*nb_floor);
863
864 if ((nb_floor->count_lhs != sizeof(nb_floor->protid)) ||
865 (nb_floor->protid != EPM_PROTOCOL_NETBIOS) ||
866 (nb_floor->count_rhs > tower_size) ||
867 (tower_data[nb_floor->count_rhs - 1] != '\0'))
869
870 if (networkaddr)
871 {
872 *networkaddr = I_RpcAllocate(nb_floor->count_rhs);
873 if (!*networkaddr)
874 {
875 if (endpoint)
876 {
878 *endpoint = NULL;
879 }
881 }
882 memcpy(*networkaddr, tower_data, nb_floor->count_rhs);
883 }
884
885 return RPC_S_OK;
886}
887
889{
890 RpcConnection_np *npc = (RpcConnection_np *)conn;
891 BOOL ret;
892
893 TRACE("(%p)\n", conn);
894
895 if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
897
899 if (!ret)
900 {
902 WARN("ImpersonateNamedPipeClient failed with error %lu\n", error);
903 switch (error)
904 {
907 }
908 }
909 return RPC_S_OK;
910}
911
913{
914 BOOL ret;
915
916 TRACE("(%p)\n", conn);
917
918 if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
920
921 ret = RevertToSelf();
922 if (!ret)
923 {
924 WARN("RevertToSelf failed with error %lu\n", GetLastError());
926 }
927 return RPC_S_OK;
928}
929
931{
935
937{
938 RpcServerProtseq_np *ps = calloc(1, sizeof(*ps));
939 if (ps)
941 return &ps->common;
942}
943
945{
947 SetEvent(npps->mgr_event);
948}
949
950static void *rpcrt4_protseq_np_get_wait_array(RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
951{
952 HANDLE *objs = prev_array;
953 RpcConnection_np *conn;
955
956 EnterCriticalSection(&protseq->cs);
957
958 /* open and count connections */
959 *count = 1;
960 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry)
961 {
962 if (!conn->pipe && rpcrt4_conn_create_pipe(&conn->common) != RPC_S_OK)
963 continue;
964 if (!conn->listen_event)
965 {
968
969 event = get_np_event(conn);
970 if (!event)
971 continue;
972
974 switch (status)
975 {
976 case STATUS_SUCCESS:
978 conn->io_status.Status = status;
980 break;
981 case STATUS_PENDING:
982 break;
983 default:
984 ERR("pipe listen error %lx\n", status);
985 continue;
986 }
987
988 conn->listen_event = event;
989 }
990 (*count)++;
991 }
992
993 /* make array of connections */
994 objs = realloc(objs, *count * sizeof(HANDLE));
995 if (!objs)
996 {
997 ERR("couldn't allocate objs\n");
998 LeaveCriticalSection(&protseq->cs);
999 return NULL;
1000 }
1001
1002 objs[0] = npps->mgr_event;
1003 *count = 1;
1004 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry)
1005 {
1006 if (conn->listen_event)
1007 objs[(*count)++] = conn->listen_event;
1008 }
1009 LeaveCriticalSection(&protseq->cs);
1010 return objs;
1011}
1012
1014{
1015 free(array);
1016}
1017
1018static int rpcrt4_protseq_np_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array)
1019{
1020 HANDLE b_handle;
1021 HANDLE *objs = wait_array;
1022 DWORD res;
1023 RpcConnection *cconn = NULL;
1024 RpcConnection_np *conn;
1025
1026 if (!objs)
1027 return -1;
1028
1029 do
1030 {
1031 /* an alertable wait isn't strictly necessary, but due to our
1032 * overlapped I/O implementation in Wine we need to free some memory
1033 * by the file user APC being called, even if no completion routine was
1034 * specified at the time of starting the async operation */
1036 } while (res == WAIT_IO_COMPLETION);
1037
1038 if (res == WAIT_OBJECT_0)
1039 return 0;
1040 else if (res == WAIT_FAILED)
1041 {
1042 ERR("wait failed with error %ld\n", GetLastError());
1043 return -1;
1044 }
1045 else
1046 {
1047 b_handle = objs[res - WAIT_OBJECT_0];
1048 /* find which connection got a RPC */
1049 EnterCriticalSection(&protseq->cs);
1050 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_np, common.protseq_entry)
1051 {
1052 if (b_handle == conn->listen_event)
1053 {
1054 release_np_event(conn, conn->listen_event);
1055 conn->listen_event = NULL;
1057 cconn = rpcrt4_spawn_connection(&conn->common);
1058 else
1059 ERR("listen failed %lx\n", conn->io_status.Status);
1060 break;
1061 }
1062 }
1063 LeaveCriticalSection(&protseq->cs);
1064 if (!cconn)
1065 {
1066 ERR("failed to locate connection for handle %p\n", b_handle);
1067 return -1;
1068 }
1069 RPCRT4_new_client(cconn);
1070 return 1;
1071 }
1072}
1073
1074static size_t rpcrt4_ncalrpc_get_top_of_tower(unsigned char *tower_data,
1075 const char *networkaddr,
1076 const char *endpoint)
1077{
1078 twr_empty_floor_t *pipe_floor;
1079 size_t size;
1080 size_t endpoint_size;
1081
1082 TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
1083
1084 endpoint_size = strlen(endpoint) + 1;
1085 size = sizeof(*pipe_floor) + endpoint_size;
1086
1087 if (!tower_data)
1088 return size;
1089
1090 pipe_floor = (twr_empty_floor_t *)tower_data;
1091
1092 tower_data += sizeof(*pipe_floor);
1093
1094 pipe_floor->count_lhs = sizeof(pipe_floor->protid);
1095 pipe_floor->protid = EPM_PROTOCOL_PIPE;
1096 pipe_floor->count_rhs = endpoint_size;
1097
1098 memcpy(tower_data, endpoint, endpoint_size);
1099
1100 return size;
1101}
1102
1103static RPC_STATUS rpcrt4_ncalrpc_parse_top_of_tower(const unsigned char *tower_data,
1104 size_t tower_size,
1105 char **networkaddr,
1106 char **endpoint)
1107{
1108 const twr_empty_floor_t *pipe_floor = (const twr_empty_floor_t *)tower_data;
1109
1110 TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1111
1112 if (tower_size < sizeof(*pipe_floor))
1113 return EPT_S_NOT_REGISTERED;
1114
1115 tower_data += sizeof(*pipe_floor);
1116 tower_size -= sizeof(*pipe_floor);
1117
1118 if ((pipe_floor->count_lhs != sizeof(pipe_floor->protid)) ||
1119 (pipe_floor->protid != EPM_PROTOCOL_PIPE) ||
1120 (pipe_floor->count_rhs > tower_size) ||
1121 (tower_data[pipe_floor->count_rhs - 1] != '\0'))
1122 return EPT_S_NOT_REGISTERED;
1123
1124 if (networkaddr)
1125 *networkaddr = NULL;
1126
1127 if (endpoint)
1128 {
1129 *endpoint = I_RpcAllocate(pipe_floor->count_rhs);
1130 if (!*endpoint)
1132 memcpy(*endpoint, tower_data, pipe_floor->count_rhs);
1133 }
1134
1135 return RPC_S_OK;
1136}
1137
1139{
1140 return FALSE;
1141}
1142
1144 unsigned char *in_buffer,
1145 unsigned int in_size,
1146 unsigned char *out_buffer,
1147 unsigned int *out_size)
1148{
1149 /* since this protocol is local to the machine there is no need to
1150 * authenticate the caller */
1151 *out_size = 0;
1152 return RPC_S_OK;
1153}
1154
1157 RpcPktHdr *hdr, unsigned int hdr_size,
1158 unsigned char *stub_data, unsigned int stub_data_size,
1159 RpcAuthVerifier *auth_hdr,
1160 unsigned char *auth_value, unsigned int auth_value_size)
1161{
1162 /* since this protocol is local to the machine there is no need to secure
1163 * the packet */
1164 return RPC_S_OK;
1165}
1166
1168 RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name,
1169 ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
1170{
1171 TRACE("(%p, %p, %p, %p, %p, %p, 0x%lx)\n", conn, privs,
1172 server_princ_name, authn_level, authn_svc, authz_svc, flags);
1173
1174 if (privs)
1175 {
1176 FIXME("privs not implemented\n");
1177 *privs = NULL;
1178 }
1179 if (server_princ_name)
1180 {
1181 FIXME("server_princ_name not implemented\n");
1182 *server_princ_name = NULL;
1183 }
1184 if (authn_level) *authn_level = RPC_C_AUTHN_LEVEL_PKT_PRIVACY;
1185 if (authn_svc) *authn_svc = RPC_C_AUTHN_WINNT;
1186 if (authz_svc)
1187 {
1188 FIXME("authorization service not implemented\n");
1189 *authz_svc = RPC_C_AUTHZ_NONE;
1190 }
1191 if (flags)
1192 FIXME("flags 0x%lx not implemented\n", flags);
1193
1194 return RPC_S_OK;
1195}
1196
1198{
1199 RpcConnection_np *connection = (RpcConnection_np *)conn;
1200
1202}
1203
1204/**** ncacn_ip_tcp support ****/
1205
1206static size_t rpcrt4_ip_tcp_get_top_of_tower(unsigned char *tower_data,
1207 const char *networkaddr,
1208 unsigned char tcp_protid,
1209 const char *endpoint)
1210{
1211 twr_tcp_floor_t *tcp_floor;
1212 twr_ipv4_floor_t *ipv4_floor;
1213 struct addrinfo *ai;
1214 struct addrinfo hints;
1215 int ret;
1216 size_t size = sizeof(*tcp_floor) + sizeof(*ipv4_floor);
1217
1218 TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
1219
1220 if (!tower_data)
1221 return size;
1222
1223 tcp_floor = (twr_tcp_floor_t *)tower_data;
1224 tower_data += sizeof(*tcp_floor);
1225
1226 ipv4_floor = (twr_ipv4_floor_t *)tower_data;
1227
1228 tcp_floor->count_lhs = sizeof(tcp_floor->protid);
1229 tcp_floor->protid = tcp_protid;
1230 tcp_floor->count_rhs = sizeof(tcp_floor->port);
1231
1232 ipv4_floor->count_lhs = sizeof(ipv4_floor->protid);
1233 ipv4_floor->protid = EPM_PROTOCOL_IP;
1234 ipv4_floor->count_rhs = sizeof(ipv4_floor->ipv4addr);
1235
1236 hints.ai_flags = AI_NUMERICHOST;
1237 /* FIXME: only support IPv4 at the moment. how is IPv6 represented by the EPM? */
1238 hints.ai_family = PF_INET;
1239 hints.ai_socktype = SOCK_STREAM;
1240 hints.ai_protocol = IPPROTO_TCP;
1241 hints.ai_addrlen = 0;
1242 hints.ai_addr = NULL;
1243 hints.ai_canonname = NULL;
1244 hints.ai_next = NULL;
1245
1246#ifdef __REACTOS__
1247 static BOOL wsa_inited;
1248 if (!wsa_inited)
1249 {
1250 WSADATA wsadata;
1251 WSAStartup(MAKEWORD(2, 2), &wsadata);
1252 /* Note: WSAStartup can be called more than once so we don't bother with
1253 * making accesses to wsa_inited thread-safe */
1254 wsa_inited = TRUE;
1255 }
1256#endif
1257
1258 ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
1259 if (ret)
1260 {
1261 ret = getaddrinfo("0.0.0.0", endpoint, &hints, &ai);
1262 if (ret)
1263 {
1264 ERR("getaddrinfo failed, error %u\n", WSAGetLastError());
1265 return 0;
1266 }
1267 }
1268
1269 if (ai->ai_family == PF_INET)
1270 {
1271 const struct sockaddr_in *sin = (const struct sockaddr_in *)ai->ai_addr;
1272 tcp_floor->port = sin->sin_port;
1273 ipv4_floor->ipv4addr = sin->sin_addr.s_addr;
1274 }
1275 else
1276 {
1277 ERR("unexpected protocol family %d\n", ai->ai_family);
1278 freeaddrinfo(ai);
1279 return 0;
1280 }
1281
1282 freeaddrinfo(ai);
1283
1284 return size;
1285}
1286
1287static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower(const unsigned char *tower_data,
1288 size_t tower_size,
1289 char **networkaddr,
1290 unsigned char tcp_protid,
1291 char **endpoint)
1292{
1293 const twr_tcp_floor_t *tcp_floor = (const twr_tcp_floor_t *)tower_data;
1294 const twr_ipv4_floor_t *ipv4_floor;
1295 struct in_addr in_addr;
1296
1297 TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1298
1299 if (tower_size < sizeof(*tcp_floor))
1300 return EPT_S_NOT_REGISTERED;
1301
1302 tower_data += sizeof(*tcp_floor);
1303 tower_size -= sizeof(*tcp_floor);
1304
1305 if (tower_size < sizeof(*ipv4_floor))
1306 return EPT_S_NOT_REGISTERED;
1307
1308 ipv4_floor = (const twr_ipv4_floor_t *)tower_data;
1309
1310 if ((tcp_floor->count_lhs != sizeof(tcp_floor->protid)) ||
1311 (tcp_floor->protid != tcp_protid) ||
1312 (tcp_floor->count_rhs != sizeof(tcp_floor->port)) ||
1313 (ipv4_floor->count_lhs != sizeof(ipv4_floor->protid)) ||
1314 (ipv4_floor->protid != EPM_PROTOCOL_IP) ||
1315 (ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
1316 return EPT_S_NOT_REGISTERED;
1317
1318 if (endpoint)
1319 {
1320 *endpoint = I_RpcAllocate(6 /* sizeof("65535") + 1 */);
1321 if (!*endpoint)
1323 sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
1324 }
1325
1326 if (networkaddr)
1327 {
1328 *networkaddr = I_RpcAllocate(INET_ADDRSTRLEN);
1329 if (!*networkaddr)
1330 {
1331 if (endpoint)
1332 {
1334 *endpoint = NULL;
1335 }
1337 }
1338 in_addr.s_addr = ipv4_floor->ipv4addr;
1339 if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
1340 {
1341 ERR("inet_ntop: %u\n", WSAGetLastError());
1342 I_RpcFree(*networkaddr);
1343 *networkaddr = NULL;
1344 if (endpoint)
1345 {
1347 *endpoint = NULL;
1348 }
1349 return EPT_S_NOT_REGISTERED;
1350 }
1351 }
1352
1353 return RPC_S_OK;
1354}
1355
1357{
1359 int sock;
1363
1365{
1366 static BOOL wsa_inited;
1367 if (!wsa_inited)
1368 {
1369 WSADATA wsadata;
1370 WSAStartup(MAKEWORD(2, 2), &wsadata);
1371 /* Note: WSAStartup can be called more than once so we don't bother with
1372 * making accesses to wsa_inited thread-safe */
1373 wsa_inited = TRUE;
1374 }
1377 if (!tcpc->sock_event || !tcpc->cancel_event)
1378 {
1379 ERR("event creation failed\n");
1380 if (tcpc->sock_event) CloseHandle(tcpc->sock_event);
1381 return FALSE;
1382 }
1383 return TRUE;
1384}
1385
1387{
1388 HANDLE wait_handles[2];
1389 DWORD res;
1391 {
1392 ERR("WSAEventSelect() failed with error %d\n", WSAGetLastError());
1393 return FALSE;
1394 }
1395 wait_handles[0] = tcpc->sock_event;
1396 wait_handles[1] = tcpc->cancel_event;
1397 res = WaitForMultipleObjects(2, wait_handles, FALSE, INFINITE);
1398 switch (res)
1399 {
1400 case WAIT_OBJECT_0:
1401 return TRUE;
1402 case WAIT_OBJECT_0 + 1:
1403 return FALSE;
1404 default:
1405 ERR("WaitForMultipleObjects() failed with error %ld\n", GetLastError());
1406 return FALSE;
1407 }
1408}
1409
1411{
1412 DWORD res;
1414 {
1415 ERR("WSAEventSelect() failed with error %d\n", WSAGetLastError());
1416 return FALSE;
1417 }
1419 switch (res)
1420 {
1421 case WAIT_OBJECT_0:
1422 return TRUE;
1423 default:
1424 ERR("WaitForMultipleObjects() failed with error %ld\n", GetLastError());
1425 return FALSE;
1426 }
1427}
1428
1430{
1431 RpcConnection_tcp *tcpc;
1432 tcpc = calloc(1, sizeof(RpcConnection_tcp));
1433 if (tcpc == NULL)
1434 return NULL;
1435 tcpc->sock = -1;
1436 if (!rpcrt4_sock_wait_init(tcpc))
1437 {
1438 free(tcpc);
1439 return NULL;
1440 }
1441 return &tcpc->common;
1442}
1443
1445{
1446 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1447 int sock;
1448 int ret;
1449 struct addrinfo *ai;
1450 struct addrinfo *ai_cur;
1451 struct addrinfo hints;
1452
1453 TRACE("(%s, %s)\n", Connection->NetworkAddr, Connection->Endpoint);
1454
1455 if (tcpc->sock != -1)
1456 return RPC_S_OK;
1457
1458 hints.ai_flags = 0;
1459 hints.ai_family = PF_UNSPEC;
1460 hints.ai_socktype = SOCK_STREAM;
1461 hints.ai_protocol = IPPROTO_TCP;
1462 hints.ai_addrlen = 0;
1463 hints.ai_addr = NULL;
1464 hints.ai_canonname = NULL;
1465 hints.ai_next = NULL;
1466
1467 ret = getaddrinfo(Connection->NetworkAddr, Connection->Endpoint, &hints, &ai);
1468 if (ret)
1469 {
1470 ERR("getaddrinfo for %s:%s failed, error %u\n", Connection->NetworkAddr,
1471 Connection->Endpoint, WSAGetLastError());
1473 }
1474
1475 for (ai_cur = ai; ai_cur; ai_cur = ai_cur->ai_next)
1476 {
1477 int val;
1478 u_long nonblocking;
1479
1480 if (ai_cur->ai_family != AF_INET && ai_cur->ai_family != AF_INET6)
1481 {
1482 TRACE("skipping non-IP/IPv6 address family\n");
1483 continue;
1484 }
1485
1486 if (TRACE_ON(rpc))
1487 {
1488 char host[256];
1489 char service[256];
1490 getnameinfo(ai_cur->ai_addr, ai_cur->ai_addrlen,
1491 host, sizeof(host), service, sizeof(service),
1493 TRACE("trying %s:%s\n", host, service);
1494 }
1495
1496 sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol);
1497 if (sock == -1)
1498 {
1499 WARN("socket() failed: %u\n", WSAGetLastError());
1500 continue;
1501 }
1502
1503 if (0>connect(sock, ai_cur->ai_addr, ai_cur->ai_addrlen))
1504 {
1505 WARN("connect() failed: %u\n", WSAGetLastError());
1507 continue;
1508 }
1509
1510 /* RPC depends on having minimal latency so disable the Nagle algorithm */
1511 val = 1;
1512 setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
1513 nonblocking = 1;
1514 ioctlsocket(sock, FIONBIO, &nonblocking);
1515
1516 tcpc->sock = sock;
1517
1518 freeaddrinfo(ai);
1519 TRACE("connected\n");
1520 return RPC_S_OK;
1521 }
1522
1523 freeaddrinfo(ai);
1524 ERR("couldn't connect to %s:%s\n", Connection->NetworkAddr, Connection->Endpoint);
1526}
1527
1529{
1531 int sock;
1532 int ret;
1533 struct addrinfo *ai;
1534 struct addrinfo *ai_cur;
1535 struct addrinfo hints;
1536
1537 TRACE("(%p, %s)\n", protseq, endpoint);
1538
1539 hints.ai_flags = AI_PASSIVE /* for non-localhost addresses */;
1540 hints.ai_family = PF_UNSPEC;
1541 hints.ai_socktype = SOCK_STREAM;
1542 hints.ai_protocol = IPPROTO_TCP;
1543 hints.ai_addrlen = 0;
1544 hints.ai_addr = NULL;
1545 hints.ai_canonname = NULL;
1546 hints.ai_next = NULL;
1547
1548 ret = getaddrinfo(NULL, endpoint ? endpoint : "0", &hints, &ai);
1549 if (ret)
1550 {
1551 ERR("getaddrinfo for port %s failed, error %u\n", endpoint, WSAGetLastError());
1552 if ((ret == EAI_SERVICE) || (ret == EAI_NONAME))
1555 }
1556
1557 for (ai_cur = ai; ai_cur; ai_cur = ai_cur->ai_next)
1558 {
1559 RpcConnection_tcp *tcpc;
1560 RPC_STATUS create_status;
1561 struct sockaddr_storage sa;
1562 socklen_t sa_len;
1563 char service[NI_MAXSERV];
1564 u_long nonblocking;
1565
1566 if (ai_cur->ai_family != AF_INET && ai_cur->ai_family != AF_INET6)
1567 {
1568 TRACE("skipping non-IP/IPv6 address family\n");
1569 continue;
1570 }
1571
1572 if (TRACE_ON(rpc))
1573 {
1574 char host[256];
1575 getnameinfo(ai_cur->ai_addr, ai_cur->ai_addrlen,
1576 host, sizeof(host), service, sizeof(service),
1578 TRACE("trying %s:%s\n", host, service);
1579 }
1580
1581 sock = socket(ai_cur->ai_family, ai_cur->ai_socktype, ai_cur->ai_protocol);
1582 if (sock == -1)
1583 {
1584 WARN("socket() failed: %u\n", WSAGetLastError());
1586 continue;
1587 }
1588
1589 ret = bind(sock, ai_cur->ai_addr, ai_cur->ai_addrlen);
1590 if (ret < 0)
1591 {
1592 WARN("bind failed: %u\n", WSAGetLastError());
1596 else
1598 continue;
1599 }
1600
1601 sa_len = sizeof(sa);
1602 if (getsockname(sock, (struct sockaddr *)&sa, &sa_len))
1603 {
1604 WARN("getsockname() failed: %u\n", WSAGetLastError());
1607 continue;
1608 }
1609
1610 ret = getnameinfo((struct sockaddr *)&sa, sa_len,
1611 NULL, 0, service, sizeof(service),
1613 if (ret)
1614 {
1615 WARN("getnameinfo failed, error %u\n", WSAGetLastError());
1618 continue;
1619 }
1620
1621 create_status = RPCRT4_CreateConnection((RpcConnection **)&tcpc, TRUE,
1622 protseq->Protseq, NULL,
1623 service, NULL, NULL, NULL, NULL);
1624 if (create_status != RPC_S_OK)
1625 {
1627 status = create_status;
1628 continue;
1629 }
1630
1631 tcpc->sock = sock;
1632 ret = listen(sock, protseq->MaxCalls);
1633 if (ret < 0)
1634 {
1635 WARN("listen failed: %u\n", WSAGetLastError());
1638 continue;
1639 }
1640 /* need a non-blocking socket, otherwise accept() has a potential
1641 * race-condition (poll() says it is readable, connection drops,
1642 * and accept() blocks until the next connection comes...)
1643 */
1644 nonblocking = 1;
1645 ret = ioctlsocket(sock, FIONBIO, &nonblocking);
1646 if (ret < 0)
1647 {
1648 WARN("couldn't make socket non-blocking, error %d\n", ret);
1651 continue;
1652 }
1653
1654 EnterCriticalSection(&protseq->cs);
1655 list_add_tail(&protseq->listeners, &tcpc->common.protseq_entry);
1656 tcpc->common.protseq = protseq;
1657 LeaveCriticalSection(&protseq->cs);
1658
1659 freeaddrinfo(ai);
1660
1661 /* since IPv4 and IPv6 share the same port space, we only need one
1662 * successful bind to listen for both */
1663 TRACE("listening on %s\n", endpoint);
1664 return RPC_S_OK;
1665 }
1666
1667 freeaddrinfo(ai);
1668 ERR("couldn't listen on port %s\n", endpoint);
1669 return status;
1670}
1671
1673{
1674 int ret;
1675 struct sockaddr_in address;
1676 socklen_t addrsize;
1679 u_long nonblocking;
1680
1681 addrsize = sizeof(address);
1682 ret = accept(server->sock, (struct sockaddr*) &address, &addrsize);
1683 if (ret < 0)
1684 {
1685 ERR("Failed to accept a TCP connection: error %d\n", ret);
1687 }
1688
1689 nonblocking = 1;
1690 ioctlsocket(ret, FIONBIO, &nonblocking);
1691 client->sock = ret;
1692
1693 client->common.NetworkAddr = malloc(INET6_ADDRSTRLEN);
1694 ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
1695 if (ret != 0)
1696 {
1697 ERR("Failed to retrieve the IP address, error %d\n", ret);
1699 }
1700
1701 TRACE("Accepted a new TCP connection from %s\n", client->common.NetworkAddr);
1702 return RPC_S_OK;
1703}
1704
1706 void *buffer, unsigned int count)
1707{
1708 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1709 int bytes_read = 0;
1710 while (bytes_read != count)
1711 {
1712 int r = recv(tcpc->sock, (char *)buffer + bytes_read, count - bytes_read, 0);
1713 if (!r)
1714 return -1;
1715 else if (r > 0)
1716 bytes_read += r;
1717 else if (WSAGetLastError() == WSAEINTR)
1718 continue;
1719 else if (WSAGetLastError() != WSAEWOULDBLOCK)
1720 {
1721 WARN("recv() failed: %u\n", WSAGetLastError());
1722 return -1;
1723 }
1724 else
1725 {
1726 if (!rpcrt4_sock_wait_for_recv(tcpc))
1727 return -1;
1728 }
1729 }
1730 TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_read);
1731 return bytes_read;
1732}
1733
1735 const void *buffer, unsigned int count)
1736{
1737 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1738 int bytes_written = 0;
1739 while (bytes_written != count)
1740 {
1741 int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
1742 if (r >= 0)
1743 bytes_written += r;
1744 else if (WSAGetLastError() == WSAEINTR)
1745 continue;
1746 else if (WSAGetLastError() != WSAEWOULDBLOCK)
1747 return -1;
1748 else
1749 {
1750 if (!rpcrt4_sock_wait_for_send(tcpc))
1751 return -1;
1752 }
1753 }
1754 TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_written);
1755 return bytes_written;
1756}
1757
1759{
1760 RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1761
1762 TRACE("%d\n", connection->sock);
1763
1764 if (connection->sock != -1)
1765 closesocket(connection->sock);
1766 connection->sock = -1;
1767 CloseHandle(connection->sock_event);
1768 CloseHandle(connection->cancel_event);
1769 return 0;
1770}
1771
1773{
1774 RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1775 shutdown(connection->sock, SD_RECEIVE);
1776}
1777
1779{
1780 RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1781
1782 TRACE("%p\n", connection);
1783
1784 SetEvent(connection->cancel_event);
1785}
1786
1788{
1789 FIXME("\n");
1790 return RPC_S_ACCESS_DENIED;
1791}
1792
1794{
1795 RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1796
1797 TRACE("%p\n", Connection);
1798
1799 if (!rpcrt4_sock_wait_for_recv(tcpc))
1800 return -1;
1801 return 0;
1802}
1803
1804static size_t rpcrt4_ncacn_ip_tcp_get_top_of_tower(unsigned char *tower_data,
1805 const char *networkaddr,
1806 const char *endpoint)
1807{
1808 return rpcrt4_ip_tcp_get_top_of_tower(tower_data, networkaddr,
1810}
1811
1813{
1817
1819{
1820 RpcServerProtseq_sock *ps = calloc(1, sizeof(*ps));
1821 if (ps)
1822 {
1823 static BOOL wsa_inited;
1824 if (!wsa_inited)
1825 {
1826 WSADATA wsadata;
1827 WSAStartup(MAKEWORD(2, 2), &wsadata);
1828 /* Note: WSAStartup can be called more than once so we don't bother with
1829 * making accesses to wsa_inited thread-safe */
1830 wsa_inited = TRUE;
1831 }
1833 }
1834 return &ps->common;
1835}
1836
1838{
1840 SetEvent(sockps->mgr_event);
1841}
1842
1843static void *rpcrt4_protseq_sock_get_wait_array(RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
1844{
1845 HANDLE *objs = prev_array;
1846 RpcConnection_tcp *conn;
1848
1849 EnterCriticalSection(&protseq->cs);
1850
1851 /* open and count connections */
1852 *count = 1;
1853 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_tcp, common.protseq_entry)
1854 {
1855 if (conn->sock != -1)
1856 (*count)++;
1857 }
1858
1859 /* make array of connections */
1860 objs = realloc(objs, *count * sizeof(HANDLE));
1861 if (!objs)
1862 {
1863 ERR("couldn't allocate objs\n");
1864 LeaveCriticalSection(&protseq->cs);
1865 return NULL;
1866 }
1867
1868 objs[0] = sockps->mgr_event;
1869 *count = 1;
1870 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_tcp, common.protseq_entry)
1871 {
1872 if (conn->sock != -1)
1873 {
1874 int res = WSAEventSelect(conn->sock, conn->sock_event, FD_ACCEPT);
1875 if (res == SOCKET_ERROR)
1876 ERR("WSAEventSelect() failed with error %d\n", WSAGetLastError());
1877 else
1878 {
1879 objs[*count] = conn->sock_event;
1880 (*count)++;
1881 }
1882 }
1883 }
1884 LeaveCriticalSection(&protseq->cs);
1885 return objs;
1886}
1887
1889{
1890 free(array);
1891}
1892
1893static int rpcrt4_protseq_sock_wait_for_new_connection(RpcServerProtseq *protseq, unsigned int count, void *wait_array)
1894{
1895 HANDLE b_handle;
1896 HANDLE *objs = wait_array;
1897 DWORD res;
1898 RpcConnection *cconn = NULL;
1899 RpcConnection_tcp *conn;
1900
1901 if (!objs)
1902 return -1;
1903
1904 do
1905 {
1906 /* an alertable wait isn't strictly necessary, but due to our
1907 * overlapped I/O implementation in Wine we need to free some memory
1908 * by the file user APC being called, even if no completion routine was
1909 * specified at the time of starting the async operation */
1911 } while (res == WAIT_IO_COMPLETION);
1912
1913 if (res == WAIT_OBJECT_0)
1914 return 0;
1915 if (res == WAIT_FAILED)
1916 {
1917 ERR("wait failed with error %ld\n", GetLastError());
1918 return -1;
1919 }
1920
1921 b_handle = objs[res - WAIT_OBJECT_0];
1922
1923 /* find which connection got a RPC */
1924 EnterCriticalSection(&protseq->cs);
1925 LIST_FOR_EACH_ENTRY(conn, &protseq->listeners, RpcConnection_tcp, common.protseq_entry)
1926 {
1927 if (b_handle == conn->sock_event)
1928 {
1929 cconn = rpcrt4_spawn_connection(&conn->common);
1930 break;
1931 }
1932 }
1933 LeaveCriticalSection(&protseq->cs);
1934 if (!cconn)
1935 {
1936 ERR("failed to locate connection for handle %p\n", b_handle);
1937 return -1;
1938 }
1939
1940 RPCRT4_new_client(cconn);
1941 return 1;
1942}
1943
1944static RPC_STATUS rpcrt4_ncacn_ip_tcp_parse_top_of_tower(const unsigned char *tower_data,
1945 size_t tower_size,
1946 char **networkaddr,
1947 char **endpoint)
1948{
1949 return rpcrt4_ip_tcp_parse_top_of_tower(tower_data, tower_size,
1950 networkaddr, EPM_PROTOCOL_TCP,
1951 endpoint);
1952}
1953
1954/**** ncacn_http support ****/
1955
1956/* 60 seconds is the period native uses */
1957#define HTTP_IDLE_TIME 60000
1958
1959/* reference counted to avoid a race between a cancelled call's connection
1960 * being destroyed and the asynchronous InternetReadFileEx call being
1961 * completed */
1962typedef struct _RpcHttpAsyncData
1963{
1970
1972{
1973 return InterlockedIncrement(&data->refs);
1974}
1975
1977{
1978 ULONG refs = InterlockedDecrement(&data->refs);
1979 if (!refs)
1980 {
1981 TRACE("destroying async data %p\n", data);
1982 CloseHandle(data->completion_event);
1983 free(data->inet_buffers.lpvBuffer);
1984 data->cs.DebugInfo->Spare[0] = 0;
1986 free(data);
1987 }
1988 return refs;
1989}
1990
1992{
1993 ResetEvent(async_data->completion_event);
1994 RpcHttpAsyncData_AddRef(async_data);
1995}
1996
1997static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
1998{
1999 HANDLE handles[2] = { async_data->completion_event, cancel_event };
2000 DWORD res;
2001
2002 if(call_ret) {
2003 RpcHttpAsyncData_Release(async_data);
2004 return RPC_S_OK;
2005 }
2006
2008 RpcHttpAsyncData_Release(async_data);
2009 ERR("Request failed with error %ld\n", GetLastError());
2011 }
2012
2014 if(res != WAIT_OBJECT_0) {
2015 TRACE("Cancelled\n");
2016 return RPC_S_CALL_CANCELLED;
2017 }
2018
2019 if(async_data->async_result) {
2020 ERR("Async request failed with error %d\n", async_data->async_result);
2022 }
2023
2024 return RPC_S_OK;
2025}
2026
2028{
2035 char *data;
2036 unsigned int data_len;
2037 BOOL finished; /* finished authenticating */
2038};
2039
2041{
2052 ULONG flow_control_mark; /* send a control packet to the server when this many bytes received */
2053 ULONG flow_control_increment; /* number of bytes to increment flow_control_mark by */
2059
2061{
2062 RpcConnection_http *httpc;
2063 httpc = calloc(1, sizeof(*httpc));
2064 if (!httpc) return NULL;
2065 httpc->async_data = calloc(1, sizeof(RpcHttpAsyncData));
2066 if (!httpc->async_data)
2067 {
2068 free(httpc);
2069 return NULL;
2070 }
2071 TRACE("async data = %p\n", httpc->async_data);
2073 httpc->async_data->refs = 1;
2076 httpc->async_data->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": RpcHttpAsyncData.cs");
2077 return &httpc->common;
2078}
2079
2081{
2086
2088{
2089 HINTERNET in_request = param;
2090 RpcPktHdr *idle_pkt;
2091
2093 0, 0);
2094 if (idle_pkt)
2095 {
2096 DWORD bytes_written;
2097 InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written);
2098 free(idle_pkt);
2099 }
2100}
2101
2102static inline DWORD rpcrt4_http_timer_calc_timeout(DWORD *last_sent_time)
2103{
2105 DWORD cached_last_sent_time = *last_sent_time;
2106 return HTTP_IDLE_TIME - (cur_time - cached_last_sent_time > HTTP_IDLE_TIME ? 0 : cur_time - cached_last_sent_time);
2107}
2108
2110{
2111 HttpTimerThreadData *data_in = param;
2113 DWORD timeout;
2114
2115 SetThreadDescription(GetCurrentThread(), L"wine_rpcrt4_http_timer");
2116
2117 data = *data_in;
2118 free(data_in);
2119
2120 for (timeout = HTTP_IDLE_TIME;
2121 WaitForSingleObject(data.timer_cancelled, timeout) == WAIT_TIMEOUT;
2123 {
2124 /* are we too soon after last send? */
2125 if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
2126 continue;
2128 }
2129
2130 CloseHandle(data.timer_cancelled);
2131 return 0;
2132}
2133
2135 HINTERNET hInternet,
2136 DWORD_PTR dwContext,
2137 DWORD dwInternetStatus,
2138 LPVOID lpvStatusInformation,
2139 DWORD dwStatusInformationLength)
2140{
2141 RpcHttpAsyncData *async_data = (RpcHttpAsyncData *)dwContext;
2142
2143 switch (dwInternetStatus)
2144 {
2146 TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
2147 if (async_data)
2148 {
2149 INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
2150
2151 async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
2152 SetEvent(async_data->completion_event);
2153 RpcHttpAsyncData_Release(async_data);
2154 }
2155 break;
2156 }
2157}
2158
2160{
2161 BOOL ret;
2163 DWORD size;
2164 DWORD index;
2165 WCHAR buf[32];
2166 WCHAR *status_text = buf;
2167 TRACE("\n");
2168
2169 index = 0;
2170 size = sizeof(status_code);
2172 if (!ret)
2173 return GetLastError();
2175 return RPC_S_OK;
2176 index = 0;
2177 size = sizeof(buf);
2178 ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
2180 {
2181 status_text = malloc(size);
2182 ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
2183 }
2184
2185 ERR("server returned: %ld %s\n", status_code, ret ? debugstr_w(status_text) : "<status text unavailable>");
2186 if(status_text != buf) free(status_text);
2187
2189 return ERROR_ACCESS_DENIED;
2191}
2192
2194{
2195 LPWSTR proxy = NULL;
2196 LPWSTR user = NULL;
2198 LPWSTR servername = NULL;
2199 const WCHAR *option;
2201
2202 if (httpc->common.QOS &&
2204 {
2205 const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_cred = httpc->common.QOS->qos->u.HttpCredentials;
2206 if (http_cred->TransportCredentials)
2207 {
2208 WCHAR *p;
2209 const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials;
2210 ULONG len = cred->DomainLength + 1 + cred->UserLength;
2211 user = malloc((len + 1) * sizeof(WCHAR));
2212 if (!user)
2214 p = user;
2215 if (cred->DomainLength)
2216 {
2217 memcpy(p, cred->Domain, cred->DomainLength * sizeof(WCHAR));
2218 p += cred->DomainLength;
2219 *p = '\\';
2220 p++;
2221 }
2222 memcpy(p, cred->User, cred->UserLength * sizeof(WCHAR));
2223 p[cred->UserLength] = 0;
2224
2226 }
2227 }
2228
2229 for (option = httpc->common.NetworkOptions; option;
2230 option = (wcschr(option, ',') ? wcschr(option, ',')+1 : NULL))
2231 {
2232 if (!_wcsnicmp(option, L"RpcProxy=", ARRAY_SIZE(L"RpcProxy=")-1))
2233 {
2234 const WCHAR *value_start = option + ARRAY_SIZE(L"RpcProxy=")-1;
2235 const WCHAR *value_end;
2236 const WCHAR *p;
2237
2238 value_end = wcschr(option, ',');
2239 if (!value_end)
2240 value_end = value_start + lstrlenW(value_start);
2241 for (p = value_start; p < value_end; p++)
2242 if (*p == ':')
2243 {
2244 port = wcstol(p+1, NULL, 10);
2245 value_end = p;
2246 break;
2247 }
2248 TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2249 servername = RPCRT4_strndupW(value_start, value_end-value_start);
2250 }
2251 else if (!_wcsnicmp(option, L"HttpProxy=", ARRAY_SIZE(L"HttpProxy=")-1))
2252 {
2253 const WCHAR *value_start = option + ARRAY_SIZE(L"HttpProxy=")-1;
2254 const WCHAR *value_end;
2255
2256 value_end = wcschr(option, ',');
2257 if (!value_end)
2258 value_end = value_start + lstrlenW(value_start);
2259 TRACE("HttpProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2260 proxy = RPCRT4_strndupW(value_start, value_end-value_start);
2261 }
2262 else
2263 FIXME("unhandled option %s\n", debugstr_w(option));
2264 }
2265
2268 if (!httpc->app_info)
2269 {
2270 free(password);
2271 free(user);
2272 free(proxy);
2273 free(servername);
2274 ERR("InternetOpenW failed with error %ld\n", GetLastError());
2276 }
2278
2279 /* if no RpcProxy option specified, set the HTTP server address to the
2280 * RPC server address */
2281 if (!servername)
2282 {
2283 servername = malloc((strlen(httpc->common.NetworkAddr) + 1) * sizeof(WCHAR));
2284 if (!servername)
2285 {
2286 free(password);
2287 free(user);
2288 free(proxy);
2290 }
2291 MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
2292 }
2293
2294 port = (httpc->common.QOS &&
2298
2299 httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
2300 INTERNET_SERVICE_HTTP, 0, 0);
2301
2302 free(password);
2303 free(user);
2304 free(proxy);
2305
2306 if (!httpc->session)
2307 {
2308 ERR("InternetConnectW failed with error %ld\n", GetLastError());
2309 free(servername);
2311 }
2312 httpc->servername = servername;
2313 return RPC_S_OK;
2314}
2315
2316static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event,
2317 void *buffer, unsigned int count)
2318{
2319 char *buf = buffer;
2320 BOOL ret;
2321 unsigned int bytes_left = count;
2323
2324 async_data->inet_buffers.lpvBuffer = malloc(count);
2325
2326 while (bytes_left)
2327 {
2328 async_data->inet_buffers.dwBufferLength = bytes_left;
2329 prepare_async_request(async_data);
2330 ret = InternetReadFileExW(req, &async_data->inet_buffers, IRF_ASYNC, 0);
2331 status = wait_async_request(async_data, ret, cancel_event);
2332 if (status != RPC_S_OK)
2333 {
2335 TRACE("call cancelled\n");
2336 break;
2337 }
2338
2339 if (!async_data->inet_buffers.dwBufferLength)
2340 break;
2341 memcpy(buf, async_data->inet_buffers.lpvBuffer,
2342 async_data->inet_buffers.dwBufferLength);
2343
2344 bytes_left -= async_data->inet_buffers.dwBufferLength;
2345 buf += async_data->inet_buffers.dwBufferLength;
2346 }
2347
2348 free(async_data->inet_buffers.lpvBuffer);
2349 async_data->inet_buffers.lpvBuffer = NULL;
2350
2351 TRACE("%p %p %u -> %lu\n", req, buffer, count, status);
2352 return status == RPC_S_OK ? count : -1;
2353}
2354
2355static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
2356{
2357 BYTE buf[20];
2358 BOOL ret;
2360
2361 TRACE("sending echo request to server\n");
2362
2363 prepare_async_request(async_data);
2364 ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
2365 status = wait_async_request(async_data, ret, cancel_event);
2366 if (status != RPC_S_OK) return status;
2367
2369 if (status != RPC_S_OK) return status;
2370
2371 rpcrt4_http_async_read(req, async_data, cancel_event, buf, sizeof(buf));
2372 /* FIXME: do something with retrieved data */
2373
2374 return RPC_S_OK;
2375}
2376
2378{
2379 WCHAR header[ARRAY_SIZE(L"Content-Length: %u\r\n") + 10];
2380
2381 swprintf(header, L"Content-Length: %u\r\n", len);
2384}
2385
2386/* prepare the in pipe for use by RPC packets */
2387static RPC_STATUS rpcrt4_http_prepare_in_pipe(HINTERNET in_request, RpcHttpAsyncData *async_data, HANDLE cancel_event,
2388 const UUID *connection_uuid, const UUID *in_pipe_uuid,
2389 const UUID *association_uuid, BOOL authorized)
2390{
2391 BOOL ret;
2393 RpcPktHdr *hdr;
2394 INTERNET_BUFFERSW buffers_in;
2395 DWORD bytes_written;
2396
2397 if (!authorized)
2398 {
2399 /* ask wininet to authorize, if necessary */
2400 status = send_echo_request(in_request, async_data, cancel_event);
2401 if (status != RPC_S_OK) return status;
2402 }
2403 memset(&buffers_in, 0, sizeof(buffers_in));
2404 buffers_in.dwStructSize = sizeof(buffers_in);
2405 /* FIXME: get this from the registry */
2406 buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
2407 status = insert_content_length_header(in_request, buffers_in.dwBufferTotal);
2408 if (status != RPC_S_OK) return status;
2409
2410 prepare_async_request(async_data);
2411 ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
2412 status = wait_async_request(async_data, ret, cancel_event);
2413 if (status != RPC_S_OK) return status;
2414
2415 TRACE("sending HTTP connect header to server\n");
2416 hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
2417 if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2418 ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
2419 free(hdr);
2420 if (!ret)
2421 {
2422 ERR("InternetWriteFile failed with error %ld\n", GetLastError());
2424 }
2425
2426 return RPC_S_OK;
2427}
2428
2430 HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
2431{
2432 unsigned short data_len;
2433 unsigned int size;
2434
2435 if (rpcrt4_http_async_read(request, async_data, cancel_event, hdr, sizeof(hdr->common)) < 0)
2437 if (hdr->common.ptype != PKT_HTTP || hdr->common.frag_len < sizeof(hdr->http))
2438 {
2439 ERR("wrong packet type received %d or wrong frag_len %d\n",
2440 hdr->common.ptype, hdr->common.frag_len);
2441 return RPC_S_PROTOCOL_ERROR;
2442 }
2443
2444 size = sizeof(hdr->http) - sizeof(hdr->common);
2445 if (rpcrt4_http_async_read(request, async_data, cancel_event, &hdr->common + 1, size) < 0)
2447
2448 data_len = hdr->common.frag_len - sizeof(hdr->http);
2449 if (data_len)
2450 {
2451 *data = malloc(data_len);
2452 if (!*data)
2454 if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0)
2455 {
2456 free(*data);
2458 }
2459 }
2460 else
2461 *data = NULL;
2462
2463 if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len))
2464 {
2465 ERR("invalid http packet\n");
2466 free(*data);
2467 return RPC_S_PROTOCOL_ERROR;
2468 }
2469
2470 return RPC_S_OK;
2471}
2472
2473/* prepare the out pipe for use by RPC packets */
2475 HANDLE cancel_event, const UUID *connection_uuid,
2476 const UUID *out_pipe_uuid, ULONG *flow_control_increment,
2477 BOOL authorized)
2478{
2479 BOOL ret;
2481 RpcPktHdr *hdr;
2482 BYTE *data_from_server;
2483 RpcPktHdr pkt_from_server;
2484 ULONG field1, field3;
2485 BYTE buf[20];
2486
2487 if (!authorized)
2488 {
2489 /* ask wininet to authorize, if necessary */
2490 status = send_echo_request(out_request, async_data, cancel_event);
2491 if (status != RPC_S_OK) return status;
2492 }
2493 else
2494 rpcrt4_http_async_read(out_request, async_data, cancel_event, buf, sizeof(buf));
2495
2496 hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
2497 if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2498
2499 status = insert_content_length_header(out_request, hdr->common.frag_len);
2500 if (status != RPC_S_OK)
2501 {
2502 free(hdr);
2503 return status;
2504 }
2505
2506 TRACE("sending HTTP connect header to server\n");
2507 prepare_async_request(async_data);
2508 ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
2509 status = wait_async_request(async_data, ret, cancel_event);
2510 free(hdr);
2511 if (status != RPC_S_OK) return status;
2512
2513 status = rpcrt4_http_check_response(out_request);
2514 if (status != RPC_S_OK) return status;
2515
2516 status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2517 &pkt_from_server, &data_from_server);
2518 if (status != RPC_S_OK) return status;
2519 status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server,
2520 &field1);
2521 free(data_from_server);
2522 if (status != RPC_S_OK) return status;
2523 TRACE("received (%ld) from first prepare header\n", field1);
2524
2525 for (;;)
2526 {
2527 status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2528 &pkt_from_server, &data_from_server);
2529 if (status != RPC_S_OK) return status;
2530 if (pkt_from_server.http.flags != 0x0001) break;
2531
2532 TRACE("http idle packet, waiting for real packet\n");
2533 free(data_from_server);
2534 if (pkt_from_server.http.num_data_items != 0)
2535 {
2536 ERR("HTTP idle packet should have no data items instead of %d\n",
2537 pkt_from_server.http.num_data_items);
2538 return RPC_S_PROTOCOL_ERROR;
2539 }
2540 }
2541 status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
2542 &field1, flow_control_increment,
2543 &field3);
2544 free(data_from_server);
2545 if (status != RPC_S_OK) return status;
2546 TRACE("received (0x%08lx 0x%08lx %ld) from second prepare header\n", field1, *flow_control_increment, field3);
2547
2548 return RPC_S_OK;
2549}
2550
2551static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
2552{
2553 static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2554 UINT i = 0, x;
2555
2556 while (len > 0)
2557 {
2558 /* first 6 bits, all from bin[0] */
2559 base64[i++] = enc[(bin[0] & 0xfc) >> 2];
2560 x = (bin[0] & 3) << 4;
2561
2562 /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
2563 if (len == 1)
2564 {
2565 base64[i++] = enc[x];
2566 base64[i++] = '=';
2567 base64[i++] = '=';
2568 break;
2569 }
2570 base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
2571 x = (bin[1] & 0x0f) << 2;
2572
2573 /* next 6 bits 4 from bin[1] and 2 from bin[2] */
2574 if (len == 2)
2575 {
2576 base64[i++] = enc[x];
2577 base64[i++] = '=';
2578 break;
2579 }
2580 base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
2581
2582 /* last 6 bits, all from bin [2] */
2583 base64[i++] = enc[bin[2] & 0x3f];
2584 bin += 3;
2585 len -= 3;
2586 }
2587 base64[i] = 0;
2588 return i;
2589}
2590
2591static inline char decode_char( WCHAR c )
2592{
2593 if (c >= 'A' && c <= 'Z') return c - 'A';
2594 if (c >= 'a' && c <= 'z') return c - 'a' + 26;
2595 if (c >= '0' && c <= '9') return c - '0' + 52;
2596 if (c == '+') return 62;
2597 if (c == '/') return 63;
2598 return 64;
2599}
2600
2601static unsigned int decode_base64( const WCHAR *base64, unsigned int len, char *buf )
2602{
2603 unsigned int i = 0;
2604 char c0, c1, c2, c3;
2605 const WCHAR *p = base64;
2606
2607 while (len > 4)
2608 {
2609 if ((c0 = decode_char( p[0] )) > 63) return 0;
2610 if ((c1 = decode_char( p[1] )) > 63) return 0;
2611 if ((c2 = decode_char( p[2] )) > 63) return 0;
2612 if ((c3 = decode_char( p[3] )) > 63) return 0;
2613
2614 if (buf)
2615 {
2616 buf[i + 0] = (c0 << 2) | (c1 >> 4);
2617 buf[i + 1] = (c1 << 4) | (c2 >> 2);
2618 buf[i + 2] = (c2 << 6) | c3;
2619 }
2620 len -= 4;
2621 i += 3;
2622 p += 4;
2623 }
2624 if (p[2] == '=')
2625 {
2626 if ((c0 = decode_char( p[0] )) > 63) return 0;
2627 if ((c1 = decode_char( p[1] )) > 63) return 0;
2628
2629 if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
2630 i++;
2631 }
2632 else if (p[3] == '=')
2633 {
2634 if ((c0 = decode_char( p[0] )) > 63) return 0;
2635 if ((c1 = decode_char( p[1] )) > 63) return 0;
2636 if ((c2 = decode_char( p[2] )) > 63) return 0;
2637
2638 if (buf)
2639 {
2640 buf[i + 0] = (c0 << 2) | (c1 >> 4);
2641 buf[i + 1] = (c1 << 4) | (c2 >> 2);
2642 }
2643 i += 2;
2644 }
2645 else
2646 {
2647 if ((c0 = decode_char( p[0] )) > 63) return 0;
2648 if ((c1 = decode_char( p[1] )) > 63) return 0;
2649 if ((c2 = decode_char( p[2] )) > 63) return 0;
2650 if ((c3 = decode_char( p[3] )) > 63) return 0;
2651
2652 if (buf)
2653 {
2654 buf[i + 0] = (c0 << 2) | (c1 >> 4);
2655 buf[i + 1] = (c1 << 4) | (c2 >> 2);
2656 buf[i + 2] = (c2 << 6) | c3;
2657 }
2658 i += 3;
2659 }
2660 return i;
2661}
2662
2663static struct authinfo *alloc_authinfo(void)
2664{
2665 struct authinfo *ret;
2666
2667 if (!(ret = malloc(sizeof(*ret)))) return NULL;
2668
2669 SecInvalidateHandle(&ret->cred);
2670 SecInvalidateHandle(&ret->ctx);
2671 memset(&ret->exp, 0, sizeof(ret->exp));
2672 ret->scheme = 0;
2673 ret->attr = 0;
2674 ret->max_token = 0;
2675 ret->data = NULL;
2676 ret->data_len = 0;
2677 ret->finished = FALSE;
2678 return ret;
2679}
2680
2681static void destroy_authinfo(struct authinfo *info)
2682{
2683 if (!info) return;
2684
2685 if (SecIsValidHandle(&info->ctx))
2687 if (SecIsValidHandle(&info->cred))
2689
2690 free(info->data);
2691 free(info);
2692}
2693
2694static const struct
2695{
2696 const WCHAR *str;
2697 unsigned int len;
2699}
2700auth_schemes[] =
2701{
2702 { L"Basic", ARRAY_SIZE(L"Basic") - 1, RPC_C_HTTP_AUTHN_SCHEME_BASIC },
2703 { L"NTLM", ARRAY_SIZE(L"NTLM") - 1, RPC_C_HTTP_AUTHN_SCHEME_NTLM },
2704 { L"Passport", ARRAY_SIZE(L"Passport") - 1, RPC_C_HTTP_AUTHN_SCHEME_PASSPORT },
2705 { L"Digest", ARRAY_SIZE(L"Digest") - 1, RPC_C_HTTP_AUTHN_SCHEME_DIGEST },
2706 { L"Negotiate", ARRAY_SIZE(L"Negotiate") - 1, RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE }
2708
2710{
2711 unsigned int i;
2712 for (i = 0; i < ARRAY_SIZE(auth_schemes); i++)
2713 {
2715 (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
2716 }
2717 return 0;
2718}
2719
2721{
2722 DWORD len, index = 0;
2723 for (;;)
2724 {
2725 len = buflen;
2727 if (auth_scheme_from_header(buffer) == scheme) break;
2728 }
2729 return TRUE;
2730}
2731
2733 const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
2734{
2735 struct authinfo *info = *auth_ptr;
2738
2739 if ((!info && !(info = alloc_authinfo()))) return RPC_S_SERVER_UNAVAILABLE;
2740
2741 switch (creds->AuthnSchemes[0])
2742 {
2744 {
2745 int userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
2746 int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
2747
2748 info->data_len = userlen + passlen + 1;
2749 if (!(info->data = malloc(info->data_len)))
2750 {
2752 break;
2753 }
2754 WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, info->data, userlen, NULL, NULL);
2755 info->data[userlen] = ':';
2756 WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, info->data + userlen + 1, passlen, NULL, NULL);
2757
2759 info->finished = TRUE;
2760 status = RPC_S_OK;
2761 break;
2762 }
2765 {
2766
2767 static SEC_WCHAR ntlmW[] = L"NTLM", negotiateW[] = L"Negotiate";
2769 SecBufferDesc out_desc, in_desc;
2770 SecBuffer out, in;
2773 int scheme_len;
2774 const WCHAR *p;
2775 WCHAR auth_value[2048];
2776 DWORD size = sizeof(auth_value);
2777 BOOL first = FALSE;
2778
2780 else scheme = negotiateW;
2781 scheme_len = lstrlenW( scheme );
2782
2783 if (!*auth_ptr)
2784 {
2785 TimeStamp exp;
2786 SecPkgInfoW *pkg_info;
2787
2789 if (ret != SEC_E_OK) break;
2790
2791 ret = QuerySecurityPackageInfoW(scheme, &pkg_info);
2792 if (ret != SEC_E_OK) break;
2793
2794 info->max_token = pkg_info->cbMaxToken;
2795 FreeContextBuffer(pkg_info);
2796 first = TRUE;
2797 }
2798 else
2799 {
2800 if (info->finished || !get_authvalue(request, creds->AuthnSchemes[0], auth_value, size)) break;
2801 if (auth_scheme_from_header(auth_value) != info->scheme)
2802 {
2803 ERR("authentication scheme changed\n");
2804 break;
2805 }
2806 }
2807 in.BufferType = SECBUFFER_TOKEN;
2808 in.cbBuffer = 0;
2809 in.pvBuffer = NULL;
2810
2811 in_desc.ulVersion = 0;
2812 in_desc.cBuffers = 1;
2813 in_desc.pBuffers = &in;
2814
2815 p = auth_value + scheme_len;
2816 if (!first && *p == ' ')
2817 {
2818 int len = lstrlenW(++p);
2819 in.cbBuffer = decode_base64(p, len, NULL);
2820 if (!(in.pvBuffer = malloc(in.cbBuffer))) break;
2821 decode_base64(p, len, in.pvBuffer);
2822 }
2823 out.BufferType = SECBUFFER_TOKEN;
2824 out.cbBuffer = info->max_token;
2825 if (!(out.pvBuffer = malloc(out.cbBuffer)))
2826 {
2827 free(in.pvBuffer);
2828 break;
2829 }
2830 out_desc.ulVersion = 0;
2831 out_desc.cBuffers = 1;
2832 out_desc.pBuffers = &out;
2833
2834 ret = InitializeSecurityContextW(first ? &info->cred : NULL, first ? NULL : &info->ctx,
2835 first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP,
2836 in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc,
2837 &info->attr, &info->exp);
2838 free(in.pvBuffer);
2839 if (ret == SEC_E_OK)
2840 {
2841 free(info->data);
2842 info->data = out.pvBuffer;
2843 info->data_len = out.cbBuffer;
2844 info->finished = TRUE;
2845 TRACE("sending last auth packet\n");
2846 status = RPC_S_OK;
2847 }
2848 else if (ret == SEC_I_CONTINUE_NEEDED)
2849 {
2850 free(info->data);
2851 info->data = out.pvBuffer;
2852 info->data_len = out.cbBuffer;
2853 TRACE("sending next auth packet\n");
2854 status = RPC_S_OK;
2855 }
2856 else
2857 {
2858 ERR("InitializeSecurityContextW failed with error 0x%08lx\n", ret);
2859 free(out.pvBuffer);
2860 break;
2861 }
2862 info->scheme = creds->AuthnSchemes[0];
2863 break;
2864 }
2865 default:
2866 FIXME("scheme %lu not supported\n", creds->AuthnSchemes[0]);
2867 break;
2868 }
2869
2870 if (status != RPC_S_OK)
2871 {
2873 *auth_ptr = NULL;
2874 return status;
2875 }
2876 *auth_ptr = info;
2877 return RPC_S_OK;
2878}
2879
2881{
2882 static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' '};
2883 static const WCHAR basicW[] = {'B','a','s','i','c',' '};
2884 static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
2885 static const WCHAR ntlmW[] = {'N','T','L','M',' '};
2886 int scheme_len, auth_len = ARRAY_SIZE(authW), len = ((data_len + 2) * 4) / 3;
2887 const WCHAR *scheme_str;
2888 WCHAR *header, *ptr;
2890
2891 switch (scheme)
2892 {
2894 scheme_str = basicW;
2895 scheme_len = ARRAY_SIZE(basicW);
2896 break;
2898 scheme_str = negotiateW;
2899 scheme_len = ARRAY_SIZE(negotiateW);
2900 break;
2902 scheme_str = ntlmW;
2903 scheme_len = ARRAY_SIZE(ntlmW);
2904 break;
2905 default:
2906 ERR("unknown scheme %lu\n", scheme);
2908 }
2909 if ((header = malloc((auth_len + scheme_len + len + 2) * sizeof(WCHAR))))
2910 {
2911 memcpy(header, authW, auth_len * sizeof(WCHAR));
2912 ptr = header + auth_len;
2913 memcpy(ptr, scheme_str, scheme_len * sizeof(WCHAR));
2914 ptr += scheme_len;
2916 ptr[len++] = '\r';
2917 ptr[len++] = '\n';
2918 ptr[len] = 0;
2920 status = RPC_S_OK;
2921 free(header);
2922 }
2923 return status;
2924}
2925
2926static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
2927{
2928 DWORD count, len = 0, size = sizeof(len);
2929 char buf[2048];
2930
2932 if (!len) return;
2933 for (;;)
2934 {
2935 count = min(sizeof(buf), len);
2936 if (rpcrt4_http_async_read(request, async_data, cancel_event, buf, count) <= 0) return;
2937 len -= count;
2938 }
2939}
2940
2942{
2943 struct authinfo *info = NULL;
2945 BOOL ret;
2946
2947 for (;;)
2948 {
2950 if (status != RPC_S_OK) break;
2951
2952 status = insert_authorization_header(request, info->scheme, info->data, info->data_len);
2953 if (status != RPC_S_OK) break;
2954
2958 if (status != RPC_S_OK || info->finished) break;
2959
2961 if (status != RPC_S_OK && status != ERROR_ACCESS_DENIED) break;
2963 }
2964
2965 if (info->scheme != RPC_C_HTTP_AUTHN_SCHEME_BASIC)
2967
2969 return status;
2970}
2971
2973{
2976
2978 return FALSE;
2979
2980 creds = httpc->common.QOS->qos->u.HttpCredentials;
2982 return FALSE;
2983
2984 id = creds->TransportCredentials;
2985 if (!id || !id->User || !id->Password) return FALSE;
2986
2987 return TRUE;
2988}
2989
2991{
2992 return httpc->common.QOS &&
2995}
2996
2998{
2999 static WCHAR httpW[] = L"http";
3000 static WCHAR httpsW[] = L"https";
3001 URL_COMPONENTSW uc;
3002 DWORD len;
3003 WCHAR *url;
3004 BOOL ret;
3005
3006 if (!value) return RPC_S_OK;
3007
3008 uc.dwStructSize = sizeof(uc);
3009 uc.lpszScheme = is_secure(httpc) ? httpsW : httpW;
3010 uc.dwSchemeLength = 0;
3011 uc.lpszHostName = httpc->servername;
3012 uc.dwHostNameLength = 0;
3013 uc.nPort = 0;
3014 uc.lpszUserName = NULL;
3015 uc.dwUserNameLength = 0;
3016 uc.lpszPassword = NULL;
3017 uc.dwPasswordLength = 0;
3018 uc.lpszUrlPath = NULL;
3019 uc.dwUrlPathLength = 0;
3020 uc.lpszExtraInfo = NULL;
3021 uc.dwExtraInfoLength = 0;
3022
3025
3026 if (!(url = malloc(len))) return RPC_S_OUT_OF_MEMORY;
3027
3028 len = len / sizeof(WCHAR) - 1;
3029 if (!InternetCreateUrlW(&uc, 0, url, &len))
3030 {
3031 free(url);
3033 }
3034
3036 free(url);
3037 if (!ret) return RPC_S_SERVER_UNAVAILABLE;
3038
3039 return RPC_S_OK;
3040}
3041
3043{
3044 RpcConnection_http *httpc = (RpcConnection_http *)Connection;
3045 static const WCHAR wszRpcProxyPrefix[] = L"/rpc/rpcproxy.dll?";
3046 LPCWSTR wszAcceptTypes[] = { L"application/rpc", NULL };
3047 DWORD flags;
3048 WCHAR *url;
3050 BOOL secure, credentials;
3051 HttpTimerThreadData *timer_data;
3052 HANDLE thread;
3053
3054 TRACE("(%s, %s)\n", Connection->NetworkAddr, Connection->Endpoint);
3055
3056 if (Connection->server)
3057 {
3058 ERR("ncacn_http servers not supported yet\n");
3060 }
3061
3062 if (httpc->in_request)
3063 return RPC_S_OK;
3064
3066
3067 UuidCreate(&httpc->connection_uuid);
3068 UuidCreate(&httpc->in_pipe_uuid);
3069 UuidCreate(&httpc->out_pipe_uuid);
3070
3072 if (status != RPC_S_OK)
3073 return status;
3074
3075 url = malloc(sizeof(wszRpcProxyPrefix) +
3076 (strlen(Connection->NetworkAddr) + 1 + strlen(Connection->Endpoint)) * sizeof(WCHAR));
3077 if (!url)
3078 return RPC_S_OUT_OF_MEMORY;
3079 memcpy(url, wszRpcProxyPrefix, sizeof(wszRpcProxyPrefix));
3080 MultiByteToWideChar(CP_ACP, 0, Connection->NetworkAddr, -1, url+ARRAY_SIZE(wszRpcProxyPrefix)-1,
3081 strlen(Connection->NetworkAddr)+1);
3082 lstrcatW(url, L":");
3083 MultiByteToWideChar(CP_ACP, 0, Connection->Endpoint, -1, url+lstrlenW(url), strlen(Connection->Endpoint)+1);
3084
3085 secure = is_secure(httpc);
3086 credentials = has_credentials(httpc);
3087
3091 if (credentials) flags |= INTERNET_FLAG_NO_AUTH;
3092
3093 status = set_auth_cookie(httpc, Connection->CookieAuth);
3094 if (status != RPC_S_OK)
3095 {
3096 free(url);
3097 return status;
3098 }
3099 httpc->in_request = HttpOpenRequestW(httpc->session, L"RPC_IN_DATA", url, NULL, NULL, wszAcceptTypes,
3100 flags, (DWORD_PTR)httpc->async_data);
3101 if (!httpc->in_request)
3102 {
3103 ERR("HttpOpenRequestW failed with error %ld\n", GetLastError());
3104 free(url);
3106 }
3107
3108 if (credentials)
3109 {
3110 status = authorize_request(httpc, httpc->in_request);
3111 if (status != RPC_S_OK)
3112 {
3113 free(url);
3114 return status;
3115 }
3117 if (status != RPC_S_OK)
3118 {
3119 free(url);
3120 return status;
3121 }
3122 drain_content(httpc->in_request, httpc->async_data, httpc->cancel_event);
3123 }
3124
3125 httpc->out_request = HttpOpenRequestW(httpc->session, L"RPC_OUT_DATA", url, NULL, NULL, wszAcceptTypes,
3126 flags, (DWORD_PTR)httpc->async_data);
3127 free(url);
3128 if (!httpc->out_request)
3129 {
3130 ERR("HttpOpenRequestW failed with error %ld\n", GetLastError());
3132 }
3133
3134 if (credentials)
3135 {
3136 status = authorize_request(httpc, httpc->out_request);
3137 if (status != RPC_S_OK)
3138 return status;
3139 }
3140
3142 &httpc->connection_uuid, &httpc->in_pipe_uuid,
3143 &Connection->assoc->http_uuid, credentials);
3144 if (status != RPC_S_OK)
3145 return status;
3146
3148 &httpc->connection_uuid, &httpc->out_pipe_uuid,
3149 &httpc->flow_control_increment, credentials);
3150 if (status != RPC_S_OK)
3151 return status;
3152
3153 httpc->flow_control_mark = httpc->flow_control_increment / 2;
3154 httpc->last_sent_time = GetTickCount();
3156
3157 timer_data = malloc(sizeof(*timer_data));
3158 if (!timer_data)
3159 return ERROR_OUTOFMEMORY;
3160 timer_data->timer_param = httpc->in_request;
3161 timer_data->last_sent_time = &httpc->last_sent_time;
3162 timer_data->timer_cancelled = httpc->timer_cancelled;
3163 /* FIXME: should use CreateTimerQueueTimer when implemented */
3164 thread = CreateThread(NULL, 0, rpcrt4_http_timer_thread, timer_data, 0, NULL);
3165 if (!thread)
3166 {
3167 free(timer_data);
3168 return GetLastError();
3169 }
3171
3172 return RPC_S_OK;
3173}
3174
3176{
3177 assert(0);
3179}
3180
3182 void *buffer, unsigned int count)
3183{
3184 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3185 return rpcrt4_http_async_read(httpc->out_request, httpc->async_data, httpc->cancel_event, buffer, count);
3186}
3187
3189{
3190 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3192 DWORD hdr_length;
3193 LONG dwRead;
3194 RpcPktCommonHdr common_hdr;
3195
3196 *Header = NULL;
3197
3198 TRACE("(%p, %p, %p)\n", Connection, Header, Payload);
3199
3200again:
3201 /* read packet common header */
3202 dwRead = rpcrt4_ncacn_http_read(Connection, &common_hdr, sizeof(common_hdr));
3203 if (dwRead != sizeof(common_hdr)) {
3204 WARN("Short read of header, %ld bytes\n", dwRead);
3206 goto fail;
3207 }
3208 if (!memcmp(&common_hdr, "HTTP/1.1", sizeof("HTTP/1.1")) ||
3209 !memcmp(&common_hdr, "HTTP/1.0", sizeof("HTTP/1.0")))
3210 {
3211 FIXME("server returned %s\n", debugstr_a((const char *)&common_hdr));
3213 goto fail;
3214 }
3215
3216 status = RPCRT4_ValidateCommonHeader(&common_hdr);
3217 if (status != RPC_S_OK) goto fail;
3218
3219 hdr_length = RPCRT4_GetHeaderSize((RpcPktHdr*)&common_hdr);
3220 if (hdr_length == 0) {
3221 WARN("header length == 0\n");
3223 goto fail;
3224 }
3225
3226 *Header = malloc(hdr_length);
3227 if (!*Header)
3228 {
3230 goto fail;
3231 }
3232 memcpy(*Header, &common_hdr, sizeof(common_hdr));
3233
3234 /* read the rest of packet header */
3235 dwRead = rpcrt4_ncacn_http_read(Connection, &(*Header)->common + 1, hdr_length - sizeof(common_hdr));
3236 if (dwRead != hdr_length - sizeof(common_hdr)) {
3237 WARN("bad header length, %ld bytes, hdr_length %ld\n", dwRead, hdr_length);
3239 goto fail;
3240 }
3241
3242 if (common_hdr.frag_len - hdr_length)
3243 {
3244 *Payload = malloc(common_hdr.frag_len - hdr_length);
3245 if (!*Payload)
3246 {
3248 goto fail;
3249 }
3250
3251 dwRead = rpcrt4_ncacn_http_read(Connection, *Payload, common_hdr.frag_len - hdr_length);
3252 if (dwRead != common_hdr.frag_len - hdr_length)
3253 {
3254 WARN("bad data length, %ld/%ld\n", dwRead, common_hdr.frag_len - hdr_length);
3256 goto fail;
3257 }
3258 }
3259 else
3260 *Payload = NULL;
3261
3262 if ((*Header)->common.ptype == PKT_HTTP)
3263 {
3264 if (!RPCRT4_IsValidHttpPacket(*Header, *Payload, common_hdr.frag_len - hdr_length))
3265 {
3266 ERR("invalid http packet of length %d bytes\n", (*Header)->common.frag_len);
3268 goto fail;
3269 }
3270 if ((*Header)->http.flags == 0x0001)
3271 {
3272 TRACE("http idle packet, waiting for real packet\n");
3273 if ((*Header)->http.num_data_items != 0)
3274 {
3275 ERR("HTTP idle packet should have no data items instead of %d\n", (*Header)->http.num_data_items);
3277 goto fail;
3278 }
3279 }
3280 else if ((*Header)->http.flags == 0x0002)
3281 {
3282 ULONG bytes_transmitted;
3283 ULONG flow_control_increment;
3284 UUID pipe_uuid;
3286 Connection->server,
3287 &bytes_transmitted,
3288 &flow_control_increment,
3289 &pipe_uuid);
3290 if (status != RPC_S_OK)
3291 goto fail;
3292 TRACE("received http flow control header (0x%lx, 0x%lx, %s)\n",
3293 bytes_transmitted, flow_control_increment, debugstr_guid(&pipe_uuid));
3294 /* FIXME: do something with parsed data */
3295 }
3296 else
3297 {
3298 FIXME("unrecognised http packet with flags 0x%04x\n", (*Header)->http.flags);
3300 goto fail;
3301 }
3302 free(*Header);
3303 *Header = NULL;
3304 free(*Payload);
3305 *Payload = NULL;
3306 goto again;
3307 }
3308
3309 /* success */
3310 status = RPC_S_OK;
3311
3312 httpc->bytes_received += common_hdr.frag_len;
3313
3314 TRACE("httpc->bytes_received = 0x%lx\n", httpc->bytes_received);
3315
3316 if (httpc->bytes_received > httpc->flow_control_mark)
3317 {
3319 httpc->bytes_received,
3321 &httpc->out_pipe_uuid);
3322 if (hdr)
3323 {
3324 DWORD bytes_written;
3325 BOOL ret2;
3326 TRACE("sending flow control packet at 0x%lx\n", httpc->bytes_received);
3327 ret2 = InternetWriteFile(httpc->in_request, hdr, hdr->common.frag_len, &bytes_written);
3328 free(hdr);
3329 if (ret2)
3330 httpc->flow_control_mark = httpc->bytes_received + httpc->flow_control_increment / 2;
3331 }
3332 }
3333
3334fail:
3335 if (status != RPC_S_OK) {
3336 free(*Header);
3337 *Header = NULL;
3338 free(*Payload);
3339 *Payload = NULL;
3340 }
3341 return status;
3342}
3343
3345 const void *buffer, unsigned int count)
3346{
3347 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3348 DWORD bytes_written;
3349 BOOL ret;
3350
3351 httpc->last_sent_time = ~0U; /* disable idle packet sending */
3352 ret = InternetWriteFile(httpc->in_request, buffer, count, &bytes_written);
3353 httpc->last_sent_time = GetTickCount();
3354 TRACE("%p %p %u -> %s\n", httpc->in_request, buffer, count, ret ? "TRUE" : "FALSE");
3355 return ret ? bytes_written : -1;
3356}
3357
3359{
3360 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3361
3362 TRACE("\n");
3363
3364 SetEvent(httpc->timer_cancelled);
3365 if (httpc->in_request)
3367 httpc->in_request = NULL;
3368 if (httpc->out_request)
3370 httpc->out_request = NULL;
3371 if (httpc->app_info)
3373 httpc->app_info = NULL;
3374 if (httpc->session)
3376 httpc->session = NULL;
3378 if (httpc->cancel_event)
3379 CloseHandle(httpc->cancel_event);
3380 free(httpc->servername);
3381 httpc->servername = NULL;
3382
3383 return 0;
3384}
3385
3387{
3388 rpcrt4_ncacn_http_close(conn); /* FIXME */
3389}
3390
3392{
3393 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3394
3395 SetEvent(httpc->cancel_event);
3396}
3397
3399{
3400 FIXME("\n");
3401 return RPC_S_ACCESS_DENIED;
3402}
3403
3405{
3406 RpcConnection_http *httpc = (RpcConnection_http *) Connection;
3407 BOOL ret;
3409
3414 return status == RPC_S_OK ? 0 : -1;
3415}
3416
3417static size_t rpcrt4_ncacn_http_get_top_of_tower(unsigned char *tower_data,
3418 const char *networkaddr,
3419 const char *endpoint)
3420{
3421 return rpcrt4_ip_tcp_get_top_of_tower(tower_data, networkaddr,
3423}
3424
3425static RPC_STATUS rpcrt4_ncacn_http_parse_top_of_tower(const unsigned char *tower_data,
3426 size_t tower_size,
3427 char **networkaddr,
3428 char **endpoint)
3429{
3430 return rpcrt4_ip_tcp_parse_top_of_tower(tower_data, tower_size,
3431 networkaddr, EPM_PROTOCOL_HTTP,
3432 endpoint);
3433}
3434
3435static const struct connection_ops conn_protseq_list[] = {
3436 { "ncacn_np",
3450 NULL,
3457 NULL
3458 },
3459 { "ncalrpc",
3473 NULL,
3481 },
3482 { "ncacn_ip_tcp",
3496 NULL,
3503 NULL
3504 },
3505 { "ncacn_http",
3526 NULL
3527 },
3528};
3529
3530
3531static const struct protseq_ops protseq_list[] =
3532{
3533 {
3534 "ncacn_np",
3541 },
3542 {
3543 "ncalrpc",
3550 },
3551 {
3552 "ncacn_ip_tcp",
3559 },
3560};
3561
3562const struct protseq_ops *rpcrt4_get_protseq_ops(const char *protseq)
3563{
3564 unsigned int i;
3565 for(i = 0; i < ARRAY_SIZE(protseq_list); i++)
3566 if (!strcmp(protseq_list[i].name, protseq))
3567 return &protseq_list[i];
3568 return NULL;
3569}
3570
3571static const struct connection_ops *rpcrt4_get_conn_protseq_ops(const char *protseq)
3572{
3573 unsigned int i;
3574 for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
3575 if (!strcmp(conn_protseq_list[i].name, protseq))
3576 return &conn_protseq_list[i];
3577 return NULL;
3578}
3579
3580/**** interface to rest of code ****/
3581
3583{
3584 TRACE("(Connection == ^%p)\n", Connection);
3585
3586 assert(!Connection->server);
3587 return Connection->ops->open_connection_client(Connection);
3588}
3589
3591{
3592 TRACE("(Connection == ^%p)\n", Connection);
3593 if (SecIsValidHandle(&Connection->ctx))
3594 {
3595 DeleteSecurityContext(&Connection->ctx);
3596 SecInvalidateHandle(&Connection->ctx);
3597 }
3598 rpcrt4_conn_close(Connection);
3599 return RPC_S_OK;
3600}
3601
3603 LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint,
3604 LPCWSTR NetworkOptions, RpcAuthInfo* AuthInfo, RpcQualityOfService *QOS, LPCWSTR CookieAuth)
3605{
3606 static LONG next_id;
3607 const struct connection_ops *ops;
3608 RpcConnection* NewConnection;
3609
3610 ops = rpcrt4_get_conn_protseq_ops(Protseq);
3611 if (!ops)
3612 {
3613 FIXME("not supported for protseq %s\n", Protseq);
3615 }
3616
3617 NewConnection = ops->alloc();
3618 NewConnection->ref = 1;
3619 NewConnection->server = server;
3620 NewConnection->ops = ops;
3621 NewConnection->NetworkAddr = strdup(NetworkAddr);
3622 NewConnection->Endpoint = strdup(Endpoint);
3623 NewConnection->NetworkOptions = wcsdup(NetworkOptions);
3624 NewConnection->CookieAuth = wcsdup(CookieAuth);
3626 NewConnection->NextCallId = 1;
3627
3628 SecInvalidateHandle(&NewConnection->ctx);
3629 if (AuthInfo) RpcAuthInfo_AddRef(AuthInfo);
3630 NewConnection->AuthInfo = AuthInfo;
3631 NewConnection->auth_context_id = InterlockedIncrement( &next_id );
3633 NewConnection->QOS = QOS;
3634
3635 list_init(&NewConnection->conn_pool_entry);
3636 list_init(&NewConnection->protseq_entry);
3637
3638 TRACE("connection: %p\n", NewConnection);
3639 *Connection = NewConnection;
3640
3641 return RPC_S_OK;
3642}
3643
3645{
3646 RpcConnection *connection;
3648
3649 err = RPCRT4_CreateConnection(&connection, old_connection->server, rpcrt4_conn_get_name(old_connection),
3650 old_connection->NetworkAddr, old_connection->Endpoint, NULL,
3651 old_connection->AuthInfo, old_connection->QOS, old_connection->CookieAuth);
3652 if (err != RPC_S_OK)
3653 return NULL;
3654
3655 rpcrt4_conn_handoff(old_connection, connection);
3656 if (old_connection->protseq)
3657 {
3658 EnterCriticalSection(&old_connection->protseq->cs);
3659 connection->protseq = old_connection->protseq;
3660 list_add_tail(&old_connection->protseq->connections, &connection->protseq_entry);
3661 LeaveCriticalSection(&old_connection->protseq->cs);
3662 }
3663 return connection;
3664}
3665
3667{
3668 HANDLE event = NULL;
3669
3670 if (connection->ref > 1)
3671 event = connection->wait_release = CreateEventW(NULL, TRUE, FALSE, NULL);
3672
3673 RPCRT4_ReleaseConnection(connection);
3674
3675 if(event)
3676 {
3679 }
3680}
3681
3683{
3684 LONG ref = InterlockedIncrement(&connection->ref);
3685 TRACE("%p ref=%lu\n", connection, ref);
3686 return connection;
3687}
3688
3690{
3691 LONG ref;
3692
3693 /* protseq stores a list of active connections, but does not own references to them.
3694 * It may need to grab a connection from the list, which could lead to a race if
3695 * connection is being released, but not yet removed from the list. We handle that
3696 * by synchronizing on CS here. */
3697 if (connection->protseq)
3698 {
3699 EnterCriticalSection(&connection->protseq->cs);
3700 ref = InterlockedDecrement(&connection->ref);
3701 if (!ref)
3702 list_remove(&connection->protseq_entry);
3703 LeaveCriticalSection(&connection->protseq->cs);
3704 }
3705 else
3706 {
3707 ref = InterlockedDecrement(&connection->ref);
3708 }
3709
3710 TRACE("%p ref=%lu\n", connection, ref);
3711
3712 if (!ref)
3713 {
3714 RPCRT4_CloseConnection(connection);
3715 free(connection->Endpoint);
3716 free(connection->NetworkAddr);
3717 free(connection->NetworkOptions);
3718 free(connection->CookieAuth);
3719 if (connection->AuthInfo) RpcAuthInfo_Release(connection->AuthInfo);
3720 if (connection->QOS) RpcQualityOfService_Release(connection->QOS);
3721
3722 /* server-only */
3723 if (connection->server_binding) RPCRT4_ReleaseBinding(connection->server_binding);
3724 else if (connection->assoc) RpcAssoc_ConnectionReleased(connection->assoc);
3725
3726 if (connection->wait_release) SetEvent(connection->wait_release);
3727
3728 free(connection);
3729 }
3730}
3731
3732RPC_STATUS RPCRT4_IsServerListening(const char *protseq, const char *endpoint)
3733{
3734 const struct connection_ops *ops;
3735
3736 ops = rpcrt4_get_conn_protseq_ops(protseq);
3737 if (!ops)
3738 {
3739 FIXME("not supported for protseq %s\n", protseq);
3740 return RPC_S_INVALID_BINDING;
3741 }
3742
3743 return ops->is_server_listening(endpoint);
3744}
3745
3746RPC_STATUS RpcTransport_GetTopOfTower(unsigned char *tower_data,
3747 size_t *tower_size,
3748 const char *protseq,
3749 const char *networkaddr,
3750 const char *endpoint)
3751{
3752 twr_empty_floor_t *protocol_floor;
3754
3755 *tower_size = 0;
3756
3757 if (!protseq_ops)
3759
3760 if (!tower_data)
3761 {
3762 *tower_size = sizeof(*protocol_floor);
3763 *tower_size += protseq_ops->get_top_of_tower(NULL, networkaddr, endpoint);
3764 return RPC_S_OK;
3765 }
3766
3767 protocol_floor = (twr_empty_floor_t *)tower_data;
3768 protocol_floor->count_lhs = sizeof(protocol_floor->protid);
3769 protocol_floor->protid = protseq_ops->epm_protocols[0];
3770 protocol_floor->count_rhs = 0;
3771
3772 tower_data += sizeof(*protocol_floor);
3773
3774 *tower_size = protseq_ops->get_top_of_tower(tower_data, networkaddr, endpoint);
3775 if (!*tower_size)
3776 return EPT_S_NOT_REGISTERED;
3777
3778 *tower_size += sizeof(*protocol_floor);
3779
3780 return RPC_S_OK;
3781}
3782
3783RPC_STATUS RpcTransport_ParseTopOfTower(const unsigned char *tower_data,
3784 size_t tower_size,
3785 char **protseq,
3786 char **networkaddr,
3787 char **endpoint)
3788{
3789 const twr_empty_floor_t *protocol_floor;
3790 const twr_empty_floor_t *floor4;
3791 const struct connection_ops *protseq_ops = NULL;
3793 unsigned int i;
3794
3795 if (tower_size < sizeof(*protocol_floor))
3796 return EPT_S_NOT_REGISTERED;
3797
3798 protocol_floor = (const twr_empty_floor_t *)tower_data;
3799 tower_data += sizeof(*protocol_floor);
3800 tower_size -= sizeof(*protocol_floor);
3801 if ((protocol_floor->count_lhs != sizeof(protocol_floor->protid)) ||
3802 (protocol_floor->count_rhs > tower_size))
3803 return EPT_S_NOT_REGISTERED;
3804 tower_data += protocol_floor->count_rhs;
3805 tower_size -= protocol_floor->count_rhs;
3806
3807 floor4 = (const twr_empty_floor_t *)tower_data;
3808 if ((tower_size < sizeof(*floor4)) ||
3809 (floor4->count_lhs != sizeof(floor4->protid)))
3810 return EPT_S_NOT_REGISTERED;
3811
3812 for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
3813 if ((protocol_floor->protid == conn_protseq_list[i].epm_protocols[0]) &&
3814 (floor4->protid == conn_protseq_list[i].epm_protocols[1]))
3815 {
3817 break;
3818 }
3819
3820 if (!protseq_ops)
3821 return EPT_S_NOT_REGISTERED;
3822
3823 status = protseq_ops->parse_top_of_tower(tower_data, tower_size, networkaddr, endpoint);
3824
3825 if ((status == RPC_S_OK) && protseq)
3826 {
3827 *protseq = I_RpcAllocate(strlen(protseq_ops->name) + 1);
3828 strcpy(*protseq, protseq_ops->name);
3829 }
3830
3831 return status;
3832}
3833
3834/***********************************************************************
3835 * RpcNetworkIsProtseqValidW (RPCRT4.@)
3836 *
3837 * Checks if the given protocol sequence is known by the RPC system.
3838 * If it is, returns RPC_S_OK, otherwise RPC_S_PROTSEQ_NOT_SUPPORTED.
3839 *
3840 */
3842{
3843 char ps[0x10];
3844
3845 WideCharToMultiByte(CP_ACP, 0, protseq, -1,
3846 ps, sizeof ps, NULL, NULL);
3848 return RPC_S_OK;
3849
3850 FIXME("Unknown protseq %s\n", debugstr_w(protseq));
3851
3853}
3854
3855/***********************************************************************
3856 * RpcNetworkIsProtseqValidA (RPCRT4.@)
3857 */
3859{
3860 UNICODE_STRING protseqW;
3861
3862 if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
3863 {
3865 RtlFreeUnicodeString(&protseqW);
3866 return ret;
3867 }
3868 return RPC_S_OUT_OF_MEMORY;
3869}
3870
3871/***********************************************************************
3872 * RpcProtseqVectorFreeA (RPCRT4.@)
3873 */
3875{
3876 TRACE("(%p)\n", protseqs);
3877
3878 if (*protseqs)
3879 {
3880 unsigned int i;
3881 for (i = 0; i < (*protseqs)->Count; i++)
3882 free((*protseqs)->Protseq[i]);
3883 free(*protseqs);
3884 *protseqs = NULL;
3885 }
3886 return RPC_S_OK;
3887}
3888
3889/***********************************************************************
3890 * RpcProtseqVectorFreeW (RPCRT4.@)
3891 */
3893{
3894 TRACE("(%p)\n", protseqs);
3895
3896 if (*protseqs)
3897 {
3898 unsigned int i;
3899 for (i = 0; i < (*protseqs)->Count; i++)
3900 free((*protseqs)->Protseq[i]);
3901 free(*protseqs);
3902 *protseqs = NULL;
3903 }
3904 return RPC_S_OK;
3905}
3906
3907/***********************************************************************
3908 * RpcNetworkInqProtseqsW (RPCRT4.@)
3909 */
3911{
3912 RPC_PROTSEQ_VECTORW *pvector;
3913 unsigned int i;
3915
3916 TRACE("(%p)\n", protseqs);
3917
3918 *protseqs = malloc(sizeof(RPC_PROTSEQ_VECTORW) + sizeof(unsigned short*) * ARRAY_SIZE(protseq_list));
3919 if (!*protseqs)
3920 goto end;
3921 pvector = *protseqs;
3922 pvector->Count = 0;
3923 for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3924 {
3925 pvector->Protseq[i] = malloc((strlen(protseq_list[i].name) + 1) * sizeof(unsigned short));
3926 if (pvector->Protseq[i] == NULL)
3927 goto end;
3929 (WCHAR*)pvector->Protseq[i], strlen(protseq_list[i].name) + 1);
3930 pvector->Count++;
3931 }
3932 status = RPC_S_OK;
3933
3934end:
3935 if (status != RPC_S_OK)
3937 return status;
3938}
3939
3940/***********************************************************************
3941 * RpcNetworkInqProtseqsA (RPCRT4.@)
3942 */
3944{
3945 RPC_PROTSEQ_VECTORA *pvector;
3946 unsigned int i;
3948
3949 TRACE("(%p)\n", protseqs);
3950
3951 *protseqs = malloc(sizeof(RPC_PROTSEQ_VECTORW) + sizeof(unsigned char*) * ARRAY_SIZE(protseq_list));
3952 if (!*protseqs)
3953 goto end;
3954 pvector = *protseqs;
3955 pvector->Count = 0;
3956 for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3957 {
3958 pvector->Protseq[i] = malloc(strlen(protseq_list[i].name) + 1);
3959 if (pvector->Protseq[i] == NULL)
3960 goto end;
3961 strcpy((char*)pvector->Protseq[i], protseq_list[i].name);
3962 pvector->Count++;
3963 }
3964 status = RPC_S_OK;
3965
3966end:
3967 if (status != RPC_S_OK)
3969 return status;
3970}
BOOL WINAPI GetNamedPipeClientProcessId(HANDLE pipe, ULONG *id)
unsigned char BOOLEAN
HRESULT WINAPI DECLSPEC_HOTPATCH SetThreadDescription(HANDLE thread, PCWSTR description)
_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 realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#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 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 InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
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 L(x)
Definition: resources.c:13
#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:37
#define EPM_PROTOCOL_SMB
Definition: epm_towers.h:35
#define EPM_PROTOCOL_PIPE
Definition: epm_towers.h:36
#define EPM_PROTOCOL_IP
Definition: epm_towers.h:29
#define EPM_PROTOCOL_NCALRPC
Definition: epm_towers.h:32
#define EPM_PROTOCOL_TCP
Definition: epm_towers.h:27
#define EPM_PROTOCOL_HTTP
Definition: epm_towers.h:47
#define EPM_PROTOCOL_NCACN
Definition: epm_towers.h:31
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#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
static PVOID ptr
Definition: dispmode.c:27
#define sprintf
Definition: sprintf.c:45
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:157
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:1625
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:1626
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
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(...)
static const WCHAR basicW[]
Definition: request.c:882
static const WCHAR negotiateW[]
Definition: request.c:886
static const WCHAR ntlmW[]
Definition: request.c:883
#define calloc
Definition: rosglue.h:14
void RpcAssoc_ConnectionReleased(RpcAssoc *assoc)
Definition: rpc_assoc.c:447
ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1165
ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos)
Definition: rpc_binding.c:1342
ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1170
RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding *Binding)
Definition: rpc_binding.c:237
LPWSTR RPCRT4_strndupW(LPCWSTR src, INT slen)
Definition: rpc_binding.c:79
ULONG RpcQualityOfService_Release(RpcQualityOfService *qos)
Definition: rpc_binding.c:1347
static const char * rpcrt4_conn_get_name(const RpcConnection *Connection)
Definition: rpc_binding.h:179
static RPC_STATUS rpcrt4_conn_handoff(RpcConnection *old_conn, RpcConnection *new_conn)
Definition: rpc_binding.h:211
secure_packet_direction
Definition: rpc_binding.h:31
static int rpcrt4_conn_close(RpcConnection *Connection)
Definition: rpc_binding.h:196
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
@ PKT_HTTP
Definition: rpc_defs.h:208
BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len)
Definition: rpc_message.c:479
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:868
RpcPktHdr * RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size)
Definition: rpc_message.c:292
BOOL RPCRT4_default_is_authorized(RpcConnection *Connection)
Definition: rpc_message.c:1118
RPC_STATUS RPCRT4_ValidateCommonHeader(const RpcPktCommonHdr *hdr)
Definition: rpc_message.c:1251
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:1185
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:633
DWORD RPCRT4_GetHeaderSize(const RpcPktHdr *Header)
Definition: rpc_message.c:58
RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn)
Definition: rpc_message.c:1155
RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3)
Definition: rpc_message.c:587
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:678
RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1)
Definition: rpc_message.c:562
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:345
RpcPktHdr * RPCRT4_BuildHttpFlowControlHeader(BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid)
Definition: rpc_message.c:385
RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn)
Definition: rpc_message.c:1127
void RPCRT4_new_client(RpcConnection *conn)
Definition: rpc_server.c:626
static struct list protseqs
Definition: rpc_server.c:69
#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:95
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 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 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 RPC_STATUS rpcrt4_ncalrpc_inquire_client_pid(RpcConnection *conn, ULONG *pid)
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 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 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 RPC_STATUS authorize_request(RpcConnection_http *httpc, HINTERNET request)
#define DEFAULT_NCACN_HTTP_TIMEOUT
Definition: rpc_transport.c:54
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 const struct @593 auth_schemes[]
static RpcConnection * rpcrt4_conn_np_alloc(void)
Definition: rpc_transport.c:89
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 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:68
#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:755
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:330
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:747
_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 char *__cdecl strdup(_In_opt_z_ const char *_Src)
_Check_return_ _CRTIMP wchar_t *__cdecl wcsdup(_In_z_ const wchar_t *_Str)
_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:37
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
union _RPC_SECURITY_QOS_V2_W::@3414 u
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
PRTL_CRITICAL_SECTION_DEBUG DebugInfo
Definition: rtltypes.h:1450
RpcConnection common
RpcHttpAsyncData * async_data
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:84
RpcConnection common
Definition: rpc_transport.c:80
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:248
u_int16 count_lhs
Definition: epm_towers.h:81
u_int16 count_rhs
Definition: epm_towers.h:83
u_int16 count_lhs
Definition: epm_towers.h:73
u_int16 count_rhs
Definition: epm_towers.h:75
u_int32 ipv4addr
Definition: epm_towers.h:76
u_int16 count_lhs
Definition: epm_towers.h:65
u_int16 port
Definition: epm_towers.h:68
u_int16 count_rhs
Definition: epm_towers.h:67
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
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
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#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
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837
#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
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1138
struct _QualityOfService QOS
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:131
#define FD_READ
Definition: winsock.h:399
#define FD_WRITE
Definition: winsock.h:400
#define PF_INET
Definition: winsock.h:367
#define FD_CLOSE
Definition: winsock.h:404
#define PF_UNSPEC
Definition: winsock.h:365
#define SOCKET_ERROR
Definition: winsock.h:327
#define AF_INET6
Definition: winsock.h:363
#define SD_RECEIVE
Definition: winsock.h:48
#define FIONBIO
Definition: winsock.h:143
#define FD_ACCEPT
Definition: winsock.h:402
#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
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193