ReactOS 0.4.15-dev-8222-g9164419
session.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 Hans Leidekker for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "config.h"
20#include <stdarg.h>
21#include <stdlib.h>
22
23#ifdef HAVE_CORESERVICES_CORESERVICES_H
24#define GetCurrentThread MacGetCurrentThread
25#define LoadResource MacLoadResource
26#include <CoreServices/CoreServices.h>
27#undef GetCurrentThread
28#undef LoadResource
29#endif
30
31#include "windef.h"
32#include "winbase.h"
33#include "winsock2.h"
34#include "ws2ipdef.h"
35#include "ws2tcpip.h"
36#include "winhttp.h"
37#include "winreg.h"
38#include "wine/winternl.h"
39#define COBJMACROS
40#include "ole2.h"
41#include "dispex.h"
42#include "activscp.h"
43
44#include "wine/debug.h"
45#include "winhttp_private.h"
46
48
49#define DEFAULT_RESOLVE_TIMEOUT 0
50#define DEFAULT_CONNECT_TIMEOUT 20000
51#define DEFAULT_SEND_TIMEOUT 30000
52#define DEFAULT_RECEIVE_TIMEOUT 30000
53#define DEFAULT_RECEIVE_RESPONSE_TIMEOUT ~0u
54
55void send_callback( struct object_header *hdr, DWORD status, void *info, DWORD buflen )
56{
57 if (hdr->callback && (hdr->notify_mask & status))
58 {
59 TRACE("%p, 0x%08x, %p, %u\n", hdr, status, info, buflen);
60 hdr->callback( hdr->handle, hdr->context, status, info, buflen );
61 TRACE("returning from 0x%08x callback\n", status);
62 }
63}
64
65/***********************************************************************
66 * WinHttpCheckPlatform (winhttp.@)
67 */
69{
70 TRACE("\n");
71 return TRUE;
72}
73
74/***********************************************************************
75 * session_destroy (internal)
76 */
77static void session_destroy( struct object_header *hdr )
78{
79 struct session *session = (struct session *)hdr;
80
81 TRACE("%p\n", session);
82
85
86 session->cs.DebugInfo->Spare[0] = 0;
94}
95
97{
98 struct session *session = (struct session *)hdr;
99
100 switch (option)
101 {
103 {
104 if (!buffer || *buflen < sizeof(DWORD))
105 {
106 *buflen = sizeof(DWORD);
108 return FALSE;
109 }
110
111 *(DWORD *)buffer = hdr->redirect_policy;
112 *buflen = sizeof(DWORD);
113 return TRUE;
114 }
117 *buflen = sizeof(DWORD);
118 return TRUE;
119
122 *buflen = sizeof(DWORD);
123 return TRUE;
124
127 *buflen = sizeof(DWORD);
128 return TRUE;
129
132 *buflen = sizeof(DWORD);
133 return TRUE;
134
137 *buflen = sizeof(DWORD);
138 return TRUE;
139
140 default:
141 FIXME("unimplemented option %u\n", option);
143 return FALSE;
144 }
145}
146
148{
149 struct session *session = (struct session *)hdr;
150
151 switch (option)
152 {
154 {
156
157 FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
158 return TRUE;
159 }
161 {
163
164 if (buflen != sizeof(policy))
165 {
167 return FALSE;
168 }
169
170 policy = *(DWORD *)buffer;
171 TRACE("0x%x\n", policy);
172 hdr->redirect_policy = policy;
173 return TRUE;
174 }
176 {
177 if (buflen != sizeof(session->secure_protocols))
178 {
180 return FALSE;
181 }
185 TRACE("0x%x\n", session->secure_protocols);
186 return TRUE;
187 }
190 return FALSE;
191
194 return TRUE;
195
198 return TRUE;
199
202 return TRUE;
203
206 return TRUE;
207
210 return TRUE;
211
214 return TRUE;
215
217 TRACE("WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT: %p\n", *(HANDLE *)buffer);
219 return TRUE;
220
222 FIXME("WINHTTP_OPTION_MAX_CONNS_PER_SERVER: %d\n", *(DWORD *)buffer);
223 return TRUE;
224
226 FIXME("WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", *(DWORD *)buffer);
227 return TRUE;
228
229 default:
230 FIXME("unimplemented option %u\n", option);
232 return FALSE;
233 }
234}
235
236static const struct object_vtbl session_vtbl =
237{
241};
242
243#ifdef __REACTOS__
244void winsock_init(void);
245#endif
246
247/***********************************************************************
248 * WinHttpOpen (winhttp.@)
249 */
251{
252 struct session *session;
254
255 TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
256
257 if (!(session = heap_alloc_zero( sizeof(struct session) ))) return NULL;
258
260 session->hdr.vtbl = &session_vtbl;
261 session->hdr.flags = flags;
262 session->hdr.refs = 1;
264 list_init( &session->hdr.children );
272 session->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": session.cs");
273
274 if (agent && !(session->agent = strdupW( agent ))) goto end;
276 {
278
280 session->access = info.dwAccessType;
281 if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
282 {
283 GlobalFree( (LPWSTR)info.lpszProxy );
284 GlobalFree( (LPWSTR)info.lpszProxyBypass );
285 goto end;
286 }
287 if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
288 {
289 GlobalFree( (LPWSTR)info.lpszProxy );
290 GlobalFree( (LPWSTR)info.lpszProxyBypass );
291 goto end;
292 }
293 }
295 {
297 if (proxy && !(session->proxy_server = strdupW( proxy ))) goto end;
298 if (bypass && !(session->proxy_bypass = strdupW( bypass ))) goto end;
299 }
300
301 if (!(handle = alloc_handle( &session->hdr ))) goto end;
302 session->hdr.handle = handle;
303
304#ifdef __REACTOS__
305 winsock_init();
306#endif
307
308end:
310 TRACE("returning %p\n", handle);
312 return handle;
313}
314
315/***********************************************************************
316 * connect_destroy (internal)
317 */
318static void connect_destroy( struct object_header *hdr )
319{
320 struct connect *connect = (struct connect *)hdr;
321
322 TRACE("%p\n", connect);
323
325
331}
332
334{
335 struct connect *connect = (struct connect *)hdr;
336
337 switch (option)
338 {
340 {
341 if (!buffer || *buflen < sizeof(HINTERNET))
342 {
343 *buflen = sizeof(HINTERNET);
345 return FALSE;
346 }
347
349 *buflen = sizeof(HINTERNET);
350 return TRUE;
351 }
353 *(DWORD *)buffer = connect->session->resolve_timeout;
354 *buflen = sizeof(DWORD);
355 return TRUE;
356
358 *(DWORD *)buffer = connect->session->connect_timeout;
359 *buflen = sizeof(DWORD);
360 return TRUE;
361
363 *(DWORD *)buffer = connect->session->send_timeout;
364 *buflen = sizeof(DWORD);
365 return TRUE;
366
368 *(DWORD *)buffer = connect->session->receive_timeout;
369 *buflen = sizeof(DWORD);
370 return TRUE;
371
373 *(DWORD *)buffer = connect->session->receive_response_timeout;
374 *buflen = sizeof(DWORD);
375 return TRUE;
376
377 default:
378 FIXME("unimplemented option %u\n", option);
380 return FALSE;
381 }
382}
383
384static const struct object_vtbl connect_vtbl =
385{
388 NULL
389};
390
392{
393 static const WCHAR localW[] = { '<','l','o','c','a','l','>',0 };
394 BOOL ret = FALSE;
395
396 if (!strcmpiW( domain, localW ) && !strchrW( server, '.' ))
397 ret = TRUE;
398 else if (*domain == '*')
399 {
400 if (domain[1] == '.')
401 {
402 LPCWSTR dot;
403
404 /* For a hostname to match a wildcard, the last domain must match
405 * the wildcard exactly. E.g. if the wildcard is *.a.b, and the
406 * hostname is www.foo.a.b, it matches, but a.b does not.
407 */
408 dot = strchrW( server, '.' );
409 if (dot)
410 {
411 int len = strlenW( dot + 1 );
412
413 if (len > strlenW( domain + 2 ))
414 {
415 LPCWSTR ptr;
416
417 /* The server's domain is longer than the wildcard, so it
418 * could be a subdomain. Compare the last portion of the
419 * server's domain.
420 */
421 ptr = dot + len + 1 - strlenW( domain + 2 );
422 if (!strcmpiW( ptr, domain + 2 ))
423 {
424 /* This is only a match if the preceding character is
425 * a '.', i.e. that it is a matching domain. E.g.
426 * if domain is '*.b.c' and server is 'www.ab.c' they
427 * do not match.
428 */
429 ret = *(ptr - 1) == '.';
430 }
431 }
432 else
433 ret = !strcmpiW( dot + 1, domain + 2 );
434 }
435 }
436 }
437 else
438 ret = !strcmpiW( server, domain );
439 return ret;
440}
441
442/* Matches INTERNET_MAX_HOST_NAME_LENGTH in wininet.h, also RFC 1035 */
443#define MAX_HOST_NAME_LENGTH 256
444
446{
447 LPCWSTR ptr;
448 BOOL ret = FALSE;
449
450 if (!session->proxy_bypass) return FALSE;
452 do {
453 LPCWSTR tmp = ptr;
454
455 ptr = strchrW( ptr, ';' );
456 if (!ptr)
457 ptr = strchrW( tmp, ' ' );
458 if (ptr)
459 {
460 if (ptr - tmp < MAX_HOST_NAME_LENGTH)
461 {
463
464 memcpy( domain, tmp, (ptr - tmp) * sizeof(WCHAR) );
465 domain[ptr - tmp] = 0;
467 }
468 ptr += 1;
469 }
470 else if (*tmp)
471 ret = domain_matches( server, tmp );
472 } while (ptr && !ret);
473 return ret;
474}
475
477{
478 struct session *session = connect->session;
479 BOOL ret = TRUE;
480
482 {
483 LPCWSTR colon;
484
485 if ((colon = strchrW( session->proxy_server, ':' )))
486 {
488 session->proxy_server, colon - session->proxy_server - 1 ))
489 {
493 (colon - session->proxy_server + 1) * sizeof(WCHAR) )))
494 {
495 ret = FALSE;
496 goto end;
497 }
499 (colon - session->proxy_server) * sizeof(WCHAR) );
500 connect->servername[colon - session->proxy_server] = 0;
501 if (*(colon + 1))
502 connect->serverport = atoiW( colon + 1 );
503 else
505 }
506 }
507 else
508 {
511 {
515 {
516 ret = FALSE;
517 goto end;
518 }
520 }
521 }
522 }
523 else if (server)
524 {
527 if (!(connect->servername = strdupW( server )))
528 {
529 ret = FALSE;
530 goto end;
531 }
533 }
534end:
535 return ret;
536}
537
538/***********************************************************************
539 * WinHttpConnect (winhttp.@)
540 */
542{
543 struct connect *connect;
544 struct session *session;
545 HINTERNET hconnect = NULL;
546
547 TRACE("%p, %s, %u, %x\n", hsession, debugstr_w(server), port, reserved);
548
549 if (!server)
550 {
552 return NULL;
553 }
554 if (!(session = (struct session *)grab_object( hsession )))
555 {
557 return NULL;
558 }
560 {
563 return NULL;
564 }
565 if (!(connect = heap_alloc_zero( sizeof(struct connect) )))
566 {
568 return NULL;
569 }
571 connect->hdr.vtbl = &connect_vtbl;
572 connect->hdr.refs = 1;
573 connect->hdr.flags = session->hdr.flags;
574 connect->hdr.callback = session->hdr.callback;
575 connect->hdr.notify_mask = session->hdr.notify_mask;
576 connect->hdr.context = session->hdr.context;
577 connect->hdr.redirect_policy = session->hdr.redirect_policy;
578 list_init( &connect->hdr.children );
579
582 list_add_head( &session->hdr.children, &connect->hdr.entry );
583
584 if (!(connect->hostname = strdupW( server ))) goto end;
587
588 if (!(hconnect = alloc_handle( &connect->hdr ))) goto end;
589 connect->hdr.handle = hconnect;
590
591 send_callback( &session->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hconnect, sizeof(hconnect) );
592
593end:
596 TRACE("returning %p\n", hconnect);
597 if (hconnect) SetLastError( ERROR_SUCCESS );
598 return hconnect;
599}
600
601/***********************************************************************
602 * request_destroy (internal)
603 */
604static void request_destroy( struct object_header *hdr )
605{
606 struct request *request = (struct request *)hdr;
607 unsigned int i, j;
608
609 TRACE("%p\n", request);
610
611#ifdef __REACTOS__
612 if (request->task_thread)
613#else
615#endif
616 {
617 /* Signal to the task proc to quit. It will call this again when it does. */
618#ifdef __REACTOS__
619 HANDLE thread = request->task_thread;
620 request->task_thread = 0;
623#else
626#endif
627 return;
628 }
630
634
637
643 for (i = 0; i < request->num_headers; i++)
644 {
645 heap_free( request->headers[i].field );
646 heap_free( request->headers[i].value );
647 }
649 for (i = 0; i < TARGET_MAX; i++)
650 {
651 for (j = 0; j < SCHEME_MAX; j++)
652 {
653 heap_free( request->creds[i][j].username );
654 heap_free( request->creds[i][j].password );
655 }
656 }
658}
659
660static void str_to_buffer( WCHAR *buffer, const WCHAR *str, LPDWORD buflen )
661{
662 int len = 0;
663 if (str) len = strlenW( str );
664 if (buffer && *buflen > len)
665 {
666 if (str) memcpy( buffer, str, len * sizeof(WCHAR) );
667 buffer[len] = 0;
668 }
669 *buflen = len * sizeof(WCHAR);
670}
671
673{
674 WCHAR *ret;
676
678 if ((ret = LocalAlloc( 0, size * sizeof(WCHAR) )))
680
681 return ret;
682}
683
684static BOOL copy_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage )
685{
686 switch (addr->sa_family)
687 {
688 case AF_INET:
689 {
690 struct sockaddr_in *addr_in = (struct sockaddr_in *)addr_storage;
691
692 memcpy( addr_in, addr, sizeof(*addr_in) );
693 memset( addr_in + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in) );
694 return TRUE;
695 }
696 case AF_INET6:
697 {
698 struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr_storage;
699
700 memcpy( addr_in6, addr, sizeof(*addr_in6) );
701 memset( addr_in6 + 1, 0, sizeof(*addr_storage) - sizeof(*addr_in6) );
702 return TRUE;
703 }
704 default:
705 ERR("unhandled family %u\n", addr->sa_family);
706 return FALSE;
707 }
708}
709
711{
712 struct request *request = (struct request *)hdr;
713
714 switch (option)
715 {
717 {
718 DWORD flags;
719 int bits;
720
721 if (!buffer || *buflen < sizeof(flags))
722 {
723 *buflen = sizeof(flags);
725 return FALSE;
726 }
727
729 if (request->netconn)
730 {
732 if (bits >= 128)
734 else if (bits >= 56)
736 else
738 }
739 *(DWORD *)buffer = flags;
740 *buflen = sizeof(flags);
741 return TRUE;
742 }
744 {
745 const CERT_CONTEXT *cert;
746
747 if (!buffer || *buflen < sizeof(cert))
748 {
749 *buflen = sizeof(cert);
751 return FALSE;
752 }
753
756 *buflen = sizeof(cert);
757 return TRUE;
758 }
760 {
762 const CRYPT_OID_INFO *oidInfo;
764
765 FIXME("partial stub\n");
766
767 if (!buffer || *buflen < sizeof(*ci))
768 {
769 *buflen = sizeof(*ci);
771 return FALSE;
772 }
773 if (!cert) return FALSE;
774
775 ci->ftExpiry = cert->pCertInfo->NotAfter;
776 ci->ftStart = cert->pCertInfo->NotBefore;
777 ci->lpszSubjectInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Subject );
778 ci->lpszIssuerInfo = blob_to_str( cert->dwCertEncodingType, &cert->pCertInfo->Issuer );
780 oidInfo = CryptFindOIDInfo( CRYPT_OID_INFO_OID_KEY, cert->pCertInfo->SignatureAlgorithm.pszObjId, 0 );
781 if (oidInfo)
782 ci->lpszSignatureAlgName = (LPWSTR)oidInfo->pwszName;
783 else
787
788 *buflen = sizeof(*ci);
789 return TRUE;
790 }
792 {
793 if (!buffer || *buflen < sizeof(DWORD))
794 {
795 *buflen = sizeof(DWORD);
797 return FALSE;
798 }
799
801 *buflen = sizeof(DWORD);
802 return TRUE;
803 }
805 {
806 WINHTTP_CONNECTION_INFO *info = buffer;
807 struct sockaddr local;
808 socklen_t len = sizeof(local);
809 const struct sockaddr *remote = (const struct sockaddr *)&request->connect->sockaddr;
810
811 if (!buffer || *buflen < sizeof(*info))
812 {
813 *buflen = sizeof(*info);
815 return FALSE;
816 }
817 if (!request->netconn)
818 {
820 return FALSE;
821 }
822 if (getsockname( request->netconn->socket, &local, &len )) return FALSE;
823 if (!copy_sockaddr( &local, &info->LocalAddress )) return FALSE;
824 if (!copy_sockaddr( remote, &info->RemoteAddress )) return FALSE;
825 info->cbSize = sizeof(*info);
826 return TRUE;
827 }
830 *buflen = sizeof(DWORD);
831 return TRUE;
832
835 *buflen = sizeof(DWORD);
836 return TRUE;
837
840 *buflen = sizeof(DWORD);
841 return TRUE;
842
845 *buflen = sizeof(DWORD);
846 return TRUE;
847
850 *buflen = sizeof(DWORD);
851 return TRUE;
852
854 str_to_buffer( buffer, request->connect->username, buflen );
855 return TRUE;
856
858 str_to_buffer( buffer, request->connect->password, buflen );
859 return TRUE;
860
862 str_to_buffer( buffer, request->connect->session->proxy_username, buflen );
863 return TRUE;
864
866 str_to_buffer( buffer, request->connect->session->proxy_password, buflen );
867 return TRUE;
868
869 default:
870 FIXME("unimplemented option %u\n", option);
872 return FALSE;
873 }
874}
875
877{
878 WCHAR *ret;
879 if ((ret = heap_alloc( (buflen + 1) * sizeof(WCHAR))))
880 {
881 memcpy( ret, buffer, buflen * sizeof(WCHAR) );
882 ret[buflen] = 0;
883 return ret;
884 }
886 return NULL;
887}
888
890{
891 struct request *request = (struct request *)hdr;
892
893 switch (option)
894 {
896 {
898
899 FIXME("%u %s %s\n", pi->dwAccessType, debugstr_w(pi->lpszProxy), debugstr_w(pi->lpszProxyBypass));
900 return TRUE;
901 }
903 {
905
906 if (buflen != sizeof(DWORD))
907 {
909 return FALSE;
910 }
911
912 disable = *(DWORD *)buffer;
913 TRACE("0x%x\n", disable);
914 hdr->disable_flags |= disable;
915 return TRUE;
916 }
918 {
920
921 if (buflen != sizeof(DWORD))
922 {
924 return FALSE;
925 }
926
927 policy = *(DWORD *)buffer;
928 TRACE("0x%x\n", policy);
929 hdr->logon_policy = policy;
930 return TRUE;
931 }
933 {
935
936 if (buflen != sizeof(DWORD))
937 {
939 return FALSE;
940 }
941
942 policy = *(DWORD *)buffer;
943 TRACE("0x%x\n", policy);
944 hdr->redirect_policy = policy;
945 return TRUE;
946 }
948 {
949 DWORD flags;
954
955 if (buflen < sizeof(DWORD))
956 {
958 return FALSE;
959 }
960 flags = *(DWORD *)buffer;
961 TRACE("0x%x\n", flags);
962 if (flags && (flags & ~accepted))
963 {
965 return FALSE;
966 }
968 return TRUE;
969 }
972 return TRUE;
973
976 return TRUE;
977
980 return TRUE;
981
984 return TRUE;
985
988 return TRUE;
989
991 {
992 struct connect *connect = request->connect;
993
995 if (!(connect->username = buffer_to_str( buffer, buflen ))) return FALSE;
996 return TRUE;
997 }
999 {
1000 struct connect *connect = request->connect;
1001
1003 if (!(connect->password = buffer_to_str( buffer, buflen ))) return FALSE;
1004 return TRUE;
1005 }
1007 {
1008 struct session *session = request->connect->session;
1009
1011 if (!(session->proxy_username = buffer_to_str( buffer, buflen ))) return FALSE;
1012 return TRUE;
1013 }
1015 {
1016 struct session *session = request->connect->session;
1017
1019 if (!(session->proxy_password = buffer_to_str( buffer, buflen ))) return FALSE;
1020 return TRUE;
1021 }
1023 {
1024 const CERT_CONTEXT *cert;
1025
1026 if (!(hdr->flags & WINHTTP_FLAG_SECURE))
1027 {
1029 return FALSE;
1030 }
1031 if (!buffer)
1032 {
1035 }
1036 else if (buflen >= sizeof(cert))
1037 {
1041 }
1042 else
1043 {
1045 return FALSE;
1046 }
1047
1049 {
1052 }
1053
1054 return TRUE;
1055 }
1057 if(buflen == sizeof( DWORD ) && *(DWORD *)buffer == WINHTTP_ENABLE_SSL_REVOCATION)
1058 {
1061 return TRUE;
1062 }
1063 else
1064 {
1066 return FALSE;
1067 }
1068
1070 FIXME("WINHTTP_OPTION_CONNECT_RETRIES\n");
1071 return TRUE;
1072
1073 default:
1074 FIXME("unimplemented option %u\n", option);
1076 return FALSE;
1077 }
1078}
1079
1080static const struct object_vtbl request_vtbl =
1081{
1085};
1086
1088{
1089 static const WCHAR acceptW[] = {'A','c','c','e','p','t',0};
1091
1092 if (!types) return TRUE;
1093 while (*types)
1094 {
1095 if (!process_header( request, acceptW, *types, flags, TRUE )) return FALSE;
1096 types++;
1097 }
1098 return TRUE;
1099}
1100
1101static WCHAR *get_request_path( const WCHAR *object )
1102{
1103 int len = object ? strlenW(object) : 0;
1104 WCHAR *p, *ret;
1105
1106 if (!object || object[0] != '/') len++;
1107 if (!(p = ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
1108 if (!object || object[0] != '/') *p++ = '/';
1109 if (object) strcpyW( p, object );
1110 ret[len] = 0;
1111 return ret;
1112}
1113
1114/***********************************************************************
1115 * WinHttpOpenRequest (winhttp.@)
1116 */
1118 LPCWSTR referrer, LPCWSTR *types, DWORD flags )
1119{
1120 struct request *request;
1121 struct connect *connect;
1122 HINTERNET hrequest = NULL;
1123
1124 TRACE("%p, %s, %s, %s, %s, %p, 0x%08x\n", hconnect, debugstr_w(verb), debugstr_w(object),
1125 debugstr_w(version), debugstr_w(referrer), types, flags);
1126
1127 if (types && TRACE_ON(winhttp))
1128 {
1129 const WCHAR **iter;
1130 TRACE("accept types:\n");
1131 for (iter = types; *iter; iter++) TRACE(" %s\n", debugstr_w(*iter));
1132 }
1133
1134 if (!(connect = (struct connect *)grab_object( hconnect )))
1135 {
1137 return NULL;
1138 }
1140 {
1143 return NULL;
1144 }
1145 if (!(request = heap_alloc_zero( sizeof(struct request) )))
1146 {
1148 return NULL;
1149 }
1151 request->hdr.vtbl = &request_vtbl;
1152 request->hdr.refs = 1;
1153 request->hdr.flags = flags;
1154 request->hdr.callback = connect->hdr.callback;
1155 request->hdr.notify_mask = connect->hdr.notify_mask;
1156 request->hdr.context = connect->hdr.context;
1157 request->hdr.redirect_policy = connect->hdr.redirect_policy;
1158 list_init( &request->hdr.children );
1160
1163 list_add_head( &connect->hdr.children, &request->hdr.entry );
1164
1165 request->resolve_timeout = connect->session->resolve_timeout;
1166 request->connect_timeout = connect->session->connect_timeout;
1167 request->send_timeout = connect->session->send_timeout;
1168 request->receive_timeout = connect->session->receive_timeout;
1169 request->receive_response_timeout = connect->session->receive_response_timeout;
1170
1171 if (!verb || !verb[0]) verb = getW;
1172 if (!(request->verb = strdupW( verb ))) goto end;
1173 if (!(request->path = get_request_path( object ))) goto end;
1174
1175 if (!version || !version[0]) version = http1_1;
1176 if (!(request->version = strdupW( version ))) goto end;
1177 if (!(add_accept_types_header( request, types ))) goto end;
1178
1179 if (!(hrequest = alloc_handle( &request->hdr ))) goto end;
1180 request->hdr.handle = hrequest;
1181
1182 send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED, &hrequest, sizeof(hrequest) );
1183
1184end:
1187 TRACE("returning %p\n", hrequest);
1188 if (hrequest) SetLastError( ERROR_SUCCESS );
1189 return hrequest;
1190}
1191
1192/***********************************************************************
1193 * WinHttpCloseHandle (winhttp.@)
1194 */
1196{
1197 struct object_header *hdr;
1198
1199 TRACE("%p\n", handle);
1200
1201 if (!(hdr = grab_object( handle )))
1202 {
1204 return FALSE;
1205 }
1209 return TRUE;
1210}
1211
1212static BOOL query_option( struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen )
1213{
1214 BOOL ret = FALSE;
1215
1216 if (!buflen)
1217 {
1219 return FALSE;
1220 }
1221
1222 switch (option)
1223 {
1225 {
1226 if (!buffer || *buflen < sizeof(DWORD_PTR))
1227 {
1228 *buflen = sizeof(DWORD_PTR);
1230 return FALSE;
1231 }
1232
1233 *(DWORD_PTR *)buffer = hdr->context;
1234 *buflen = sizeof(DWORD_PTR);
1235 return TRUE;
1236 }
1237 default:
1238 if (hdr->vtbl->query_option) ret = hdr->vtbl->query_option( hdr, option, buffer, buflen );
1239 else
1240 {
1241 FIXME("unimplemented option %u\n", option);
1243 return FALSE;
1244 }
1245 break;
1246 }
1247 return ret;
1248}
1249
1250/***********************************************************************
1251 * WinHttpQueryOption (winhttp.@)
1252 */
1254{
1255 BOOL ret = FALSE;
1256 struct object_header *hdr;
1257
1258 TRACE("%p, %u, %p, %p\n", handle, option, buffer, buflen);
1259
1260 if (!(hdr = grab_object( handle )))
1261 {
1263 return FALSE;
1264 }
1265
1266 ret = query_option( hdr, option, buffer, buflen );
1267
1270 return ret;
1271}
1272
1273static BOOL set_option( struct object_header *hdr, DWORD option, void *buffer, DWORD buflen )
1274{
1275 BOOL ret = TRUE;
1276
1277 if (!buffer && buflen)
1278 {
1280 return FALSE;
1281 }
1282
1283 switch (option)
1284 {
1286 {
1287 if (buflen != sizeof(DWORD_PTR))
1288 {
1290 return FALSE;
1291 }
1292
1293 hdr->context = *(DWORD_PTR *)buffer;
1294 return TRUE;
1295 }
1296 default:
1297 if (hdr->vtbl->set_option) ret = hdr->vtbl->set_option( hdr, option, buffer, buflen );
1298 else
1299 {
1300 FIXME("unimplemented option %u\n", option);
1302 return FALSE;
1303 }
1304 break;
1305 }
1306 return ret;
1307}
1308
1309/***********************************************************************
1310 * WinHttpSetOption (winhttp.@)
1311 */
1313{
1314 BOOL ret = FALSE;
1315 struct object_header *hdr;
1316
1317 TRACE("%p, %u, %p, %u\n", handle, option, buffer, buflen);
1318
1319 if (!(hdr = grab_object( handle )))
1320 {
1322 return FALSE;
1323 }
1324
1325 ret = set_option( hdr, option, buffer, buflen );
1326
1329 return ret;
1330}
1331
1332static char *get_computer_name( COMPUTER_NAME_FORMAT format )
1333{
1334 char *ret;
1335 DWORD size = 0;
1336
1338 if (GetLastError() != ERROR_MORE_DATA) return NULL;
1339 if (!(ret = heap_alloc( size ))) return NULL;
1340 if (!GetComputerNameExA( format, ret, &size ))
1341 {
1342 heap_free( ret );
1343 return NULL;
1344 }
1345 return ret;
1346}
1347
1348static BOOL is_domain_suffix( const char *domain, const char *suffix )
1349{
1350 int len_domain = strlen( domain ), len_suffix = strlen( suffix );
1351
1352 if (len_suffix > len_domain) return FALSE;
1353 if (!_strnicmp( domain + len_domain - len_suffix, suffix, -1 )) return TRUE;
1354 return FALSE;
1355}
1356
1357static int reverse_lookup( const struct addrinfo *ai, char *hostname, size_t len )
1358{
1359 return getnameinfo( ai->ai_addr, ai->ai_addrlen, hostname, len, NULL, 0, 0 );
1360}
1361
1362static WCHAR *build_wpad_url( const char *hostname, const struct addrinfo *ai )
1363{
1364 static const WCHAR httpW[] = {'h','t','t','p',':','/','/',0};
1365 static const WCHAR wpadW[] = {'/','w','p','a','d','.','d','a','t',0};
1366 char name[NI_MAXHOST];
1367 WCHAR *ret, *p;
1368 int len;
1369
1370 while (ai && ai->ai_family != AF_INET && ai->ai_family != AF_INET6) ai = ai->ai_next;
1371 if (!ai) return NULL;
1372
1373 if (!reverse_lookup( ai, name, sizeof(name) )) hostname = name;
1374
1375 len = strlenW( httpW ) + strlen( hostname ) + strlenW( wpadW );
1376 if (!(ret = p = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
1377 strcpyW( p, httpW );
1378 p += strlenW( httpW );
1379 while (*hostname) { *p++ = *hostname++; }
1380 strcpyW( p, wpadW );
1381 return ret;
1382}
1383
1385{
1386#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1387 CFDictionaryRef settings = CFNetworkCopySystemProxySettings();
1388 const void *ref;
1389 BOOL ret = FALSE;
1390
1391 if (!settings) return FALSE;
1392
1393 if (!(ref = CFDictionaryGetValue( settings, kCFNetworkProxiesProxyAutoConfigURLString )))
1394 {
1395 CFRelease( settings );
1396 return FALSE;
1397 }
1398 if (CFStringGetCString( ref, buf, buflen, kCFStringEncodingASCII ))
1399 {
1400 TRACE( "returning %s\n", debugstr_a(buf) );
1401 ret = TRUE;
1402 }
1403 CFRelease( settings );
1404 return ret;
1405#else
1406 static BOOL first = TRUE;
1407 if (first)
1408 {
1409 FIXME( "no support on this platform\n" );
1410 first = FALSE;
1411 }
1412 else
1413 TRACE( "no support on this platform\n" );
1414 return FALSE;
1415#endif
1416}
1417
1418#define INTERNET_MAX_URL_LENGTH 2084
1419
1420/***********************************************************************
1421 * WinHttpDetectAutoProxyConfigUrl (winhttp.@)
1422 */
1424{
1425 BOOL ret = FALSE;
1426 char system_url[INTERNET_MAX_URL_LENGTH + 1];
1427
1428 TRACE("0x%08x, %p\n", flags, url);
1429
1430 if (!flags || !url)
1431 {
1433 return FALSE;
1434 }
1435 if (get_system_proxy_autoconfig_url( system_url, sizeof(system_url) ))
1436 {
1437 WCHAR *urlW;
1438
1439 if (!(urlW = strdupAW( system_url ))) return FALSE;
1440 *url = urlW;
1442 return TRUE;
1443 }
1445 {
1446 static int fixme_shown;
1447 if (!fixme_shown++) FIXME("discovery via DHCP not supported\n");
1448 }
1450 {
1451 char *fqdn, *domain, *p;
1452
1453 if (!(fqdn = get_computer_name( ComputerNamePhysicalDnsFullyQualified ))) return FALSE;
1454 if (!(domain = get_computer_name( ComputerNamePhysicalDnsDomain )))
1455 {
1456 heap_free( fqdn );
1457 return FALSE;
1458 }
1459 p = fqdn;
1460 while ((p = strchr( p, '.' )) && is_domain_suffix( p + 1, domain ))
1461 {
1462 struct addrinfo *ai;
1463 char *name;
1464 int res;
1465
1466 if (!(name = heap_alloc( sizeof("wpad") + strlen(p) )))
1467 {
1468 heap_free( fqdn );
1469 heap_free( domain );
1470 return FALSE;
1471 }
1472 strcpy( name, "wpad" );
1473 strcat( name, p );
1474 res = getaddrinfo( name, NULL, NULL, &ai );
1475 if (!res)
1476 {
1477 *url = build_wpad_url( name, ai );
1478 freeaddrinfo( ai );
1479 if (*url)
1480 {
1481 TRACE("returning %s\n", debugstr_w(*url));
1482 heap_free( name );
1483 ret = TRUE;
1484 break;
1485 }
1486 }
1487 heap_free( name );
1488 p++;
1489 }
1490 heap_free( domain );
1491 heap_free( fqdn );
1492 }
1493 if (!ret)
1494 {
1496 *url = NULL;
1497 }
1499 return ret;
1500}
1501
1502static const WCHAR Connections[] = {
1503 'S','o','f','t','w','a','r','e','\\',
1504 'M','i','c','r','o','s','o','f','t','\\',
1505 'W','i','n','d','o','w','s','\\',
1506 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1507 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s','\\',
1508 'C','o','n','n','e','c','t','i','o','n','s',0 };
1509static const WCHAR WinHttpSettings[] = {
1510 'W','i','n','H','t','t','p','S','e','t','t','i','n','g','s',0 };
1511static const DWORD WINHTTP_SETTINGS_MAGIC = 0x18;
1512static const DWORD WININET_SETTINGS_MAGIC = 0x46;
1513static const DWORD PROXY_TYPE_DIRECT = 1;
1514static const DWORD PROXY_TYPE_PROXY = 2;
1517
1519{
1521 DWORD unknown; /* always zero? */
1522 DWORD flags; /* one or more of PROXY_* */
1523};
1524
1525static inline void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
1526{
1527 const BYTE *begin;
1528
1529 for (begin = src; src - begin < len; src++, dst++)
1530 *dst = *src;
1531 *dst = 0;
1532}
1533
1534/***********************************************************************
1535 * WinHttpGetDefaultProxyConfiguration (winhttp.@)
1536 */
1538{
1539 LONG l;
1540 HKEY key;
1541 BOOL got_from_reg = FALSE, direct = TRUE;
1542 char *envproxy;
1543
1544 TRACE("%p\n", info);
1545
1547 if (!l)
1548 {
1549 DWORD type, size = 0;
1550
1552 if (!l && type == REG_BINARY &&
1553 size >= sizeof(struct connection_settings_header) + 2 * sizeof(DWORD))
1554 {
1555 BYTE *buf = heap_alloc( size );
1556
1557 if (buf)
1558 {
1561 DWORD *len = (DWORD *)(hdr + 1);
1562
1564 &size );
1565 if (!l && hdr->magic == WINHTTP_SETTINGS_MAGIC &&
1566 hdr->unknown == 0)
1567 {
1568 if (hdr->flags & PROXY_TYPE_PROXY)
1569 {
1570 BOOL sane = FALSE;
1571 LPWSTR proxy = NULL;
1572 LPWSTR proxy_bypass = NULL;
1573
1574 /* Sanity-check length of proxy string */
1575 if ((BYTE *)len - buf + *len <= size)
1576 {
1577 sane = TRUE;
1578 proxy = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1579 if (proxy)
1580 copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy );
1581 len = (DWORD *)((BYTE *)(len + 1) + *len);
1582 }
1583 if (sane)
1584 {
1585 /* Sanity-check length of proxy bypass string */
1586 if ((BYTE *)len - buf + *len <= size)
1587 {
1588 proxy_bypass = GlobalAlloc( 0, (*len + 1) * sizeof(WCHAR) );
1589 if (proxy_bypass)
1590 copy_char_to_wchar_sz( (BYTE *)(len + 1), *len, proxy_bypass );
1591 }
1592 else
1593 {
1594 sane = FALSE;
1595 GlobalFree( proxy );
1596 proxy = NULL;
1597 }
1598 }
1599 info->lpszProxy = proxy;
1600 info->lpszProxyBypass = proxy_bypass;
1601 if (sane)
1602 {
1603 got_from_reg = TRUE;
1604 direct = FALSE;
1605 info->dwAccessType =
1607 TRACE("http proxy (from registry) = %s, bypass = %s\n",
1608 debugstr_w(info->lpszProxy),
1609 debugstr_w(info->lpszProxyBypass));
1610 }
1611 }
1612 }
1613 heap_free( buf );
1614 }
1615 }
1616 RegCloseKey( key );
1617 }
1618 if (!got_from_reg && (envproxy = getenv( "http_proxy" )))
1619 {
1620 char *colon, *http_proxy = NULL;
1621
1622 if (!(colon = strchr( envproxy, ':' ))) http_proxy = envproxy;
1623 else
1624 {
1625 if (*(colon + 1) == '/' && *(colon + 2) == '/')
1626 {
1627 /* It's a scheme, check that it's http */
1628 if (!strncmp( envproxy, "http://", 7 )) http_proxy = envproxy + 7;
1629 else WARN("unsupported scheme in $http_proxy: %s\n", envproxy);
1630 }
1631 else http_proxy = envproxy;
1632 }
1633
1634 if (http_proxy && http_proxy[0])
1635 {
1636 WCHAR *http_proxyW;
1637 int len;
1638
1639 len = MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, NULL, 0 );
1640 if ((http_proxyW = GlobalAlloc( 0, len * sizeof(WCHAR))))
1641 {
1642 MultiByteToWideChar( CP_UNIXCP, 0, http_proxy, -1, http_proxyW, len );
1643 direct = FALSE;
1644 info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1645 info->lpszProxy = http_proxyW;
1646 info->lpszProxyBypass = NULL;
1647 TRACE("http proxy (from environment) = %s\n", debugstr_w(info->lpszProxy));
1648 }
1649 }
1650 }
1651 if (direct)
1652 {
1653 info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1654 info->lpszProxy = NULL;
1655 info->lpszProxyBypass = NULL;
1656 }
1658 return TRUE;
1659}
1660
1661/***********************************************************************
1662 * WinHttpGetIEProxyConfigForCurrentUser (winhttp.@)
1663 */
1665{
1666 static const WCHAR settingsW[] =
1667 {'D','e','f','a','u','l','t','C','o','n','n','e','c','t','i','o','n','S','e','t','t','i','n','g','s',0};
1668 HKEY hkey = NULL;
1670 DWORD type, offset, len, size = 0;
1671 BOOL ret = FALSE;
1672
1673 TRACE("%p\n", config);
1674
1675 if (!config)
1676 {
1678 return FALSE;
1679 }
1680 memset( config, 0, sizeof(*config) );
1681 config->fAutoDetect = TRUE;
1682
1684 RegQueryValueExW( hkey, settingsW, NULL, &type, NULL, &size ) ||
1685 type != REG_BINARY || size < sizeof(struct connection_settings_header))
1686 {
1687 ret = TRUE;
1688 goto done;
1689 }
1690 if (!(hdr = heap_alloc( size ))) goto done;
1691 if (RegQueryValueExW( hkey, settingsW, NULL, &type, (BYTE *)hdr, &size ) ||
1692 hdr->magic != WININET_SETTINGS_MAGIC)
1693 {
1694 ret = TRUE;
1695 goto done;
1696 }
1697
1698 config->fAutoDetect = (hdr->flags & PROXY_AUTODETECT_SETTINGS) != 0;
1699 offset = sizeof(*hdr);
1700 if (offset + sizeof(DWORD) > size) goto done;
1701 len = *(DWORD *)((char *)hdr + offset);
1702 offset += sizeof(DWORD);
1703 if (len && hdr->flags & PROXY_TYPE_PROXY)
1704 {
1705 if (!(config->lpszProxy = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1706 copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxy );
1707 }
1708 offset += len;
1709 if (offset + sizeof(DWORD) > size) goto done;
1710 len = *(DWORD *)((char *)hdr + offset);
1711 offset += sizeof(DWORD);
1712 if (len && (hdr->flags & PROXY_TYPE_PROXY))
1713 {
1714 if (!(config->lpszProxyBypass = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1715 copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszProxyBypass );
1716 }
1717 offset += len;
1718 if (offset + sizeof(DWORD) > size) goto done;
1719 len = *(DWORD *)((char *)hdr + offset);
1720 offset += sizeof(DWORD);
1721 if (len && (hdr->flags & PROXY_USE_PAC_SCRIPT))
1722 {
1723 if (!(config->lpszAutoConfigUrl = GlobalAlloc( 0, (len + 1) * sizeof(WCHAR) ))) goto done;
1724 copy_char_to_wchar_sz( (const BYTE *)hdr + offset , len, config->lpszAutoConfigUrl );
1725 }
1726 ret = TRUE;
1727
1728done:
1729 RegCloseKey( hkey );
1730 heap_free( hdr );
1731 if (!ret)
1732 {
1733 GlobalFree( config->lpszAutoConfigUrl );
1734 config->lpszAutoConfigUrl = NULL;
1735 GlobalFree( config->lpszProxy );
1736 config->lpszProxy = NULL;
1737 GlobalFree( config->lpszProxyBypass );
1738 config->lpszProxyBypass = NULL;
1739 }
1741 return ret;
1742}
1743
1745{
1746 const char *p;
1747 WCHAR *q;
1748 int len;
1749
1750 info->dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
1751 info->lpszProxy = NULL;
1752 info->lpszProxyBypass = NULL;
1753
1754 TRACE("%s\n", debugstr_a( result ));
1755
1756 p = result;
1757 while (*p == ' ') p++;
1758 len = strlen( p );
1759 if (len >= 5 && !_strnicmp( p, "PROXY", sizeof("PROXY") - 1 ))
1760 {
1761 p += 5;
1762 while (*p == ' ') p++;
1763 if (!*p || *p == ';') return TRUE;
1764 if (!(info->lpszProxy = q = strdupAW( p ))) return FALSE;
1765 info->dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
1766 for (; *q; q++)
1767 {
1768 if (*q == ' ' || *q == ';')
1769 {
1770 *q = 0;
1771 break;
1772 }
1773 }
1774 }
1775 return TRUE;
1776}
1777
1778static char *download_script( const WCHAR *url, DWORD *out_size )
1779{
1780 static const WCHAR typeW[] = {'*','/','*',0};
1781 static const WCHAR *acceptW[] = {typeW, NULL};
1782 HINTERNET ses, con = NULL, req = NULL;
1783 WCHAR *hostname;
1784 URL_COMPONENTSW uc;
1785 DWORD status, size = sizeof(status), offset, to_read, bytes_read, flags = 0;
1786 char *tmp, *buffer = NULL;
1787
1788 *out_size = 0;
1789
1790 memset( &uc, 0, sizeof(uc) );
1791 uc.dwStructSize = sizeof(uc);
1792 uc.dwHostNameLength = -1;
1793 uc.dwUrlPathLength = -1;
1794 if (!WinHttpCrackUrl( url, 0, 0, &uc )) return NULL;
1795 if (!(hostname = heap_alloc( (uc.dwHostNameLength + 1) * sizeof(WCHAR) ))) return NULL;
1796 memcpy( hostname, uc.lpszHostName, uc.dwHostNameLength * sizeof(WCHAR) );
1797 hostname[uc.dwHostNameLength] = 0;
1798
1799 if (!(ses = WinHttpOpen( NULL, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0 ))) goto done;
1800 if (!(con = WinHttpConnect( ses, hostname, uc.nPort, 0 ))) goto done;
1802 if (!(req = WinHttpOpenRequest( con, NULL, uc.lpszUrlPath, NULL, NULL, acceptW, flags ))) goto done;
1803 if (!WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 )) goto done;
1804
1805 if (!(WinHttpReceiveResponse( req, 0 ))) goto done;
1807 &size, NULL ) || status != HTTP_STATUS_OK) goto done;
1808
1809 size = 4096;
1810 if (!(buffer = heap_alloc( size ))) goto done;
1811 to_read = size;
1812 offset = 0;
1813 for (;;)
1814 {
1815 if (!WinHttpReadData( req, buffer + offset, to_read, &bytes_read )) goto done;
1816 if (!bytes_read) break;
1817 to_read -= bytes_read;
1818 offset += bytes_read;
1819 *out_size += bytes_read;
1820 if (!to_read)
1821 {
1822 to_read = size;
1823 size *= 2;
1824 if (!(tmp = heap_realloc( buffer, size ))) goto done;
1825 buffer = tmp;
1826 }
1827 }
1828
1829done:
1830 WinHttpCloseHandle( req );
1831 WinHttpCloseHandle( con );
1832 WinHttpCloseHandle( ses );
1835 return buffer;
1836}
1837
1839{
1843};
1844
1848
1850{
1851 BOOL ret;
1852 char *result, *urlA;
1853 DWORD len_result;
1855 URL_COMPONENTSW uc;
1856
1857 buffer.dwStructSize = sizeof(buffer);
1858 buffer.lpszScriptBuffer = script;
1859 buffer.dwScriptBufferSize = size;
1860
1861 if (!(urlA = strdupWA( url ))) return FALSE;
1863 {
1864 heap_free( urlA );
1865 return FALSE;
1866 }
1867
1868 memset( &uc, 0, sizeof(uc) );
1869 uc.dwStructSize = sizeof(uc);
1870 uc.dwHostNameLength = -1;
1871
1872 if (WinHttpCrackUrl( url, 0, 0, &uc ))
1873 {
1874 char *hostnameA = strdupWA_sized( uc.lpszHostName, uc.dwHostNameLength );
1875
1876 if ((ret = InternetGetProxyInfo( urlA, strlen(urlA),
1877 hostnameA, strlen(hostnameA), &result, &len_result )))
1878 {
1880 heap_free( result );
1881 }
1882
1883 heap_free( hostnameA );
1884 }
1885 heap_free( urlA );
1887}
1888
1889/***********************************************************************
1890 * WinHttpGetProxyForUrl (winhttp.@)
1891 */
1894{
1895 WCHAR *detected_pac_url = NULL;
1896 const WCHAR *pac_url;
1897 struct session *session;
1898 char *script;
1899 DWORD size;
1900 BOOL ret = FALSE;
1901
1902 TRACE("%p, %s, %p, %p\n", hsession, debugstr_w(url), options, info);
1903
1904 if (!(session = (struct session *)grab_object( hsession )))
1905 {
1907 return FALSE;
1908 }
1910 {
1913 return FALSE;
1914 }
1915 if (!url || !options || !info ||
1917 ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) && !options->dwAutoDetectFlags) ||
1918 ((options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT) &&
1920 {
1923 return FALSE;
1924 }
1925 if (options->dwFlags & WINHTTP_AUTOPROXY_AUTO_DETECT &&
1926 !WinHttpDetectAutoProxyConfigUrl( options->dwAutoDetectFlags, &detected_pac_url ))
1927 goto done;
1928
1929 if (options->dwFlags & WINHTTP_AUTOPROXY_CONFIG_URL) pac_url = options->lpszAutoConfigUrl;
1930 else pac_url = detected_pac_url;
1931
1932 if ((script = download_script( pac_url, &size )))
1933 {
1934 ret = run_script( script, size, url, info );
1935 heap_free( script );
1936 }
1937
1938done:
1939 GlobalFree( detected_pac_url );
1942 return ret;
1943}
1944
1945/***********************************************************************
1946 * WinHttpSetDefaultProxyConfiguration (winhttp.@)
1947 */
1949{
1950 LONG l;
1951 HKEY key;
1952 BOOL ret = FALSE;
1953 const WCHAR *src;
1954
1955 TRACE("%p\n", info);
1956
1957 if (!info)
1958 {
1960 return FALSE;
1961 }
1962 switch (info->dwAccessType)
1963 {
1965 break;
1967 if (!info->lpszProxy)
1968 {
1970 return FALSE;
1971 }
1972 /* Only ASCII characters are allowed */
1973 for (src = info->lpszProxy; *src; src++)
1974 if (*src > 0x7f)
1975 {
1977 return FALSE;
1978 }
1979 if (info->lpszProxyBypass)
1980 {
1981 for (src = info->lpszProxyBypass; *src; src++)
1982 if (*src > 0x7f)
1983 {
1985 return FALSE;
1986 }
1987 }
1988 break;
1989 default:
1991 return FALSE;
1992 }
1993
1995 KEY_WRITE, NULL, &key, NULL );
1996 if (!l)
1997 {
1998 DWORD size = sizeof(struct connection_settings_header) + 2 * sizeof(DWORD);
1999 BYTE *buf;
2000
2001 if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
2002 {
2003 size += strlenW( info->lpszProxy );
2004 if (info->lpszProxyBypass)
2005 size += strlenW( info->lpszProxyBypass );
2006 }
2007 buf = heap_alloc( size );
2008 if (buf)
2009 {
2012 DWORD *len = (DWORD *)(hdr + 1);
2013
2014 hdr->magic = WINHTTP_SETTINGS_MAGIC;
2015 hdr->unknown = 0;
2016 if (info->dwAccessType == WINHTTP_ACCESS_TYPE_NAMED_PROXY)
2017 {
2018 BYTE *dst;
2019
2020 hdr->flags = PROXY_TYPE_PROXY;
2021 *len++ = strlenW( info->lpszProxy );
2022 for (dst = (BYTE *)len, src = info->lpszProxy; *src;
2023 src++, dst++)
2024 *dst = *src;
2025 len = (DWORD *)dst;
2026 if (info->lpszProxyBypass)
2027 {
2028 *len++ = strlenW( info->lpszProxyBypass );
2029 for (dst = (BYTE *)len, src = info->lpszProxyBypass; *src;
2030 src++, dst++)
2031 *dst = *src;
2032 }
2033 else
2034 *len++ = 0;
2035 }
2036 else
2037 {
2038 hdr->flags = PROXY_TYPE_DIRECT;
2039 *len++ = 0;
2040 *len++ = 0;
2041 }
2043 if (!l)
2044 ret = TRUE;
2045 heap_free( buf );
2046 }
2047 RegCloseKey( key );
2048 }
2050 return ret;
2051}
2052
2053/***********************************************************************
2054 * WinHttpSetStatusCallback (winhttp.@)
2055 */
2058{
2059 struct object_header *hdr;
2061
2062 TRACE("%p, %p, 0x%08x, 0x%lx\n", handle, callback, flags, reserved);
2063
2064 if (!(hdr = grab_object( handle )))
2065 {
2068 }
2069 ret = hdr->callback;
2070 hdr->callback = callback;
2071 hdr->notify_mask = flags;
2072
2075 return ret;
2076}
2077
2078/***********************************************************************
2079 * WinHttpSetTimeouts (winhttp.@)
2080 */
2081BOOL WINAPI WinHttpSetTimeouts( HINTERNET handle, int resolve, int connect, int send, int receive )
2082{
2083 BOOL ret = TRUE;
2084 struct object_header *hdr;
2085
2086 TRACE("%p, %d, %d, %d, %d\n", handle, resolve, connect, send, receive);
2087
2088 if (resolve < -1 || connect < -1 || send < -1 || receive < -1)
2089 {
2091 return FALSE;
2092 }
2093
2094 if (!(hdr = grab_object( handle )))
2095 {
2097 return FALSE;
2098 }
2099
2100 switch(hdr->type)
2101 {
2103 {
2104 struct request *request = (struct request *)hdr;
2106
2107 if (resolve < 0) resolve = 0;
2108 request->resolve_timeout = resolve;
2109
2110 if (send < 0) send = 0;
2112
2113 if (receive < 0) receive = 0;
2114 request->receive_timeout = receive;
2115
2116 if (request->netconn)
2117 {
2119 if (netconn_set_timeout( request->netconn, FALSE, receive )) ret = FALSE;
2120 }
2121 break;
2122 }
2124 {
2125 struct session *session = (struct session *)hdr;
2127
2128 if (resolve < 0) resolve = 0;
2129 session->resolve_timeout = resolve;
2130
2131 if (send < 0) send = 0;
2133
2134 if (receive < 0) receive = 0;
2135 session->receive_timeout = receive;
2136 break;
2137 }
2138 default:
2140 ret = FALSE;
2141 }
2144 return ret;
2145}
2146
2147static const WCHAR wkday[7][4] =
2148 {{'S','u','n', 0}, {'M','o','n', 0}, {'T','u','e', 0}, {'W','e','d', 0},
2149 {'T','h','u', 0}, {'F','r','i', 0}, {'S','a','t', 0}};
2150static const WCHAR month[12][4] =
2151 {{'J','a','n', 0}, {'F','e','b', 0}, {'M','a','r', 0}, {'A','p','r', 0},
2152 {'M','a','y', 0}, {'J','u','n', 0}, {'J','u','l', 0}, {'A','u','g', 0},
2153 {'S','e','p', 0}, {'O','c','t', 0}, {'N','o','v', 0}, {'D','e','c', 0}};
2154
2155/***********************************************************************
2156 * WinHttpTimeFromSystemTime (WININET.@)
2157 */
2159{
2160 static const WCHAR format[] =
2161 {'%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2162 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0};
2163
2164 TRACE("%p, %p\n", time, string);
2165
2166 if (!time || !string)
2167 {
2169 return FALSE;
2170 }
2171
2172 sprintfW( string, format,
2173 wkday[time->wDayOfWeek],
2174 time->wDay,
2175 month[time->wMonth - 1],
2176 time->wYear,
2177 time->wHour,
2178 time->wMinute,
2179 time->wSecond );
2180
2182 return TRUE;
2183}
2184
2185/***********************************************************************
2186 * WinHttpTimeToSystemTime (WININET.@)
2187 */
2189{
2190 unsigned int i;
2191 const WCHAR *s = string;
2192 WCHAR *end;
2193
2194 TRACE("%s, %p\n", debugstr_w(string), time);
2195
2196 if (!string || !time)
2197 {
2199 return FALSE;
2200 }
2201
2202 /* Windows does this too */
2204
2205 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2206 * a SYSTEMTIME structure.
2207 */
2208
2210
2211 while (*s && !isalphaW( *s )) s++;
2212 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2213 time->wDayOfWeek = 7;
2214
2215 for (i = 0; i < 7; i++)
2216 {
2217 if (toupperW( wkday[i][0] ) == toupperW( s[0] ) &&
2218 toupperW( wkday[i][1] ) == toupperW( s[1] ) &&
2219 toupperW( wkday[i][2] ) == toupperW( s[2] ) )
2220 {
2221 time->wDayOfWeek = i;
2222 break;
2223 }
2224 }
2225
2226 if (time->wDayOfWeek > 6) return TRUE;
2227 while (*s && !isdigitW( *s )) s++;
2228 time->wDay = strtolW( s, &end, 10 );
2229 s = end;
2230
2231 while (*s && !isalphaW( *s )) s++;
2232 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2233 time->wMonth = 0;
2234
2235 for (i = 0; i < 12; i++)
2236 {
2237 if (toupperW( month[i][0]) == toupperW( s[0] ) &&
2238 toupperW( month[i][1]) == toupperW( s[1] ) &&
2239 toupperW( month[i][2]) == toupperW( s[2] ) )
2240 {
2241 time->wMonth = i + 1;
2242 break;
2243 }
2244 }
2245 if (time->wMonth == 0) return TRUE;
2246
2247 while (*s && !isdigitW( *s )) s++;
2248 if (*s == '\0') return TRUE;
2249 time->wYear = strtolW( s, &end, 10 );
2250 s = end;
2251
2252 while (*s && !isdigitW( *s )) s++;
2253 if (*s == '\0') return TRUE;
2254 time->wHour = strtolW( s, &end, 10 );
2255 s = end;
2256
2257 while (*s && !isdigitW( *s )) s++;
2258 if (*s == '\0') return TRUE;
2259 time->wMinute = strtolW( s, &end, 10 );
2260 s = end;
2261
2262 while (*s && !isdigitW( *s )) s++;
2263 if (*s == '\0') return TRUE;
2264 time->wSecond = strtolW( s, &end, 10 );
2265
2266 time->wMilliseconds = 0;
2267 return TRUE;
2268}
struct mke2fs_defaults settings[]
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
char * hostname
Definition: ftp.c:88
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
static HANDLE thread
Definition: service.c:33
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#define ERR(fmt,...)
Definition: debug.h:113
#define RegCloseKey(hKey)
Definition: registry.h:49
r l[0]
Definition: byte_order.h:168
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
static WCHAR * strdupAW(const char *src)
Definition: main.c:31
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:360
static struct list oidInfo
Definition: oid.c:1206
PCCRYPT_OID_INFO WINAPI CryptFindOIDInfo(DWORD dwKeyType, void *pvKey, DWORD dwGroupId)
Definition: oid.c:1799
DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
Definition: str.c:702
#define CloseHandle
Definition: compat.h:739
#define CP_UNIXCP
Definition: compat.h:79
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define TRACE_ON(x)
Definition: compat.h:75
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define MultiByteToWideChar
Definition: compat.h:110
static const WCHAR version[]
Definition: asmname.c:66
static const WCHAR getW[]
Definition: object.c:50
static char * strdupWA(const WCHAR *src)
Definition: main.c:91
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
static BOOL alloc_handle(struct handle_table *lpTable, OBJECTHDR *lpObject, HCRYPTKEY *lpHandle)
Definition: handle.c:183
static const WCHAR typeW[]
Definition: name.c:51
USHORT port
Definition: uri.c:228
BOOL free_handle(HINTERNET hinternet)
Definition: handle.c:123
struct object_header * grab_object(HINTERNET hinternet)
Definition: handle.c:56
void release_object(struct object_header *hdr)
Definition: handle.c:72
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
DWORD netconn_set_timeout(struct netconn *netconn, BOOL send, int value)
Definition: net.c:596
int netconn_get_cipher_strength(struct netconn *conn)
Definition: net.c:768
static BOOL request_set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:889
BOOL WINAPI WinHttpQueryOption(HINTERNET handle, DWORD option, LPVOID buffer, LPDWORD buflen)
Definition: session.c:1253
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
static const WCHAR WinHttpSettings[]
Definition: session.c:1509
BOOL WINAPI WinHttpGetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1537
static const struct object_vtbl session_vtbl
Definition: session.c:236
static void session_destroy(struct object_header *hdr)
Definition: session.c:77
static BOOL should_bypass_proxy(struct session *session, LPCWSTR server)
Definition: session.c:445
static const WCHAR wkday[7][4]
Definition: session.c:2147
static const struct object_vtbl request_vtbl
Definition: session.c:1080
HINTERNET WINAPI WinHttpOpen(LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWSTR bypass, DWORD flags)
Definition: session.c:250
#define DEFAULT_RECEIVE_TIMEOUT
Definition: session.c:52
static BOOL request_query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:710
#define DEFAULT_RESOLVE_TIMEOUT
Definition: session.c:49
#define INTERNET_MAX_URL_LENGTH
Definition: session.c:1418
static void connect_destroy(struct object_header *hdr)
Definition: session.c:318
static const DWORD PROXY_AUTODETECT_SETTINGS
Definition: session.c:1516
static WCHAR * buffer_to_str(WCHAR *buffer, DWORD buflen)
Definition: session.c:876
BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG *config)
Definition: session.c:1664
static WCHAR * build_wpad_url(const char *hostname, const struct addrinfo *ai)
Definition: session.c:1362
static int reverse_lookup(const struct addrinfo *ai, char *hostname, size_t len)
Definition: session.c:1357
#define MAX_HOST_NAME_LENGTH
Definition: session.c:443
HINTERNET WINAPI WinHttpConnect(HINTERNET hsession, LPCWSTR server, INTERNET_PORT port, DWORD reserved)
Definition: session.c:541
static const DWORD WININET_SETTINGS_MAGIC
Definition: session.c:1512
BOOL WINAPI WinHttpGetProxyForUrl(HINTERNET hsession, LPCWSTR url, WINHTTP_AUTOPROXY_OPTIONS *options, WINHTTP_PROXY_INFO *info)
Definition: session.c:1892
static const DWORD PROXY_TYPE_PROXY
Definition: session.c:1514
static BOOL set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:1273
BOOL WINAPI InternetDeInitializeAutoProxyDll(LPSTR, DWORD)
Definition: main.c:111
static const DWORD PROXY_USE_PAC_SCRIPT
Definition: session.c:1515
static BOOL session_set_option(struct object_header *hdr, DWORD option, void *buffer, DWORD buflen)
Definition: session.c:147
static WCHAR * blob_to_str(DWORD encoding, CERT_NAME_BLOB *blob)
Definition: session.c:672
static char * download_script(const WCHAR *url, DWORD *out_size)
Definition: session.c:1778
BOOL WINAPI WinHttpTimeFromSystemTime(const SYSTEMTIME *time, LPWSTR string)
Definition: session.c:2158
#define DEFAULT_SEND_TIMEOUT
Definition: session.c:51
BOOL WINAPI InternetInitializeAutoProxyDll(DWORD, LPSTR, LPSTR, void *, struct AUTO_PROXY_SCRIPT_BUFFER *)
BOOL WINAPI WinHttpSetDefaultProxyConfiguration(WINHTTP_PROXY_INFO *info)
Definition: session.c:1948
static BOOL get_system_proxy_autoconfig_url(char *buf, DWORD buflen)
Definition: session.c:1384
BOOL set_server_for_hostname(struct connect *connect, const WCHAR *server, INTERNET_PORT port)
Definition: session.c:476
BOOL WINAPI WinHttpCloseHandle(HINTERNET handle)
Definition: session.c:1195
static char * get_computer_name(COMPUTER_NAME_FORMAT format)
Definition: session.c:1332
static BOOL query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:1212
static BOOL copy_sockaddr(const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage)
Definition: session.c:684
BOOL WINAPI WinHttpSetTimeouts(HINTERNET handle, int resolve, int connect, int send, int receive)
Definition: session.c:2081
static void str_to_buffer(WCHAR *buffer, const WCHAR *str, LPDWORD buflen)
Definition: session.c:660
static const DWORD PROXY_TYPE_DIRECT
Definition: session.c:1513
static WCHAR * get_request_path(const WCHAR *object)
Definition: session.c:1101
static BOOL parse_script_result(const char *result, WINHTTP_PROXY_INFO *info)
Definition: session.c:1744
#define DEFAULT_RECEIVE_RESPONSE_TIMEOUT
Definition: session.c:53
static const WCHAR month[12][4]
Definition: session.c:2150
HINTERNET WINAPI WinHttpOpenRequest(HINTERNET hconnect, LPCWSTR verb, LPCWSTR object, LPCWSTR version, LPCWSTR referrer, LPCWSTR *types, DWORD flags)
Definition: session.c:1117
#define DEFAULT_CONNECT_TIMEOUT
Definition: session.c:50
static void copy_char_to_wchar_sz(const BYTE *src, DWORD len, WCHAR *dst)
Definition: session.c:1525
BOOL WINAPI WinHttpSetOption(HINTERNET handle, DWORD option, LPVOID buffer, DWORD buflen)
Definition: session.c:1312
static const WCHAR Connections[]
Definition: session.c:1502
static const struct object_vtbl connect_vtbl
Definition: session.c:384
BOOL WINAPI WinHttpCheckPlatform(void)
Definition: session.c:68
static BOOL session_query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:96
static BOOL is_domain_suffix(const char *domain, const char *suffix)
Definition: session.c:1348
static BOOL run_script(char *script, DWORD size, const WCHAR *url, WINHTTP_PROXY_INFO *info)
Definition: session.c:1849
BOOL WINAPI WinHttpDetectAutoProxyConfigUrl(DWORD flags, LPWSTR *url)
Definition: session.c:1423
static BOOL domain_matches(LPCWSTR server, LPCWSTR domain)
Definition: session.c:391
BOOL WINAPI WinHttpTimeToSystemTime(LPCWSTR string, SYSTEMTIME *time)
Definition: session.c:2188
static BOOL add_accept_types_header(struct request *request, const WCHAR **types)
Definition: session.c:1087
WINHTTP_STATUS_CALLBACK WINAPI WinHttpSetStatusCallback(HINTERNET handle, WINHTTP_STATUS_CALLBACK callback, DWORD flags, DWORD_PTR reserved)
Definition: session.c:2056
static BOOL connect_query_option(struct object_header *hdr, DWORD option, void *buffer, DWORD *buflen)
Definition: session.c:333
static const DWORD WINHTTP_SETTINGS_MAGIC
Definition: session.c:1511
static void request_destroy(struct object_header *hdr)
Definition: session.c:604
BOOL WINAPI InternetGetProxyInfo(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD)
BOOL WINAPI WinHttpCrackUrl(LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc)
Definition: url.c:179
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
r reserved
Definition: btrfs.c:3006
ULONG to_read
Definition: btrfs.c:4260
#define AF_INET
Definition: tcpip.h:117
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
WDF_INTERRUPT_POLICY policy
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLsizeiptr size
Definition: glext.h:5919
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLenum GLenum dst
Definition: glext.h:6340
GLbitfield flags
Definition: glext.h:7161
const GLint * first
Definition: glext.h:5794
GLenum const GLvoid * addr
Definition: glext.h:9621
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
GLintptr offset
Definition: glext.h:5920
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
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 GLint GLint j
Definition: glfuncs.h:250
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define bits
Definition: infblock.c:15
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT, LPSTR, LPDWORD)
Definition: compname.c:376
char hdr[14]
Definition: iptest.cpp:33
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
if(dx< 0)
Definition: linetemp.h:194
__u16 time
Definition: mkdosfs.c:8
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char string[160]
Definition: util.h:11
int socklen_t
Definition: tcp.c:35
static PVOID ptr
Definition: dispmode.c:27
static IPrintDialogCallback callback
Definition: printdlg.c:326
static const WCHAR url[]
Definition: encode.c:1432
static BYTE cert[]
Definition: msg.c:1437
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
static refpint_t pi[]
Definition: server.c:96
static const WCHAR httpW[]
Definition: assoc.c:94
int disable
Definition: msacm.c:1365
script
Definition: msipriv.h:383
#define REG_BINARY
Definition: nt_native.h:1496
#define KEY_READ
Definition: nt_native.h:1023
#define KEY_WRITE
Definition: nt_native.h:1031
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define atoiW(s)
Definition: unicode.h:60
#define strncmpiW(s1, s2, n)
Definition: unicode.h:46
#define toupperW(n)
Definition: unicode.h:51
#define isdigitW(n)
Definition: unicode.h:56
#define strchrW(s, c)
Definition: unicode.h:40
#define strcmpiW(s1, s2)
Definition: unicode.h:45
#define strlenW(s)
Definition: unicode.h:34
#define sprintfW
Definition: unicode.h:64
#define strtolW(s, e, b)
Definition: unicode.h:39
#define strcpyW(d, s)
Definition: unicode.h:35
#define isalphaW(n)
Definition: unicode.h:54
BOOL WINAPI WinHttpQueryHeaders(HINTERNET hrequest, DWORD level, LPCWSTR name, LPVOID buffer, LPDWORD buflen, LPDWORD index)
Definition: request.c:856
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
BOOL WINAPI WinHttpReadData(HINTERNET hrequest, LPVOID buffer, DWORD to_read, LPDWORD read)
Definition: request.c:3053
BOOL WINAPI WinHttpSendRequest(HINTERNET hrequest, LPCWSTR headers, DWORD headers_len, LPVOID optional, DWORD optional_len, DWORD total_len, DWORD_PTR context)
Definition: request.c:2350
BOOL WINAPI WinHttpReceiveResponse(HINTERNET hrequest, LPVOID reserved)
Definition: request.c:2924
static void accepted(enum accept_stat, struct rpc_err *)
Definition: rpc_prot.c:280
const WCHAR * str
static void destroy_authinfo(struct authinfo *info)
#define memset(x, y, z)
Definition: compat.h:39
INT WSAAPI getsockname(IN SOCKET s, OUT LPSOCKADDR name, IN OUT INT FAR *namelen)
Definition: sockctrl.c:213
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwStructSize
Definition: wininet.h:211
DWORD dwUrlPathLength
Definition: wininet.h:223
LPWSTR lpszHostName
Definition: wininet.h:215
DWORD dwHostNameLength
Definition: wininet.h:216
INTERNET_SCHEME nScheme
Definition: wininet.h:214
LPWSTR lpszUrlPath
Definition: wininet.h:222
INTERNET_PORT nPort
Definition: wininet.h:217
LPWSTR lpszEncryptionAlgName
Definition: winhttp.h:498
DWORD_PTR Spare[8/sizeof(DWORD_PTR)]
Definition: winbase.h:887
PCRITICAL_SECTION_DEBUG DebugInfo
Definition: winbase.h:894
size_t ai_addrlen
Definition: ws2def.h:669
struct sockaddr * ai_addr
Definition: ws2def.h:671
struct addrinfo * ai_next
Definition: ws2def.h:672
int ai_family
Definition: ws2def.h:666
Definition: image.c:134
WCHAR * hostname
struct session * session
WCHAR * password
WCHAR * servername
INTERNET_PORT hostport
WCHAR * username
INTERNET_PORT serverport
struct object_header hdr
Definition: cookie.c:42
Definition: copy.c:22
Definition: name.c:39
Definition: getopt.h:109
Definition: send.c:48
Definition: tftpd.h:86
HANDLE task_cancel
BOOL task_proc_running
const CERT_CONTEXT * server_cert
struct request::@603 creds[TARGET_MAX][SCHEME_MAX]
struct list task_queue
WCHAR * version
char path[256]
Definition: tftpd.h:94
const CERT_CONTEXT * client_cert
int send_timeout
struct header * headers
struct object_header hdr
WCHAR * verb
DWORD security_flags
struct authinfo * authinfo
DWORD num_headers
CredHandle cred_handle
WCHAR * status_text
int receive_timeout
BOOL check_revocation
int connect_timeout
int resolve_timeout
WCHAR * raw_headers
struct connect * connect
int receive_response_timeout
BOOL cred_handle_initialized
struct netconn * netconn
struct authinfo * proxy_authinfo
int resolve_timeout
WCHAR * proxy_password
DWORD passport_flags
WCHAR * proxy_bypass
int receive_response_timeout
CRITICAL_SECTION cs
int receive_timeout
DWORD access
HANDLE unload_event
DWORD secure_protocols
WCHAR * agent
WCHAR * proxy_server
struct object_header hdr
int send_timeout
WCHAR * proxy_username
int connect_timeout
struct list cookie_cache
Definition: ps.c:97
Definition: cmds.c:130
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint32_t * LPDWORD
Definition: typedefs.h:59
static rfbScreenInfoPtr server
Definition: vnc.c:74
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define CERT_SIMPLE_NAME_STR
Definition: wincrypt.h:3484
#define CERT_NAME_STR_CRLF_FLAG
Definition: wincrypt.h:3490
#define CRYPT_OID_INFO_OID_KEY
Definition: wincrypt.h:1702
#define WINAPI
Definition: msvc.h:6
void destroy_cookies(struct session *session)
Definition: cookie.c:120
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define WINHTTP_OPTION_PROXY
Definition: winhttp.h:110
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
#define SECURITY_FLAG_STRENGTH_MEDIUM
Definition: winhttp.h:287
#define WINHTTP_OPTION_PROXY_PASSWORD
Definition: winhttp.h:148
#define WINHTTP_OPTION_USERNAME
Definition: winhttp.h:145
WORD INTERNET_PORT
Definition: winhttp.h:38
#define WINHTTP_AUTO_DETECT_TYPE_DHCP
Definition: winhttp.h:527
#define WINHTTP_OPTION_CONFIGURE_PASSPORT_AUTH
Definition: winhttp.h:126
#define WINHTTP_OPTION_MAX_CONNS_PER_SERVER
Definition: winhttp.h:118
#define WINHTTP_OPTION_CONTEXT_VALUE
Definition: winhttp.h:112
#define SECURITY_FLAG_IGNORE_CERT_WRONG_USAGE
Definition: winhttp.h:284
#define WINHTTP_OPTION_SEND_TIMEOUT
Definition: winhttp.h:98
#define WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT
Definition: winhttp.h:141
#define WINHTTP_OPTION_CONNECTION_INFO
Definition: winhttp.h:136
#define WINHTTP_OPTION_SERVER_CERT_CONTEXT
Definition: winhttp.h:121
#define WINHTTP_OPTION_SECURITY_FLAGS
Definition: winhttp.h:106
#define WINHTTP_HANDLE_TYPE_CONNECT
Definition: winhttp.h:431
LPVOID HINTERNET
Definition: winhttp.h:32
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
#define SECURITY_FLAG_STRENGTH_WEAK
Definition: winhttp.h:286
#define WINHTTP_OPTION_PROXY_USERNAME
Definition: winhttp.h:147
#define WINHTTP_OPTION_ENABLE_FEATURE
Definition: winhttp.h:122
#define WINHTTP_INVALID_STATUS_CALLBACK
Definition: winhttp.h:422
#define WINHTTP_OPTION_PASSWORD
Definition: winhttp.h:146
#define WINHTTP_OPTION_RESOLVE_TIMEOUT
Definition: winhttp.h:95
#define WINHTTP_OPTION_DISABLE_FEATURE
Definition: winhttp.h:116
#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT
Definition: winhttp.h:113
#define WINHTTP_ENABLE_SSL_REVOCATION
Definition: winhttp.h:172
#define WINHTTP_AUTOPROXY_AUTO_DETECT
Definition: winhttp.h:530
#define WINHTTP_QUERY_STATUS_CODE
Definition: winhttp.h:317
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
Definition: winhttp.h:62
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY
Definition: winhttp.h:64
#define WINHTTP_OPTION_REDIRECT_POLICY_DISALLOW_HTTPS_TO_HTTP
Definition: winhttp.h:158
#define ERROR_WINHTTP_INCORRECT_HANDLE_STATE
Definition: winhttp.h:200
#define ERROR_WINHTTP_INVALID_OPTION
Definition: winhttp.h:194
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
#define WINHTTP_OPTION_CONNECT_RETRIES
Definition: winhttp.h:97
#define WINHTTP_QUERY_FLAG_NUMBER
Definition: winhttp.h:377
#define SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
Definition: winhttp.h:282
#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT
Definition: winhttp.h:221
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A
Definition: winhttp.h:528
#define WINHTTP_OPTION_CONNECT_TIMEOUT
Definition: winhttp.h:96
#define WINHTTP_OPTION_AUTOLOGON_POLICY
Definition: winhttp.h:120
VOID(CALLBACK * WINHTTP_STATUS_CALLBACK)(_In_ HINTERNET, _In_ DWORD_PTR, _In_ DWORD, _In_ LPVOID, _In_ DWORD)
Definition: winhttp.h:520
#define WINHTTP_OPTION_RECEIVE_TIMEOUT
Definition: winhttp.h:99
#define INTERNET_DEFAULT_PORT
Definition: winhttp.h:35
#define ERROR_WINHTTP_AUTODETECTION_FAILED
Definition: winhttp.h:228
#define ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
Definition: winhttp.h:199
#define WINHTTP_ACCESS_TYPE_NO_PROXY
Definition: winhttp.h:63
#define WINHTTP_OPTION_SECURITY_CERTIFICATE_STRUCT
Definition: winhttp.h:107
#define WINHTTP_CALLBACK_STATUS_HANDLE_CREATED
Definition: winhttp.h:390
#define WINHTTP_FLAG_SECURE
Definition: winhttp.h:60
#define WINHTTP_OPTION_RECEIVE_RESPONSE_TIMEOUT
Definition: winhttp.h:100
#define INTERNET_SCHEME_HTTPS
Definition: winhttp.h:43
#define WINHTTP_OPTION_REDIRECT_POLICY
Definition: winhttp.h:131
#define WINHTTP_OPTION_SECURITY_KEY_BITNESS
Definition: winhttp.h:109
#define WINHTTP_OPTION_SECURE_PROTOCOLS
Definition: winhttp.h:127
#define SECURITY_FLAG_STRENGTH_STRONG
Definition: winhttp.h:288
#define SECURITY_FLAG_IGNORE_UNKNOWN_CA
Definition: winhttp.h:281
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
#define WINHTTP_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: winhttp.h:119
#define WINHTTP_OPTION_PARENT_HANDLE
Definition: winhttp.h:104
#define WINHTTP_AUTOPROXY_CONFIG_URL
Definition: winhttp.h:531
#define SECURITY_FLAG_IGNORE_CERT_CN_INVALID
Definition: winhttp.h:283
static const WCHAR http1_1[]
static char * strdupWA_sized(const WCHAR *src, DWORD size)
@ TARGET_MAX
@ SCHEME_MAX
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define AF_INET6
Definition: winsock.h:369
BOOL winsock_init(void)
Definition: wintirpc.c:77
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
#define NI_MAXHOST
Definition: ws2def.h:359
#define getaddrinfo
Definition: wspiapi.h:44
#define getnameinfo
Definition: wspiapi.h:45
#define freeaddrinfo
Definition: wspiapi.h:46
static clock_t begin
Definition: xmllint.c:458
static char * encoding
Definition: xmllint.c:155
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193