ReactOS  0.4.14-dev-860-gd05f621
winhttp_private.h File Reference
#include "wine/heap.h"
#include "wine/list.h"
#include "wine/unicode.h"
#include "ole2.h"
#include "sspi.h"
#include "wincrypt.h"
Include dependency graph for winhttp_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  object_vtbl
 
struct  object_header
 
struct  hostdata
 
struct  session
 
struct  connect
 
struct  netconn
 
struct  header
 
struct  authinfo
 
struct  request
 
struct  task_header
 
struct  send_request
 
struct  receive_response
 
struct  query_data
 
struct  read_data
 
struct  write_data
 

Enumerations

enum  auth_target { TARGET_INVALID = -1, TARGET_SERVER, TARGET_PROXY, TARGET_MAX }
 
enum  auth_scheme {
  SCHEME_INVALID = -1, SCHEME_BASIC, SCHEME_NTLM, SCHEME_PASSPORT,
  SCHEME_DIGEST, SCHEME_NEGOTIATE, SCHEME_MAX
}
 

Functions

struct object_headeraddref_object (struct object_header *) DECLSPEC_HIDDEN
 
struct object_headergrab_object (HINTERNET) DECLSPEC_HIDDEN
 
void release_object (struct object_header *) DECLSPEC_HIDDEN
 
HINTERNET alloc_handle (struct object_header *) DECLSPEC_HIDDEN
 
BOOL free_handle (HINTERNET) DECLSPEC_HIDDEN
 
void send_callback (struct object_header *, DWORD, LPVOID, DWORD) DECLSPEC_HIDDEN
 
void close_connection (struct request *) DECLSPEC_HIDDEN
 
void netconn_close (struct netconn *) DECLSPEC_HIDDEN
 
struct netconnnetconn_create (struct hostdata *, const struct sockaddr_storage *, int) DECLSPEC_HIDDEN
 
void netconn_unload (void) DECLSPEC_HIDDEN
 
ULONG netconn_query_data_available (struct netconn *) DECLSPEC_HIDDEN
 
BOOL netconn_recv (struct netconn *, void *, size_t, int, int *) DECLSPEC_HIDDEN
 
BOOL netconn_resolve (WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int) DECLSPEC_HIDDEN
 
BOOL netconn_secure_connect (struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL) DECLSPEC_HIDDEN
 
BOOL netconn_send (struct netconn *, const void *, size_t, int *) DECLSPEC_HIDDEN
 
DWORD netconn_set_timeout (struct netconn *, BOOL, int) DECLSPEC_HIDDEN
 
BOOL netconn_is_alive (struct netconn *) DECLSPEC_HIDDEN
 
const voidnetconn_get_certificate (struct netconn *) DECLSPEC_HIDDEN
 
int netconn_get_cipher_strength (struct netconn *) DECLSPEC_HIDDEN
 
BOOL set_cookies (struct request *, const WCHAR *) DECLSPEC_HIDDEN
 
BOOL add_cookie_headers (struct request *) DECLSPEC_HIDDEN
 
BOOL add_request_headers (struct request *, const WCHAR *, DWORD, DWORD) DECLSPEC_HIDDEN
 
void destroy_cookies (struct session *) DECLSPEC_HIDDEN
 
BOOL set_server_for_hostname (struct connect *, const WCHAR *, INTERNET_PORT) DECLSPEC_HIDDEN
 
void destroy_authinfo (struct authinfo *) DECLSPEC_HIDDEN
 
void release_host (struct hostdata *) DECLSPEC_HIDDEN
 
BOOL process_header (struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL) DECLSPEC_HIDDEN
 
HRESULT WinHttpRequest_create (void **) DECLSPEC_HIDDEN
 
void release_typelib (void) DECLSPEC_HIDDEN
 
static void__WINE_ALLOC_SIZE (2) heap_realloc_zero(LPVOID mem
 
static WCHARstrdupW (const WCHAR *src)
 
static WCHARstrdupAW (const char *src)
 
static charstrdupWA (const WCHAR *src)
 
static charstrdupWA_sized (const WCHAR *src, DWORD size)
 

Variables

static const WCHAR getW [] = {'G','E','T',0}
 
static const WCHAR postW [] = {'P','O','S','T',0}
 
static const WCHAR headW [] = {'H','E','A','D',0}
 
static const WCHAR slashW [] = {'/',0}
 
static const WCHAR http1_0 [] = {'H','T','T','P','/','1','.','0',0}
 
static const WCHAR http1_1 [] = {'H','T','T','P','/','1','.','1',0}
 
static const WCHAR chunkedW [] = {'c','h','u','n','k','e','d',0}
 
static void SIZE_T size
 
HINSTANCE winhttp_instance DECLSPEC_HIDDEN
 

Enumeration Type Documentation

◆ auth_scheme

Enumerator
SCHEME_INVALID 
SCHEME_BASIC 
SCHEME_NTLM 
SCHEME_PASSPORT 
SCHEME_DIGEST 
SCHEME_NEGOTIATE 
SCHEME_MAX 

Definition at line 146 of file winhttp_private.h.

◆ auth_target

Enumerator
TARGET_INVALID 
TARGET_SERVER 
TARGET_PROXY 
TARGET_MAX 

Definition at line 138 of file winhttp_private.h.

Function Documentation

◆ __WINE_ALLOC_SIZE()

static void* __WINE_ALLOC_SIZE ( )
inlinestatic

◆ add_cookie_headers()

BOOL add_cookie_headers ( struct request )

Definition at line 324 of file cookie.c.

325 {
326  struct list *domain_cursor;
327  struct session *session = request->connect->session;
328 
330 
331  LIST_FOR_EACH( domain_cursor, &session->cookie_cache )
332  {
333  struct domain *domain = LIST_ENTRY( domain_cursor, struct domain, entry );
334  if (domain_match( request->connect->servername, domain, TRUE ))
335  {
336  struct list *cookie_cursor;
337  TRACE("found domain %s\n", debugstr_w(domain->name));
338 
339  LIST_FOR_EACH( cookie_cursor, &domain->cookies )
340  {
341  struct cookie *cookie = LIST_ENTRY( cookie_cursor, struct cookie, entry );
342 
343  TRACE("comparing path %s with %s\n", debugstr_w(request->path), debugstr_w(cookie->path));
344 
345  if (strstrW( request->path, cookie->path ) == request->path)
346  {
347  static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
348  int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = strlenW( cookie->name );
349  WCHAR *header;
350 
351  len = len_cookie + len_name;
352  if (cookie->value) len += strlenW( cookie->value ) + 1;
353  if (!(header = heap_alloc( (len + 1) * sizeof(WCHAR) )))
354  {
356  return FALSE;
357  }
358 
359  memcpy( header, cookieW, len_cookie * sizeof(WCHAR) );
360  strcpyW( header + len_cookie, cookie->name );
361  if (cookie->value)
362  {
363  header[len_cookie + len_name] = '=';
364  strcpyW( header + len_cookie + len_name + 1, cookie->value );
365  }
366 
367  TRACE("%s\n", debugstr_w(header));
370  heap_free( header );
371  }
372  }
373  }
374  }
375 
377  return TRUE;
378 }
BOOL add_request_headers(struct request *request, const WCHAR *headers, DWORD len, DWORD flags)
Definition: request.c:495
struct connect * connect
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
struct list cookies
Definition: cookie.c:45
WCHAR * name
Definition: cookie.c:36
static BOOL domain_match(const WCHAR *name, struct domain *domain, BOOL partial)
Definition: cookie.c:81
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
WCHAR * name
Definition: cookie.c:44
Definition: cookie.c:41
WCHAR * value
Definition: cookie.c:37
#define debugstr_w
Definition: kernel32.h:32
char path[256]
Definition: tftpd.h:94
#define strstrW(d, s)
Definition: unicode.h:32
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:188
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:86
#define TRACE(s)
Definition: solgame.cpp:4
CRITICAL_SECTION cs
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct list cookie_cache
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: _list.h:228
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: cookie.c:33
Definition: tftpd.h:85
WCHAR * path
Definition: cookie.c:38
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define LIST_ENTRY(type)
Definition: queue.h:175
struct CFHEADER header
Definition: fdi.c:101
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by send_request().

◆ add_request_headers()

BOOL add_request_headers ( struct request ,
const WCHAR ,
DWORD  ,
DWORD   
)

Definition at line 495 of file request.c.

496 {
497  BOOL ret = FALSE;
498  WCHAR *buffer, *p, *q;
499  struct header *header;
500 
501  if (len == ~0u) len = strlenW( headers );
502  if (!len) return TRUE;
503  if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
504  memcpy( buffer, headers, len * sizeof(WCHAR) );
505  buffer[len] = 0;
506 
507  p = buffer;
508  do
509  {
510  q = p;
511  while (*q)
512  {
513  if (q[0] == '\n' && q[1] == '\r')
514  {
515  q[0] = '\r';
516  q[1] = '\n';
517  }
518  if (q[0] == '\r' && q[1] == '\n') break;
519  q++;
520  }
521  if (!*p) break;
522  if (*q == '\r')
523  {
524  *q = 0;
525  q += 2; /* jump over \r\n */
526  }
527  if ((header = parse_header( p )))
528  {
530  free_header( header );
531  }
532  p = q;
533  } while (ret);
534 
535  heap_free( buffer );
536  return ret;
537 }
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 * u
Definition: glfuncs.h:240
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WCHAR * field
GLuint buffer
Definition: glext.h:5915
BOOL process_header(struct request *request, const WCHAR *field, const WCHAR *value, DWORD flags, BOOL request_only)
Definition: request.c:430
vector< Header * > headers
Definition: sdkparse.cpp:39
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
WCHAR * value
__wchar_t WCHAR
Definition: xmlstorage.h:180
static struct header * parse_header(const WCHAR *string)
Definition: request.c:325
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLbitfield flags
Definition: glext.h:7161
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int len
Definition: request.c:891
struct CFHEADER header
Definition: fdi.c:101
static void free_header(struct header *header)
Definition: request.c:297
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by add_cookie_headers(), send_request(), and WinHttpAddRequestHeaders().

◆ addref_object()

struct object_header* addref_object ( struct object_header )

Definition at line 49 of file handle.c.

50 {
51  ULONG refs = InterlockedIncrement( &hdr->refs );
52  TRACE("%p -> refcount = %d\n", hdr, refs);
53  return hdr;
54 }
char hdr[14]
Definition: iptest.cpp:33
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

Referenced by alloc_handle(), grab_object(), WinHttpConnect(), WinHttpOpenRequest(), WinHttpQueryDataAvailable(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), and WinHttpWriteData().

◆ alloc_handle()

HINTERNET alloc_handle ( struct object_header )

Definition at line 88 of file handle.c.

89 {
90  struct object_header **p;
92 
93  list_init( &hdr->children );
94  hdr->handle = NULL;
95 
97  if (!max_handles)
98  {
100  if (!(p = heap_alloc_zero( sizeof(ULONG_PTR) * num ))) goto end;
101  handles = p;
102  max_handles = num;
103  }
104  if (max_handles == next_handle)
105  {
106  num = max_handles * 2;
107  if (!(p = heap_realloc_zero( handles, sizeof(ULONG_PTR) * num ))) goto end;
108  handles = p;
109  max_handles = num;
110  }
112  if (handles[handle]) ERR("handle isn't free but should be\n");
113 
115  hdr->handle = (HINTERNET)(handle + 1);
117 
118 end:
120  return hdr->handle;
121 }
LPVOID HINTERNET
Definition: winhttp.h:32
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
char hdr[14]
Definition: iptest.cpp:33
static struct object_header ** handles
Definition: handle.c:45
GLuint GLuint end
Definition: gl.h:1545
#define HANDLE_CHUNK_SIZE
Definition: handle.c:34
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
static ULONG_PTR next_handle
Definition: handle.c:46
GLuint GLuint num
Definition: glext.h:9618
#define ERR(fmt,...)
Definition: debug.h:109
static ULONG_PTR max_handles
Definition: handle.c:47
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
GLfloat GLfloat p
Definition: glext.h:8902
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
static CRITICAL_SECTION handle_cs
Definition: handle.c:36

◆ close_connection()

void close_connection ( struct request )

Definition at line 1809 of file request.c.

1810 {
1811  if (!request->netconn) return;
1812 
1815  request->netconn = NULL;
1817 }
#define WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION
Definition: winhttp.h:388
smooth NULL
Definition: ftsmooth.c:416
void netconn_close(struct netconn *conn)
Definition: net.c:250
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
struct object_header hdr
struct netconn * netconn
Definition: tftpd.h:85
#define WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED
Definition: winhttp.h:389

Referenced by finished_reading(), and release_object().

◆ destroy_authinfo()

void destroy_authinfo ( struct authinfo )

Definition at line 1138 of file request.c.

1139 {
1140  if (!authinfo) return;
1141 
1142  if (SecIsValidHandle( &authinfo->ctx ))
1144  if (SecIsValidHandle( &authinfo->cred ))
1146 
1147  heap_free( authinfo->data );
1148  heap_free( authinfo );
1149 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
CredHandle cred
char * data
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
CtxtHandle ctx

Referenced by do_authorization().

◆ destroy_cookies()

void destroy_cookies ( struct session )

Definition at line 120 of file cookie.c.

121 {
122  struct list *item, *next;
123  struct domain *domain;
124 
126  {
127  domain = LIST_ENTRY( item, struct domain, entry );
129  }
130 }
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:192
Definition: cookie.c:41
struct list cookie_cache
uint32_t entry
Definition: isohybrid.c:63
Definition: _list.h:228
static unsigned __int64 next
Definition: rand_nt.c:6
static ATOM item
Definition: dde.c:856
static void delete_domain(struct domain *domain)
Definition: cookie.c:104
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by session_destroy().

◆ free_handle()

BOOL free_handle ( HINTERNET  )

Definition at line 123 of file handle.c.

124 {
125  BOOL ret = FALSE;
126  ULONG_PTR handle = (ULONG_PTR)hinternet;
127  struct object_header *hdr = NULL, *child, *next;
128 
130 
131  if ((handle > 0) && (handle <= max_handles))
132  {
133  handle--;
134  if (handles[handle])
135  {
136  hdr = handles[handle];
137  TRACE("destroying handle 0x%lx for object %p\n", handle + 1, hdr);
138  handles[handle] = NULL;
139  ret = TRUE;
140  }
141  }
142 
144 
145  if (hdr)
146  {
147  LIST_FOR_EACH_ENTRY_SAFE( child, next, &hdr->children, struct object_header, entry )
148  {
149  TRACE("freeing child handle %p for parent handle 0x%lx\n", child->handle, handle + 1);
150  free_handle( child->handle );
151  }
152  release_object( hdr );
153  }
154 
158 
159  return ret;
160 }
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
static struct object_header ** handles
Definition: handle.c:45
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
static HWND child
Definition: cursoricon.c:298
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static ULONG_PTR next_handle
Definition: handle.c:46
int ret
uint32_t entry
Definition: isohybrid.c:63
BOOL free_handle(HINTERNET hinternet)
Definition: handle.c:123
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static ULONG_PTR max_handles
Definition: handle.c:47
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static CRITICAL_SECTION handle_cs
Definition: handle.c:36
void release_object(struct object_header *hdr)
Definition: handle.c:72

Referenced by free_handle(), pqInsert(), and WinHttpCloseHandle().

◆ grab_object()

struct object_header* grab_object ( HINTERNET  )

Definition at line 56 of file handle.c.

57 {
58  struct object_header *hdr = NULL;
59  ULONG_PTR handle = (ULONG_PTR)hinternet;
60 
62 
63  if ((handle > 0) && (handle <= max_handles) && handles[handle - 1])
64  hdr = addref_object( handles[handle - 1] );
65 
67 
68  TRACE("handle 0x%lx -> %p\n", handle, hdr);
69  return hdr;
70 }
char hdr[14]
Definition: iptest.cpp:33
static struct object_header ** handles
Definition: handle.c:45
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static ULONG_PTR max_handles
Definition: handle.c:47
#define ULONG_PTR
Definition: config.h:101
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
struct object_header * addref_object(struct object_header *hdr)
Definition: handle.c:49
static CRITICAL_SECTION handle_cs
Definition: handle.c:36

Referenced by WinHttpAddRequestHeaders(), WinHttpCloseHandle(), WinHttpConnect(), WinHttpGetProxyForUrl(), WinHttpOpenRequest(), WinHttpQueryAuthSchemes(), WinHttpQueryDataAvailable(), WinHttpQueryHeaders(), WinHttpQueryOption(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), WinHttpSetCredentials(), WinHttpSetOption(), WinHttpSetStatusCallback(), WinHttpSetTimeouts(), and WinHttpWriteData().

◆ netconn_close()

void netconn_close ( struct netconn )

Definition at line 250 of file net.c.

251 {
252  if (conn->secure)
253  {
254  heap_free( conn->peek_msg_mem );
255  heap_free(conn->ssl_buf);
256  heap_free(conn->extra_buf);
257  DeleteSecurityContext(&conn->ssl_ctx);
258  }
259  closesocket( conn->socket );
260  release_host( conn->host );
261  heap_free(conn);
262 }
#define closesocket
Definition: precomp.h:57
void release_host(struct hostdata *host)
Definition: request.c:1494
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by close_connection(), connection_collector(), handle_redirect(), and open_connection().

◆ netconn_create()

struct netconn* netconn_create ( struct hostdata ,
const struct sockaddr_storage ,
int   
)

Definition at line 186 of file net.c.

187 {
188  struct netconn *conn;
189  unsigned int addr_len;
190  BOOL ret = FALSE;
191 
192 #ifndef __REACTOS__
193  winsock_init();
194 #endif
195 
196  conn = heap_alloc_zero(sizeof(*conn));
197  if (!conn) return NULL;
198  conn->host = host;
199  conn->sockaddr = *sockaddr;
200  if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
201  {
202  WARN("unable to create socket (%u)\n", WSAGetLastError());
203  heap_free(conn);
204  return NULL;
205  }
206 
207  switch (conn->sockaddr.ss_family)
208  {
209  case AF_INET:
210  addr_len = sizeof(struct sockaddr_in);
211  break;
212  case AF_INET6:
213  addr_len = sizeof(struct sockaddr_in6);
214  break;
215  default:
216  assert(0);
217  }
218 
219  if (timeout > 0) set_blocking( conn, FALSE );
220 
221  if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = TRUE;
222  else
223  {
225  if (err == WSAEWOULDBLOCK || err == WSAEINPROGRESS)
226  {
227  FD_SET set;
228  TIMEVAL timeval = { 0, timeout * 1000 };
229  int res;
230 
231  FD_ZERO( &set );
232  FD_SET( conn->socket, &set );
233  if ((res = select( conn->socket + 1, NULL, &set, NULL, &timeval )) > 0) ret = TRUE;
234  else if (!res) SetLastError( ERROR_WINHTTP_TIMEOUT );
235  }
236  }
237 
238  if (timeout > 0) set_blocking( conn, TRUE );
239 
240  if (!ret)
241  {
242  WARN("unable to connect to host (%u)\n", GetLastError());
243  closesocket( conn->socket );
244  heap_free( conn );
245  return NULL;
246  }
247  return conn;
248 }
Definition: winsock.h:66
#define TRUE
Definition: types.h:120
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
#define WARN(fmt,...)
Definition: debug.h:111
char * host
Definition: whois.c:55
#define closesocket
Definition: precomp.h:57
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
Definition: dhcpd.h:245
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
INT WSAAPI connect(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: sockctrl.c:23
#define WSAEINPROGRESS
Definition: winerror.h:1949
unsigned int BOOL
Definition: ntddk_ex.h:94
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
smooth NULL
Definition: ftsmooth.c:416
#define AF_INET6
Definition: winsock.h:369
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
static UINT set(struct ID3DXConstantTableImpl *table, IDirect3DDevice9 *device, struct ctab_constant *constant, const void **indata, D3DXPARAMETER_TYPE intype, UINT *size, UINT incol, D3DXPARAMETER_CLASS inclass, UINT index, BOOL is_pointer)
Definition: shader.c:1095
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
#define err(...)
struct hostdata * host
struct sockaddr_storage sockaddr
static void winsock_init(void)
Definition: net.c:173
GLuint res
Definition: glext.h:9613
#define AF_INET
Definition: tcpip.h:117
#define SOCK_STREAM
Definition: tcpip.h:118
Definition: _set.h:46
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
static void set_blocking(struct netconn *conn, BOOL blocking)
Definition: net.c:180

Referenced by open_connection().

◆ netconn_get_certificate()

const void* netconn_get_certificate ( struct netconn )

Definition at line 758 of file net.c.

759 {
760  const CERT_CONTEXT *ret;
762 
763  if (!conn->secure) return NULL;
765  return res == SEC_E_OK ? ret : NULL;
766 }
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
smooth NULL
Definition: ftsmooth.c:416
LONG SECURITY_STATUS
Definition: sspi.h:34
int ret
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
GLuint res
Definition: glext.h:9613

Referenced by open_connection().

◆ netconn_get_cipher_strength()

int netconn_get_cipher_strength ( struct netconn )

Definition at line 768 of file net.c.

769 {
772 
773  if (!conn->secure) return 0;
774  res = QueryContextAttributesW(&conn->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, (void*)&conn_info);
775  if(res != SEC_E_OK)
776  WARN("QueryContextAttributesW failed: %08x\n", res);
777  return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
778 }
#define WARN(fmt,...)
Definition: debug.h:111
LONG SECURITY_STATUS
Definition: sspi.h:34
#define SECPKG_ATTR_CONNECTION_INFO
Definition: schannel.h:76
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
GLuint res
Definition: glext.h:9613

Referenced by request_query_option().

◆ netconn_is_alive()

BOOL netconn_is_alive ( struct netconn )

Definition at line 608 of file net.c.

609 {
610  int len;
611  char b;
612  DWORD err;
613 
615  len = sock_recv( netconn->socket, &b, 1, MSG_PEEK );
616  err = WSAGetLastError();
618 
619  return len == 1 || (len == -1 && err == WSAEWOULDBLOCK);
620 }
#define TRUE
Definition: types.h:120
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
static void set_blocking(struct netconn *conn, BOOL blocking)
Definition: net.c:180
#define MSG_PEEK
Definition: winsock.h:222

Referenced by open_connection().

◆ netconn_query_data_available()

ULONG netconn_query_data_available ( struct netconn )

Definition at line 591 of file net.c.

592 {
593  return conn->secure ? conn->peek_len : 0;
594 }

Referenced by query_data_available().

◆ netconn_recv()

BOOL netconn_recv ( struct netconn ,
void ,
size_t  ,
int  ,
int  
)

Definition at line 539 of file net.c.

540 {
541  *recvd = 0;
542  if (!len) return TRUE;
543 
544  if (conn->secure)
545  {
546  SIZE_T size, cread;
547  BOOL res, eof;
548 
549  if (conn->peek_msg)
550  {
551  *recvd = min( len, conn->peek_len );
552  memcpy( buf, conn->peek_msg, *recvd );
553  conn->peek_len -= *recvd;
554  conn->peek_msg += *recvd;
555 
556  if (conn->peek_len == 0)
557  {
558  heap_free( conn->peek_msg_mem );
559  conn->peek_msg_mem = NULL;
560  conn->peek_msg = NULL;
561  }
562  /* check if we have enough data from the peek buffer */
563  if (!(flags & MSG_WAITALL) || *recvd == len) return TRUE;
564  }
565  size = *recvd;
566 
567  do {
568  res = read_ssl_chunk(conn, (BYTE*)buf+size, len-size, &cread, &eof);
569  if(!res) {
570  WARN("read_ssl_chunk failed\n");
571  if(!size)
572  return FALSE;
573  break;
574  }
575 
576  if(eof) {
577  TRACE("EOF\n");
578  break;
579  }
580 
581  size += cread;
582  }while(!size || ((flags & MSG_WAITALL) && size < len));
583 
584  TRACE("received %ld bytes\n", size);
585  *recvd = size;
586  return TRUE;
587  }
588  return ((*recvd = sock_recv( conn->socket, buf, len, flags )) != -1);
589 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
unsigned int BOOL
Definition: ntddk_ex.h:94
static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
Definition: net.c:448
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define min(a, b)
Definition: monoChain.cc:55
GLuint res
Definition: glext.h:9613
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by read_more_data().

◆ netconn_resolve()

BOOL netconn_resolve ( WCHAR ,
INTERNET_PORT  ,
struct sockaddr_storage ,
int   
)

Definition at line 725 of file net.c.

726 {
727  DWORD ret;
728 
730  else
731  {
732  struct async_resolve async;
733 
734  async.hostname = hostname;
735  async.port = port;
736  async.addr = addr;
737  if (!(async.done = CreateEventW( NULL, FALSE, FALSE, NULL ))) return FALSE;
738  if (!TrySubmitThreadpoolCallback( resolve_proc, &async, NULL ))
739  {
740  CloseHandle( async.done );
741  return FALSE;
742  }
744  else ret = async.result;
745  CloseHandle( async.done );
746  }
747 
748  if (ret)
749  {
750  SetLastError( ret );
751  return FALSE;
752  }
753  return TRUE;
754 }
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
static DWORD resolve_hostname(const WCHAR *name, INTERNET_PORT port, struct sockaddr_storage *sa)
Definition: net.c:622
#define ERROR_WINHTTP_TIMEOUT
Definition: winhttp.h:189
Definition: dhcpd.h:245
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
char * hostname
Definition: ftp.c:88
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
const WCHAR * hostname
Definition: net.c:711
static void CALLBACK resolve_proc(TP_CALLBACK_INSTANCE *instance, void *ctx)
Definition: net.c:718
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
int ret
GLenum const GLvoid * addr
Definition: glext.h:9621
USHORT port
Definition: uri.c:228

Referenced by open_connection().

◆ netconn_secure_connect()

BOOL netconn_secure_connect ( struct netconn ,
WCHAR ,
DWORD  ,
CredHandle ,
BOOL   
)

Definition at line 264 of file net.c.

266 {
267  SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
268  SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
269  BYTE *read_buf;
270  SIZE_T read_buf_size = 2048;
271  ULONG attrs = 0;
272  CtxtHandle ctx;
273  SSIZE_T size;
274  const CERT_CONTEXT *cert;
277 
280 
281  read_buf = heap_alloc(read_buf_size);
282  if(!read_buf)
283  return FALSE;
284 
285  status = InitializeSecurityContextW(cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
286  &ctx, &out_desc, &attrs, NULL);
287 
288  assert(status != SEC_E_OK);
289 
291  if(out_buf.cbBuffer) {
293 
294  TRACE("sending %u bytes\n", out_buf.cbBuffer);
295 
296  size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
297  if(size != out_buf.cbBuffer) {
298  ERR("send failed\n");
300  break;
301  }
302 
303  FreeContextBuffer(out_buf.pvBuffer);
304  out_buf.pvBuffer = NULL;
305  out_buf.cbBuffer = 0;
306  }
307 
309  assert(in_bufs[1].cbBuffer < read_buf_size);
310 
311  memmove(read_buf, (BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
312  in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
313 
314  in_bufs[1].BufferType = SECBUFFER_EMPTY;
315  in_bufs[1].cbBuffer = 0;
316  in_bufs[1].pvBuffer = NULL;
317  }
318 
319  assert(in_bufs[0].BufferType == SECBUFFER_TOKEN);
320  assert(in_bufs[1].BufferType == SECBUFFER_EMPTY);
321 
322  if(in_bufs[0].cbBuffer + 1024 > read_buf_size) {
323  BYTE *new_read_buf;
324 
325  new_read_buf = heap_realloc(read_buf, read_buf_size + 1024);
326  if(!new_read_buf) {
328  break;
329  }
330 
331  in_bufs[0].pvBuffer = read_buf = new_read_buf;
332  read_buf_size += 1024;
333  }
334 
335  size = sock_recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
336  if(size < 1) {
338  break;
339  }
340 
341  TRACE("recv %lu bytes\n", size);
342 
343  in_bufs[0].cbBuffer += size;
344  in_bufs[0].pvBuffer = read_buf;
345  status = InitializeSecurityContextW(cred_handle, &ctx, hostname, isc_req_flags, 0, 0, &in_desc,
346  0, NULL, &out_desc, &attrs, NULL);
347  TRACE("InitializeSecurityContext ret %08x\n", status);
348 
349  if(status == SEC_E_OK) {
350  if(in_bufs[1].BufferType == SECBUFFER_EXTRA)
351  FIXME("SECBUFFER_EXTRA not supported\n");
352 
353  status = QueryContextAttributesW(&ctx, SECPKG_ATTR_STREAM_SIZES, &conn->ssl_sizes);
354  if(status != SEC_E_OK) {
355  WARN("Could not get sizes\n");
356  break;
357  }
358 
360  if(status == SEC_E_OK) {
361  res = netconn_verify_cert(cert, hostname, security_flags, check_revocation);
363  if(res != ERROR_SUCCESS) {
364  WARN("cert verify failed: %u\n", res);
365  break;
366  }
367  }else {
368  WARN("Could not get cert\n");
369  break;
370  }
371 
372  conn->ssl_buf = heap_alloc(conn->ssl_sizes.cbHeader + conn->ssl_sizes.cbMaximumMessage + conn->ssl_sizes.cbTrailer);
373  if(!conn->ssl_buf) {
374  res = GetLastError();
375  break;
376  }
377  }
378  }
379 
381 
382  if(status != SEC_E_OK || res != ERROR_SUCCESS) {
383  WARN("Failed to initialize security context failed: %08x\n", status);
384  heap_free(conn->ssl_buf);
385  conn->ssl_buf = NULL;
386  DeleteSecurityContext(&ctx);
388  return FALSE;
389  }
390 
391 
392  TRACE("established SSL connection\n");
393  conn->secure = TRUE;
394  conn->ssl_ctx = ctx;
395  return TRUE;
396 }
#define ISC_REQ_SEQUENCE_DETECT
Definition: sspi.h:352
static DWORD netconn_verify_cert(PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags, BOOL check_revocation)
Definition: net.c:60
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
#define ERROR_WINHTTP_SECURE_CHANNEL_ERROR
Definition: winhttp.h:219
BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
Definition: cert.c:371
#define WARN(fmt,...)
Definition: debug.h:111
#define SECPKG_ATTR_REMOTE_CERT_CONTEXT
Definition: schannel.h:69
static SecHandle cred_handle
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LONG_PTR SSIZE_T
Definition: basetsd.h:183
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define SECBUFFER_EXTRA
Definition: sspi.h:151
unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size)
Definition: deflate.c:1167
char * hostname
Definition: ftp.c:88
#define ISC_REQ_MANUAL_CRED_VALIDATION
Definition: sspi.h:368
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define SECBUFFER_EMPTY
Definition: sspi.h:146
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
static BYTE cert[]
Definition: msg.c:1437
LONG SECURITY_STATUS
Definition: sspi.h:34
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
#define ISC_REQ_USE_SESSION_KEY
Definition: sspi.h:354
#define SECPKG_ATTR_STREAM_SIZES
Definition: sspi.h:512
#define ISC_REQ_ALLOCATE_MEMORY
Definition: sspi.h:357
#define SECBUFFER_TOKEN
Definition: sspi.h:148
unsigned char BYTE
Definition: mem.h:68
#define SEC_E_OK
Definition: winerror.h:2356
SECURITY_STATUS WINAPI QueryContextAttributesW(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:535
#define ERR(fmt,...)
Definition: debug.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:78
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:38
#define SECBUFFER_VERSION
Definition: sspi.h:174
ULONG cbBuffer
Definition: sspi.h:140
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
#define ISC_REQ_CONFIDENTIALITY
Definition: sspi.h:353
#define ISC_REQ_REPLAY_DETECT
Definition: sspi.h:351
static int sock_recv(int fd, void *msg, size_t len, int flags)
Definition: net.c:49
static SERVICE_STATUS status
Definition: service.c:31
#define SEC_E_INCOMPLETE_MESSAGE
Definition: winerror.h:2934
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
Definition: ps.c:97

Referenced by open_connection().

◆ netconn_send()

BOOL netconn_send ( struct netconn ,
const void ,
size_t  ,
int  
)

Definition at line 424 of file net.c.

425 {
426  if (conn->secure)
427  {
428  const BYTE *ptr = msg;
429  size_t chunk_size;
430 
431  *sent = 0;
432 
433  while(len) {
434  chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage);
435  if(!send_ssl_chunk(conn, ptr, chunk_size))
436  return FALSE;
437 
438  *sent += chunk_size;
439  ptr += chunk_size;
440  len -= chunk_size;
441  }
442 
443  return TRUE;
444  }
445  return ((*sent = sock_send( conn->socket, msg, len, 0 )) != -1);
446 }
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
Definition: net.c:398
Definition: msg.h:34
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
static int sock_send(int fd, const void *msg, size_t len, int flags)
Definition: net.c:38
#define min(a, b)
Definition: monoChain.cc:55
#define msg(x)
Definition: auth_time.c:54

Referenced by secure_proxy_connect(), send_request(), and write_data().

◆ netconn_set_timeout()

DWORD netconn_set_timeout ( struct netconn ,
BOOL  ,
int   
)

Definition at line 596 of file net.c.

597 {
598  int opt = send ? SO_SNDTIMEO : SO_RCVTIMEO;
599  if (setsockopt( netconn->socket, SOL_SOCKET, opt, (void *)&value, sizeof(value) ) == -1)
600  {
602  WARN("setsockopt failed (%u)\n", err );
603  return err;
604  }
605  return ERROR_SUCCESS;
606 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WARN(fmt,...)
Definition: debug.h:111
#define SOL_SOCKET
Definition: winsock.h:398
INT WSAAPI setsockopt(IN SOCKET s, IN INT level, IN INT optname, IN CONST CHAR FAR *optval, IN INT optlen)
Definition: sockctrl.c:421
#define SO_RCVTIMEO
Definition: winsock.h:193
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
INT WSAAPI send(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags)
Definition: send.c:23
unsigned long DWORD
Definition: ntddk_ex.h:95
#define err(...)
#define SO_SNDTIMEO
Definition: winsock.h:192

Referenced by open_connection(), receive_response(), and WinHttpSetTimeouts().

◆ netconn_unload()

void netconn_unload ( void  )

Definition at line 156 of file net.c.

157 {
158  if (winsock_loaded) WSACleanup();
159 }
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
static BOOL winsock_loaded
Definition: net.c:154

Referenced by DllMain().

◆ process_header()

BOOL process_header ( struct request ,
const WCHAR ,
const WCHAR ,
DWORD  ,
BOOL   
)

Definition at line 430 of file request.c.

431 {
432  int index;
433  struct header hdr;
434 
435  TRACE("%s: %s 0x%08x\n", debugstr_w(field), debugstr_w(value), flags);
436 
437  if ((index = get_header_index( request, field, 0, request_only )) >= 0)
438  {
440  }
441 
443  {
444  if (index >= 0)
445  {
447  if (!value || !value[0]) return TRUE;
448  }
449  else if (!(flags & WINHTTP_ADDREQ_FLAG_ADD))
450  {
452  return FALSE;
453  }
454 
455  hdr.field = (LPWSTR)field;
456  hdr.value = (LPWSTR)value;
457  hdr.is_request = request_only;
458  return insert_header( request, &hdr );
459  }
460  else if (value)
461  {
462 
464  index >= 0)
465  {
466  WCHAR *tmp;
467  int len, len_orig, len_value;
468  struct header *header = &request->headers[index];
469 
470  len_orig = strlenW( header->value );
471  len_value = strlenW( value );
472 
473  len = len_orig + len_value + 2;
474  if (!(tmp = heap_realloc( header->value, (len + 1) * sizeof(WCHAR) ))) return FALSE;
475  header->value = tmp;
476  header->value[len_orig++] = (flags & WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA) ? ',' : ';';
477  header->value[len_orig++] = ' ';
478 
479  memcpy( &header->value[len_orig], value, len_value * sizeof(WCHAR) );
480  header->value[len] = 0;
481  return TRUE;
482  }
483  else
484  {
485  hdr.field = (LPWSTR)field;
486  hdr.value = (LPWSTR)value;
487  hdr.is_request = request_only;
488  return insert_header( request, &hdr );
489  }
490  }
491 
492  return TRUE;
493 }
#define TRUE
Definition: types.h:120
char hdr[14]
Definition: iptest.cpp:33
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WINHTTP_ADDREQ_FLAG_ADD
Definition: winhttp.h:84
static BOOL insert_header(struct request *request, struct header *header)
Definition: request.c:396
#define WINHTTP_ADDREQ_FLAG_REPLACE
Definition: winhttp.h:88
static BOOL delete_header(struct request *request, DWORD index)
Definition: request.c:415
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Definition: winhttp.h:85
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:70
static int get_header_index(struct request *request, const WCHAR *field, int requested_index, BOOL request_only)
Definition: request.c:376
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Definition: winhttp.h:86
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR * value
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
#define SetLastError(x)
Definition: compat.h:417
#define WINHTTP_ADDREQ_FLAG_ADD_IF_NEW
Definition: winhttp.h:83
GLbitfield flags
Definition: glext.h:7161
#define index(s, c)
Definition: various.h:29
struct header * headers
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned int len
Definition: request.c:891
#define ERROR_WINHTTP_HEADER_NOT_FOUND
Definition: winhttp.h:213

Referenced by add_accept_types_header(), add_host_header(), add_request_headers(), do_authorization(), handle_passport_redirect(), read_reply(), and send_request().

◆ release_host()

void release_host ( struct hostdata )

Definition at line 1494 of file request.c.

1495 {
1496  LONG ref;
1497 
1499  if (!(ref = --host->ref)) list_remove( &host->entry );
1501  if (ref) return;
1502 
1503  assert( list_empty( &host->connections ) );
1504  heap_free( host->hostname );
1505  heap_free( host );
1506 }
char * host
Definition: whois.c:55
#define assert(x)
Definition: debug.h:53
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
Definition: send.c:47
static CRITICAL_SECTION connection_pool_cs
Definition: request.c:1483
long LONG
Definition: pedump.c:60
GLenum GLint ref
Definition: glext.h:6028
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
Definition: list.h:143
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by netconn_close(), and open_connection().

◆ release_object()

void release_object ( struct object_header )

Definition at line 72 of file handle.c.

73 {
74  ULONG refs = InterlockedDecrement( &hdr->refs );
75  TRACE("object %p refcount = %d\n", hdr, refs);
76  if (!refs)
77  {
78  if (hdr->type == WINHTTP_HANDLE_TYPE_REQUEST) close_connection( (struct request *)hdr );
79 
81 
82  TRACE("destroying object %p\n", hdr);
83  if (hdr->type != WINHTTP_HANDLE_TYPE_SESSION) list_remove( &hdr->entry );
84  hdr->vtbl->destroy( hdr );
85  }
86 }
#define WINHTTP_HANDLE_TYPE_REQUEST
Definition: winhttp.h:432
char hdr[14]
Definition: iptest.cpp:33
void close_connection(struct request *request)
Definition: request.c:1809
#define WINHTTP_HANDLE_TYPE_SESSION
Definition: winhttp.h:430
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
#define TRACE(s)
Definition: solgame.cpp:4
#define WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING
Definition: winhttp.h:391
#define InterlockedDecrement
Definition: armddk.h:52
void send_callback(struct object_header *hdr, DWORD status, void *info, DWORD buflen)
Definition: session.c:55
Definition: tftpd.h:85
unsigned int ULONG
Definition: retypes.h:1

Referenced by connect_destroy(), free_handle(), request_destroy(), task_proc(), WinHttpAddRequestHeaders(), WinHttpCloseHandle(), WinHttpConnect(), WinHttpGetProxyForUrl(), WinHttpOpen(), WinHttpOpenRequest(), WinHttpQueryAuthSchemes(), WinHttpQueryDataAvailable(), WinHttpQueryHeaders(), WinHttpQueryOption(), WinHttpReadData(), WinHttpReceiveResponse(), WinHttpSendRequest(), WinHttpSetCredentials(), WinHttpSetOption(), WinHttpSetStatusCallback(), WinHttpSetTimeouts(), and WinHttpWriteData().

◆ release_typelib()

void release_typelib ( void  )

Definition at line 159 of file apps.c.

160 {
161  unsigned i;
162 
163  for (i = 0; i < ARRAY_SIZE(typeinfo); i++)
164  if (typeinfo[i])
165  ITypeInfo_Release(typeinfo[i]);
166 
167  if (typelib)
168  ITypeLib_Release(typelib);
169 }
static ITypeLib * typelib
Definition: apps.c:108
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
#define ARRAY_SIZE(a)
Definition: main.h:24

Referenced by DllMain(), and process_detach().

◆ send_callback()

void send_callback ( struct object_header ,
DWORD  ,
LPVOID  ,
DWORD   
)

◆ set_cookies()

BOOL set_cookies ( struct request ,
const WCHAR  
)

Definition at line 263 of file cookie.c.

264 {
265  static const WCHAR pathW[] = {'p','a','t','h',0};
266  static const WCHAR domainW[] = {'d','o','m','a','i','n',0};
267  BOOL ret = FALSE;
268  WCHAR *buffer, *p;
269  WCHAR *cookie_domain = NULL, *cookie_path = NULL;
270  struct attr *attr, *domain = NULL, *path = NULL;
271  struct session *session = request->connect->session;
272  struct cookie *cookie;
273  int len, used;
274 
275  len = strlenW( cookies );
276  if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
277  strcpyW( buffer, cookies );
278 
279  p = buffer;
280  while (*p && *p != ';') p++;
281  if (*p == ';') *p++ = 0;
282  if (!(cookie = parse_cookie( buffer )))
283  {
284  heap_free( buffer );
285  return FALSE;
286  }
287  len = strlenW( p );
288  while (len && (attr = parse_attr( p, &used )))
289  {
290  if (!strcmpiW( attr->name, domainW ))
291  {
292  domain = attr;
293  cookie_domain = attr->value;
294  }
295  else if (!strcmpiW( attr->name, pathW ))
296  {
297  path = attr;
298  cookie_path = attr->value;
299  }
300  else
301  {
302  FIXME( "unhandled attribute %s\n", debugstr_w(attr->name) );
303  free_attr( attr );
304  }
305  len -= used;
306  p += used;
307  }
308  if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end;
309  if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end;
310 
311  if ((p = strrchrW( cookie_path, '/' )) && p != cookie_path) *p = 0;
312  ret = add_cookie( session, cookie, cookie_domain, cookie_path );
313 
314 end:
315  if (!ret) free_cookie( cookie );
316  if (domain) free_attr( domain );
317  else heap_free( cookie_domain );
318  if (path) free_attr( path );
319  else heap_free( cookie_path );
320  heap_free( buffer );
321  return ret;
322 }
struct connect * connect
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
WCHAR * value
Definition: cookie.c:204
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
Definition: cookie.c:41
static void free_attr(struct attr *attr)
Definition: cookie.c:207
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
char path[256]
Definition: tftpd.h:94
smooth NULL
Definition: ftsmooth.c:416
static BOOL add_cookie(struct session *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path)
Definition: cookie.c:132
c used
Definition: write.c:2877
__wchar_t WCHAR
Definition: xmlstorage.h:180
static struct cookie * parse_cookie(const WCHAR *string)
Definition: cookie.c:162
Definition: cookie.c:201
int ret
static CookieInternal * cookies
Definition: msctf.c:65
__u8 attr
Definition: mkdosfs.c:359
GLenum GLsizei len
Definition: glext.h:6722
static struct attr * parse_attr(const WCHAR *str, int *used)
Definition: cookie.c:215
#define strcmpiW(s1, s2)
Definition: unicode.h:39
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static void free_cookie(struct cookie *cookie)
Definition: cookie.c:90
Definition: cookie.c:33
Definition: tftpd.h:85
WCHAR * name
Definition: cookie.c:203
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by record_cookies().

◆ set_server_for_hostname()

BOOL set_server_for_hostname ( struct connect ,
const WCHAR ,
INTERNET_PORT   
)

Definition at line 476 of file session.c.

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  {
492  if (!(connect->servername = heap_alloc(
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  }
534 end:
535  return ret;
536 }
#define TRUE
Definition: types.h:120
static rfbScreenInfoPtr server
Definition: vnc.c:74
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:248
WCHAR * proxy_server
struct session * session
GLuint GLuint end
Definition: gl.h:1545
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
INTERNET_PORT serverport
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL should_bypass_proxy(struct session *session, LPCWSTR server)
Definition: session.c:445
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define strcmpiW(s1, s2)
Definition: unicode.h:39
#define INTERNET_DEFAULT_PORT
Definition: winhttp.h:35
WCHAR * servername
USHORT port
Definition: uri.c:228
WINE_UNICODE_INLINE int atoiW(const WCHAR *str)
Definition: unicode.h:315
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by handle_redirect(), and WinHttpConnect().

◆ strdupAW()

static WCHAR* strdupAW ( const char src)
inlinestatic

Definition at line 316 of file winhttp_private.h.

317 {
318  WCHAR *dst = NULL;
319  if (src)
320  {
321  DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
322  if ((dst = heap_alloc( len * sizeof(WCHAR) )))
323  MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
324  }
325  return dst;
326 }
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define MultiByteToWideChar
Definition: compat.h:100

◆ strdupW()

static WCHAR* strdupW ( const WCHAR src)
inlinestatic

Definition at line 306 of file winhttp_private.h.

307 {
308  WCHAR *dst;
309 
310  if (!src) return NULL;
311  dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
312  if (dst) strcpyW( dst, src );
313  return dst;
314 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum src
Definition: glext.h:6340
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
GLenum GLenum dst
Definition: glext.h:6340

◆ strdupWA()

static char* strdupWA ( const WCHAR src)
inlinestatic

Definition at line 328 of file winhttp_private.h.

329 {
330  char *dst = NULL;
331  if (src)
332  {
333  int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
334  if ((dst = heap_alloc( len )))
335  WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
336  }
337  return dst;
338 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

◆ strdupWA_sized()

static char* strdupWA_sized ( const WCHAR src,
DWORD  size 
)
inlinestatic

Definition at line 340 of file winhttp_private.h.

341 {
342  char *dst = NULL;
343  if (src)
344  {
345  int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
346  if ((dst = heap_alloc( len )))
347  {
349  dst[len - 1] = 0;
350  }
351  }
352  return dst;
353 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by run_script().

◆ WinHttpRequest_create()

HRESULT WinHttpRequest_create ( void **  )

Definition at line 4782 of file request.c.

4783 {
4784  struct winhttp_request *request;
4785 
4786  TRACE("%p\n", obj);
4787 
4788  if (!(request = heap_alloc_zero( sizeof(*request) ))) return E_OUTOFMEMORY;
4789  request->IWinHttpRequest_iface.lpVtbl = &winhttp_request_vtbl;
4790  request->refs = 1;
4792  request->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": winhttp_request.cs");
4794 
4795  *obj = &request->IWinHttpRequest_iface;
4796  TRACE("returning iface %p\n", *obj);
4797  return S_OK;
4798 }
#define DWORD_PTR
Definition: treelist.c:76
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
static const struct IWinHttpRequestVtbl winhttp_request_vtbl
Definition: request.c:4752
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:59
Definition: tftpd.h:85
static void initialize_request(struct winhttp_request *request)
Definition: request.c:3589

Variable Documentation

◆ chunkedW

const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0}
static

Definition at line 40 of file winhttp_private.h.

Referenced by set_content_length().

◆ DECLSPEC_HIDDEN

HINSTANCE winhttp_instance DECLSPEC_HIDDEN

Definition at line 155 of file crypt32_private.h.

◆ getW

const WCHAR getW[] = {'G','E','T',0}
static

Definition at line 34 of file winhttp_private.h.

◆ headW

const WCHAR headW[] = {'H','E','A','D',0}
static

Definition at line 36 of file winhttp_private.h.

◆ http1_0

const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0}
static

Definition at line 38 of file winhttp_private.h.

Referenced by finished_reading().

◆ http1_1

const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0}
static

Definition at line 39 of file winhttp_private.h.

Referenced by build_proxy_connect_string(), and WinHttpOpenRequest().

◆ postW

const WCHAR postW[] = {'P','O','S','T',0}
static

◆ size

Initial value:
{
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
#define HeapReAlloc
Definition: compat.h:401
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
Definition: mem.c:156

Definition at line 302 of file winhttp_private.h.

◆ slashW

const WCHAR slashW[] = {'/',0}
static

Definition at line 37 of file winhttp_private.h.