ReactOS  0.4.15-dev-5131-g311fcc6
rpc_transport.c File Reference
#include "ntstatus.h"
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winerror.h"
#include "wininet.h"
#include "wine/winternl.h"
#include "winioctl.h"
#include "rpc.h"
#include "rpcndr.h"
#include "wine/debug.h"
#include "rpc_binding.h"
#include "rpc_assoc.h"
#include "rpc_message.h"
#include "rpc_server.h"
#include "epm_towers.h"
Include dependency graph for rpc_transport.c:

Go to the source code of this file.

Classes

struct  _RpcConnection_np
 
struct  _RpcServerProtseq_np
 
struct  _RpcConnection_tcp
 
struct  _RpcServerProtseq_sock
 
struct  _RpcHttpAsyncData
 
struct  authinfo
 
struct  _RpcConnection_http
 
struct  _HttpTimerThreadData
 

Macros

#define WIN32_NO_STATUS
 
#define DEFAULT_NCACN_HTTP_TIMEOUT   (60 * 1000)
 
#define HTTP_IDLE_TIME   60000
 

Typedefs

typedef struct _RpcConnection_np RpcConnection_np
 
typedef struct _RpcServerProtseq_np RpcServerProtseq_np
 
typedef struct _RpcConnection_tcp RpcConnection_tcp
 
typedef struct _RpcServerProtseq_sock RpcServerProtseq_sock
 
typedef struct _RpcHttpAsyncData RpcHttpAsyncData
 
typedef struct _RpcConnection_http RpcConnection_http
 
typedef struct _HttpTimerThreadData HttpTimerThreadData
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (rpc)
 
static RpcConnectionrpcrt4_spawn_connection (RpcConnection *old_connection)
 
static RpcConnectionrpcrt4_conn_np_alloc (void)
 
static HANDLE get_np_event (RpcConnection_np *connection)
 
static void release_np_event (RpcConnection_np *connection, HANDLE event)
 
static RPC_STATUS rpcrt4_conn_create_pipe (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_conn_open_pipe (RpcConnection *Connection, LPCSTR pname, BOOL wait)
 
static charncalrpc_pipe_name (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_protseq_ncalrpc_open_endpoint (RpcServerProtseq *protseq, const char *endpoint)
 
static charncacn_pipe_name (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncacn_np_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_protseq_ncacn_np_open_endpoint (RpcServerProtseq *protseq, const char *endpoint)
 
static void rpcrt4_conn_np_handoff (RpcConnection_np *old_npc, RpcConnection_np *new_npc)
 
static RPC_STATUS rpcrt4_ncacn_np_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static RPC_STATUS is_pipe_listening (const char *pipe_name)
 
static RPC_STATUS rpcrt4_ncacn_np_is_server_listening (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_np_is_server_listening (const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static int rpcrt4_conn_np_read (RpcConnection *conn, void *buffer, unsigned int count)
 
static int rpcrt4_conn_np_write (RpcConnection *conn, const void *buffer, unsigned int count)
 
static int rpcrt4_conn_np_close (RpcConnection *conn)
 
static void rpcrt4_conn_np_close_read (RpcConnection *conn)
 
static void rpcrt4_conn_np_cancel_call (RpcConnection *conn)
 
static int rpcrt4_conn_np_wait_for_incoming_data (RpcConnection *conn)
 
static size_t rpcrt4_ncacn_np_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RPC_STATUS rpcrt4_ncacn_np_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
static RPC_STATUS rpcrt4_conn_np_impersonate_client (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_conn_np_revert_to_self (RpcConnection *conn)
 
static RpcServerProtseqrpcrt4_protseq_np_alloc (void)
 
static void rpcrt4_protseq_np_signal_state_changed (RpcServerProtseq *protseq)
 
static voidrpcrt4_protseq_np_get_wait_array (RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
 
static void rpcrt4_protseq_np_free_wait_array (RpcServerProtseq *protseq, void *array)
 
static int rpcrt4_protseq_np_wait_for_new_connection (RpcServerProtseq *protseq, unsigned int count, void *wait_array)
 
static size_t rpcrt4_ncalrpc_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RPC_STATUS rpcrt4_ncalrpc_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
static BOOL rpcrt4_ncalrpc_is_authorized (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_ncalrpc_authorize (RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size)
 
static RPC_STATUS rpcrt4_ncalrpc_secure_packet (RpcConnection *conn, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size)
 
static RPC_STATUS rpcrt4_ncalrpc_inquire_auth_client (RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
 
static size_t rpcrt4_ip_tcp_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, unsigned char tcp_protid, const char *endpoint)
 
static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, unsigned char tcp_protid, char **endpoint)
 
static BOOL rpcrt4_sock_wait_init (RpcConnection_tcp *tcpc)
 
static BOOL rpcrt4_sock_wait_for_recv (RpcConnection_tcp *tcpc)
 
static BOOL rpcrt4_sock_wait_for_send (RpcConnection_tcp *tcpc)
 
static RpcConnectionrpcrt4_conn_tcp_alloc (void)
 
static RPC_STATUS rpcrt4_ncacn_ip_tcp_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_protseq_ncacn_ip_tcp_open_endpoint (RpcServerProtseq *protseq, const char *endpoint)
 
static RPC_STATUS rpcrt4_conn_tcp_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static int rpcrt4_conn_tcp_read (RpcConnection *Connection, void *buffer, unsigned int count)
 
static int rpcrt4_conn_tcp_write (RpcConnection *Connection, const void *buffer, unsigned int count)
 
static int rpcrt4_conn_tcp_close (RpcConnection *conn)
 
static void rpcrt4_conn_tcp_close_read (RpcConnection *conn)
 
static void rpcrt4_conn_tcp_cancel_call (RpcConnection *conn)
 
static RPC_STATUS rpcrt4_conn_tcp_is_server_listening (const char *endpoint)
 
static int rpcrt4_conn_tcp_wait_for_incoming_data (RpcConnection *Connection)
 
static size_t rpcrt4_ncacn_ip_tcp_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RpcServerProtseqrpcrt4_protseq_sock_alloc (void)
 
static void rpcrt4_protseq_sock_signal_state_changed (RpcServerProtseq *protseq)
 
static voidrpcrt4_protseq_sock_get_wait_array (RpcServerProtseq *protseq, void *prev_array, unsigned int *count)
 
static void rpcrt4_protseq_sock_free_wait_array (RpcServerProtseq *protseq, void *array)
 
static int rpcrt4_protseq_sock_wait_for_new_connection (RpcServerProtseq *protseq, unsigned int count, void *wait_array)
 
static RPC_STATUS rpcrt4_ncacn_ip_tcp_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
static ULONG RpcHttpAsyncData_AddRef (RpcHttpAsyncData *data)
 
static ULONG RpcHttpAsyncData_Release (RpcHttpAsyncData *data)
 
static void prepare_async_request (RpcHttpAsyncData *async_data)
 
static RPC_STATUS wait_async_request (RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
 
static RpcConnectionrpcrt4_ncacn_http_alloc (void)
 
static VOID rpcrt4_http_keep_connection_active_timer_proc (PVOID param, BOOLEAN dummy)
 
static DWORD rpcrt4_http_timer_calc_timeout (DWORD *last_sent_time)
 
static DWORD CALLBACK rpcrt4_http_timer_thread (PVOID param)
 
static VOID WINAPI rpcrt4_http_internet_callback (HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
 
static RPC_STATUS rpcrt4_http_check_response (HINTERNET hor)
 
static RPC_STATUS rpcrt4_http_internet_connect (RpcConnection_http *httpc)
 
static int rpcrt4_http_async_read (HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
 
static RPC_STATUS send_echo_request (HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
 
static RPC_STATUS insert_content_length_header (HINTERNET request, DWORD len)
 
static RPC_STATUS rpcrt4_http_prepare_in_pipe (HINTERNET in_request, RpcHttpAsyncData *async_data, HANDLE cancel_event, const UUID *connection_uuid, const UUID *in_pipe_uuid, const UUID *association_uuid, BOOL authorized)
 
static RPC_STATUS rpcrt4_http_read_http_packet (HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
 
static RPC_STATUS rpcrt4_http_prepare_out_pipe (HINTERNET out_request, RpcHttpAsyncData *async_data, HANDLE cancel_event, const UUID *connection_uuid, const UUID *out_pipe_uuid, ULONG *flow_control_increment, BOOL authorized)
 
static UINT encode_base64 (const char *bin, unsigned int len, WCHAR *base64)
 
static char decode_char (WCHAR c)
 
static unsigned int decode_base64 (const WCHAR *base64, unsigned int len, char *buf)
 
static struct authinfoalloc_authinfo (void)
 
static void destroy_authinfo (struct authinfo *info)
 
static DWORD auth_scheme_from_header (const WCHAR *header)
 
static BOOL get_authvalue (HINTERNET request, DWORD scheme, WCHAR *buffer, DWORD buflen)
 
static RPC_STATUS do_authorization (HINTERNET request, SEC_WCHAR *servername, const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
 
static RPC_STATUS insert_authorization_header (HINTERNET request, ULONG scheme, char *data, int data_len)
 
static void drain_content (HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
 
static RPC_STATUS authorize_request (RpcConnection_http *httpc, HINTERNET request)
 
static BOOL has_credentials (RpcConnection_http *httpc)
 
static BOOL is_secure (RpcConnection_http *httpc)
 
static RPC_STATUS set_auth_cookie (RpcConnection_http *httpc, const WCHAR *value)
 
static RPC_STATUS rpcrt4_ncacn_http_open (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_ncacn_http_handoff (RpcConnection *old_conn, RpcConnection *new_conn)
 
static int rpcrt4_ncacn_http_read (RpcConnection *Connection, void *buffer, unsigned int count)
 
static RPC_STATUS rpcrt4_ncacn_http_receive_fragment (RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
 
static int rpcrt4_ncacn_http_write (RpcConnection *Connection, const void *buffer, unsigned int count)
 
static int rpcrt4_ncacn_http_close (RpcConnection *Connection)
 
static void rpcrt4_ncacn_http_close_read (RpcConnection *conn)
 
static void rpcrt4_ncacn_http_cancel_call (RpcConnection *Connection)
 
static RPC_STATUS rpcrt4_ncacn_http_is_server_listening (const char *endpoint)
 
static int rpcrt4_ncacn_http_wait_for_incoming_data (RpcConnection *Connection)
 
static size_t rpcrt4_ncacn_http_get_top_of_tower (unsigned char *tower_data, const char *networkaddr, const char *endpoint)
 
static RPC_STATUS rpcrt4_ncacn_http_parse_top_of_tower (const unsigned char *tower_data, size_t tower_size, char **networkaddr, char **endpoint)
 
const struct protseq_opsrpcrt4_get_protseq_ops (const char *protseq)
 
static const struct connection_opsrpcrt4_get_conn_protseq_ops (const char *protseq)
 
RPC_STATUS RPCRT4_OpenClientConnection (RpcConnection *Connection)
 
RPC_STATUS RPCRT4_CloseConnection (RpcConnection *Connection)
 
RPC_STATUS RPCRT4_CreateConnection (RpcConnection **Connection, BOOL server, LPCSTR Protseq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCWSTR NetworkOptions, RpcAuthInfo *AuthInfo, RpcQualityOfService *QOS, LPCWSTR CookieAuth)
 
void rpcrt4_conn_release_and_wait (RpcConnection *connection)
 
RpcConnectionRPCRT4_GrabConnection (RpcConnection *connection)
 
void RPCRT4_ReleaseConnection (RpcConnection *connection)
 
RPC_STATUS RPCRT4_IsServerListening (const char *protseq, const char *endpoint)
 
RPC_STATUS RpcTransport_GetTopOfTower (unsigned char *tower_data, size_t *tower_size, const char *protseq, const char *networkaddr, const char *endpoint)
 
RPC_STATUS RpcTransport_ParseTopOfTower (const unsigned char *tower_data, size_t tower_size, char **protseq, char **networkaddr, char **endpoint)
 
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW (RPC_WSTR protseq)
 
RPC_STATUS WINAPI RpcNetworkIsProtseqValidA (RPC_CSTR protseq)
 
RPC_STATUS WINAPI RpcProtseqVectorFreeA (RPC_PROTSEQ_VECTORA **protseqs)
 
RPC_STATUS WINAPI RpcProtseqVectorFreeW (RPC_PROTSEQ_VECTORW **protseqs)
 
RPC_STATUS WINAPI RpcNetworkInqProtseqsW (RPC_PROTSEQ_VECTORW **protseqs)
 
RPC_STATUS WINAPI RpcNetworkInqProtseqsA (RPC_PROTSEQ_VECTORA **protseqs)
 

Variables

static const WCHAR basicW [] = {'B','a','s','i','c',0}
 
static const WCHAR ntlmW [] = {'N','T','L','M',0}
 
static const WCHAR passportW [] = {'P','a','s','s','p','o','r','t',0}
 
static const WCHAR digestW [] = {'D','i','g','e','s','t',0}
 
static const WCHAR negotiateW [] = {'N','e','g','o','t','i','a','t','e',0}
 
struct {
   const WCHAR *   str
 
   unsigned int   len
 
   DWORD   scheme
 
auth_schemes []
 
static const struct connection_ops conn_protseq_list []
 
static const struct protseq_ops protseq_list []
 

Macro Definition Documentation

◆ DEFAULT_NCACN_HTTP_TIMEOUT

#define DEFAULT_NCACN_HTTP_TIMEOUT   (60 * 1000)

Definition at line 57 of file rpc_transport.c.

◆ HTTP_IDLE_TIME

#define HTTP_IDLE_TIME   60000

Definition at line 1963 of file rpc_transport.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 27 of file rpc_transport.c.

Typedef Documentation

◆ HttpTimerThreadData

◆ RpcConnection_http

◆ RpcConnection_np

◆ RpcConnection_tcp

◆ RpcHttpAsyncData

◆ RpcServerProtseq_np

◆ RpcServerProtseq_sock

Function Documentation

◆ alloc_authinfo()

static struct authinfo* alloc_authinfo ( void  )
static

Definition at line 2673 of file rpc_transport.c.

2674 {
2675  struct authinfo *ret;
2676 
2677  if (!(ret = HeapAlloc(GetProcessHeap(), 0, sizeof(*ret) ))) return NULL;
2678 
2679  SecInvalidateHandle(&ret->cred);
2680  SecInvalidateHandle(&ret->ctx);
2681  memset(&ret->exp, 0, sizeof(ret->exp));
2682  ret->scheme = 0;
2683  ret->attr = 0;
2684  ret->max_token = 0;
2685  ret->data = NULL;
2686  ret->data_len = 0;
2687  ret->finished = FALSE;
2688  return ret;
2689 }
#define SecInvalidateHandle(x)
Definition: sspi.h:58
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
#define NULL
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39

Referenced by do_authorization().

◆ auth_scheme_from_header()

static DWORD auth_scheme_from_header ( const WCHAR header)
static

Definition at line 2725 of file rpc_transport.c.

2726 {
2727  unsigned int i;
2728  for (i = 0; i < ARRAY_SIZE(auth_schemes); i++)
2729  {
2731  (header[auth_schemes[i].len] == ' ' || !header[auth_schemes[i].len])) return auth_schemes[i].scheme;
2732  }
2733  return 0;
2734 }
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
const WCHAR * str
GLenum GLsizei len
Definition: glext.h:6722
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
static const struct @525 auth_schemes[]

Referenced by do_authorization(), and get_authvalue().

◆ authorize_request()

static RPC_STATUS authorize_request ( RpcConnection_http httpc,
HINTERNET  request 
)
static

Definition at line 2957 of file rpc_transport.c.

2958 {
2959  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':','\r','\n',0};
2960  struct authinfo *info = NULL;
2962  BOOL ret;
2963 
2964  for (;;)
2965  {
2967  if (status != RPC_S_OK) break;
2968 
2969  status = insert_authorization_header(request, info->scheme, info->data, info->data_len);
2970  if (status != RPC_S_OK) break;
2971 
2973  ret = HttpSendRequestW(request, NULL, 0, NULL, 0);
2975  if (status != RPC_S_OK || info->finished) break;
2976 
2978  if (status != RPC_S_OK && status != ERROR_ACCESS_DENIED) break;
2979  drain_content(request, httpc->async_data, httpc->cancel_event);
2980  }
2981 
2982  if (info->scheme != RPC_C_HTTP_AUTHN_SCHEME_BASIC)
2984 
2986  return status;
2987 }
static void drain_content(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event)
union _RPC_SECURITY_QOS_V2_W::@3167 u
RpcConnection common
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
long RPC_STATUS
Definition: rpc.h:52
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5595
static RPC_STATUS insert_authorization_header(HINTERNET request, ULONG scheme, char *data, int data_len)
static void prepare_async_request(RpcHttpAsyncData *async_data)
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
static RPC_STATUS do_authorization(HINTERNET request, SEC_WCHAR *servername, const RPC_HTTP_TRANSPORT_CREDENTIALS_W *creds, struct authinfo **auth_ptr)
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1297
static void destroy_authinfo(struct authinfo *info)
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
RpcHttpAsyncData * async_data
#define NULL
Definition: types.h:112
Definition: tftpd.h:85
static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by rpcrt4_ncacn_http_open().

◆ decode_base64()

static unsigned int decode_base64 ( const WCHAR base64,
unsigned int  len,
char buf 
)
static

Definition at line 2611 of file rpc_transport.c.

2612 {
2613  unsigned int i = 0;
2614  char c0, c1, c2, c3;
2615  const WCHAR *p = base64;
2616 
2617  while (len > 4)
2618  {
2619  if ((c0 = decode_char( p[0] )) > 63) return 0;
2620  if ((c1 = decode_char( p[1] )) > 63) return 0;
2621  if ((c2 = decode_char( p[2] )) > 63) return 0;
2622  if ((c3 = decode_char( p[3] )) > 63) return 0;
2623 
2624  if (buf)
2625  {
2626  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2627  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2628  buf[i + 2] = (c2 << 6) | c3;
2629  }
2630  len -= 4;
2631  i += 3;
2632  p += 4;
2633  }
2634  if (p[2] == '=')
2635  {
2636  if ((c0 = decode_char( p[0] )) > 63) return 0;
2637  if ((c1 = decode_char( p[1] )) > 63) return 0;
2638 
2639  if (buf) buf[i] = (c0 << 2) | (c1 >> 4);
2640  i++;
2641  }
2642  else if (p[3] == '=')
2643  {
2644  if ((c0 = decode_char( p[0] )) > 63) return 0;
2645  if ((c1 = decode_char( p[1] )) > 63) return 0;
2646  if ((c2 = decode_char( p[2] )) > 63) return 0;
2647 
2648  if (buf)
2649  {
2650  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2651  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2652  }
2653  i += 2;
2654  }
2655  else
2656  {
2657  if ((c0 = decode_char( p[0] )) > 63) return 0;
2658  if ((c1 = decode_char( p[1] )) > 63) return 0;
2659  if ((c2 = decode_char( p[2] )) > 63) return 0;
2660  if ((c3 = decode_char( p[3] )) > 63) return 0;
2661 
2662  if (buf)
2663  {
2664  buf[i + 0] = (c0 << 2) | (c1 >> 4);
2665  buf[i + 1] = (c1 << 4) | (c2 >> 2);
2666  buf[i + 2] = (c2 << 6) | c3;
2667  }
2668  i += 3;
2669  }
2670  return i;
2671 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
static char decode_char(WCHAR c)
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
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by do_authorization().

◆ decode_char()

static char decode_char ( WCHAR  c)
inlinestatic

Definition at line 2601 of file rpc_transport.c.

2602 {
2603  if (c >= 'A' && c <= 'Z') return c - 'A';
2604  if (c >= 'a' && c <= 'z') return c - 'a' + 26;
2605  if (c >= '0' && c <= '9') return c - '0' + 52;
2606  if (c == '+') return 62;
2607  if (c == '/') return 63;
2608  return 64;
2609 }
const GLubyte * c
Definition: glext.h:8905

Referenced by decode_base64().

◆ destroy_authinfo()

static void destroy_authinfo ( struct authinfo info)
static

Definition at line 2691 of file rpc_transport.c.

2692 {
2693  if (!info) return;
2694 
2695  if (SecIsValidHandle(&info->ctx))
2696  DeleteSecurityContext(&info->ctx);
2697  if (SecIsValidHandle(&info->cred))
2698  FreeCredentialsHandle(&info->cred);
2699 
2700  HeapFree(GetProcessHeap(), 0, info->data);
2701  HeapFree(GetProcessHeap(), 0, info);
2702 }
#define SecIsValidHandle(x)
Definition: sspi.h:63
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151
#define GetProcessHeap()
Definition: compat.h:595
#define HeapFree(x, y, z)
Definition: compat.h:594
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450

Referenced by authorize_request(), do_authorization(), and request_destroy().

◆ do_authorization()

static RPC_STATUS do_authorization ( HINTERNET  request,
SEC_WCHAR servername,
const RPC_HTTP_TRANSPORT_CREDENTIALS_W creds,
struct authinfo **  auth_ptr 
)
static

Definition at line 2748 of file rpc_transport.c.

2750 {
2751  struct authinfo *info = *auth_ptr;
2754 
2755  if ((!info && !(info = alloc_authinfo()))) return RPC_S_SERVER_UNAVAILABLE;
2756 
2757  switch (creds->AuthnSchemes[0])
2758  {
2760  {
2761  int userlen = WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, NULL, 0, NULL, NULL);
2762  int passlen = WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, NULL, 0, NULL, NULL);
2763 
2764  info->data_len = userlen + passlen + 1;
2765  if (!(info->data = HeapAlloc(GetProcessHeap(), 0, info->data_len)))
2766  {
2768  break;
2769  }
2770  WideCharToMultiByte(CP_UTF8, 0, id->User, id->UserLength, info->data, userlen, NULL, NULL);
2771  info->data[userlen] = ':';
2772  WideCharToMultiByte(CP_UTF8, 0, id->Password, id->PasswordLength, info->data + userlen + 1, passlen, NULL, NULL);
2773 
2775  info->finished = TRUE;
2776  status = RPC_S_OK;
2777  break;
2778  }
2781  {
2782 
2783  static SEC_WCHAR ntlmW[] = {'N','T','L','M',0}, negotiateW[] = {'N','e','g','o','t','i','a','t','e',0};
2785  SecBufferDesc out_desc, in_desc;
2786  SecBuffer out, in;
2788  SEC_WCHAR *scheme;
2789  int scheme_len;
2790  const WCHAR *p;
2791  WCHAR auth_value[2048];
2792  DWORD size = sizeof(auth_value);
2793  BOOL first = FALSE;
2794 
2796  else scheme = negotiateW;
2797  scheme_len = lstrlenW( scheme );
2798 
2799  if (!*auth_ptr)
2800  {
2801  TimeStamp exp;
2802  SecPkgInfoW *pkg_info;
2803 
2805  if (ret != SEC_E_OK) break;
2806 
2807  ret = QuerySecurityPackageInfoW(scheme, &pkg_info);
2808  if (ret != SEC_E_OK) break;
2809 
2810  info->max_token = pkg_info->cbMaxToken;
2811  FreeContextBuffer(pkg_info);
2812  first = TRUE;
2813  }
2814  else
2815  {
2816  if (info->finished || !get_authvalue(request, creds->AuthnSchemes[0], auth_value, size)) break;
2817  if (auth_scheme_from_header(auth_value) != info->scheme)
2818  {
2819  ERR("authentication scheme changed\n");
2820  break;
2821  }
2822  }
2823  in.BufferType = SECBUFFER_TOKEN;
2824  in.cbBuffer = 0;
2825  in.pvBuffer = NULL;
2826 
2827  in_desc.ulVersion = 0;
2828  in_desc.cBuffers = 1;
2829  in_desc.pBuffers = &in;
2830 
2831  p = auth_value + scheme_len;
2832  if (!first && *p == ' ')
2833  {
2834  int len = lstrlenW(++p);
2835  in.cbBuffer = decode_base64(p, len, NULL);
2836  if (!(in.pvBuffer = HeapAlloc(GetProcessHeap(), 0, in.cbBuffer))) break;
2837  decode_base64(p, len, in.pvBuffer);
2838  }
2839  out.BufferType = SECBUFFER_TOKEN;
2840  out.cbBuffer = info->max_token;
2841  if (!(out.pvBuffer = HeapAlloc(GetProcessHeap(), 0, out.cbBuffer)))
2842  {
2843  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2844  break;
2845  }
2846  out_desc.ulVersion = 0;
2847  out_desc.cBuffers = 1;
2848  out_desc.pBuffers = &out;
2849 
2850  ret = InitializeSecurityContextW(first ? &info->cred : NULL, first ? NULL : &info->ctx,
2851  first ? servername : NULL, flags, 0, SECURITY_NETWORK_DREP,
2852  in.pvBuffer ? &in_desc : NULL, 0, &info->ctx, &out_desc,
2853  &info->attr, &info->exp);
2854  HeapFree(GetProcessHeap(), 0, in.pvBuffer);
2855  if (ret == SEC_E_OK)
2856  {
2857  HeapFree(GetProcessHeap(), 0, info->data);
2858  info->data = out.pvBuffer;
2859  info->data_len = out.cbBuffer;
2860  info->finished = TRUE;
2861  TRACE("sending last auth packet\n");
2862  status = RPC_S_OK;
2863  }
2864  else if (ret == SEC_I_CONTINUE_NEEDED)
2865  {
2866  HeapFree(GetProcessHeap(), 0, info->data);
2867  info->data = out.pvBuffer;
2868  info->data_len = out.cbBuffer;
2869  TRACE("sending next auth packet\n");
2870  status = RPC_S_OK;
2871  }
2872  else
2873  {
2874  ERR("InitializeSecurityContextW failed with error 0x%08x\n", ret);
2875  HeapFree(GetProcessHeap(), 0, out.pvBuffer);
2876  break;
2877  }
2878  info->scheme = creds->AuthnSchemes[0];
2879  break;
2880  }
2881  default:
2882  FIXME("scheme %u not supported\n", creds->AuthnSchemes[0]);
2883  break;
2884  }
2885 
2886  if (status != RPC_S_OK)
2887  {
2889  *auth_ptr = NULL;
2890  return status;
2891  }
2892  *auth_ptr = info;
2893  return RPC_S_OK;
2894 }
static struct authinfo * alloc_authinfo(void)
#define SECPKG_CRED_OUTBOUND
Definition: sspi.h:291
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
static DWORD auth_scheme_from_header(const WCHAR *header)
#define WideCharToMultiByte
Definition: compat.h:111
SECURITY_STATUS WINAPI AcquireCredentialsHandleW(SEC_WCHAR *pszPrincipal, SEC_WCHAR *pszPackage, ULONG fCredentialsUse, PLUID pvLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn, PVOID pvGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
Definition: wrapper.c:105
WCHAR SEC_WCHAR
Definition: sspi.h:29
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
Definition: sspi.c:699
#define TRUE
Definition: types.h:120
ULONG ulVersion
Definition: sspi.h:181
const GLint * first
Definition: glext.h:5794
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
DWORD scheme
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define ISC_REQ_DELEGATE
Definition: sspi.h:362
#define lstrlenW
Definition: compat.h:609
static const WCHAR negotiateW[]
long RPC_STATUS
Definition: rpc.h:52
#define FALSE
Definition: types.h:117
#define CP_UTF8
Definition: nls.h:20
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG cbMaxToken
Definition: sspi.h:117
static struct _test_info info[]
Definition: SetCursorPos.c:19
#define FIXME(fmt,...)
Definition: debug.h:111
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:2927
static const WCHAR ntlmW[]
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
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define RPC_C_HTTP_AUTHN_SCHEME_NTLM
Definition: rpcdce.h:206
int ret
#define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE
Definition: rpcdce.h:209
#define SECBUFFER_TOKEN
Definition: sspi.h:161
GLenum GLsizei len
Definition: glext.h:6722
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:371
static void destroy_authinfo(struct authinfo *info)
#define SECURITY_NETWORK_DREP
Definition: sspi.h:474
#define SEC_E_OK
Definition: winerror.h:2356
#define ISC_REQ_CONNECTION
Definition: sspi.h:373
#define ERR(fmt,...)
Definition: debug.h:110
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112
DWORD exp
Definition: msg.c:16033
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:363
static unsigned int decode_base64(const WCHAR *base64, unsigned int len, char *buf)
Definition: tftpd.h:85
unsigned int ULONG
Definition: retypes.h:1
GLenum GLuint id
Definition: glext.h:5579
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL get_authvalue(HINTERNET request, DWORD scheme, WCHAR *buffer, DWORD buflen)
ULONG cBuffers
Definition: sspi.h:182
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:594
SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, PSecPkgInfoW *ppPackageInfo)
Definition: wrapper.c:750
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by authorize_request().

◆ drain_content()

static void drain_content ( HINTERNET  request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event 
)
static

Definition at line 2942 of file rpc_transport.c.

2943 {
2944  DWORD count, len = 0, size = sizeof(len);
2945  char buf[2048];
2946 
2948  if (!len) return;
2949  for (;;)
2950  {
2951  count = min(sizeof(buf), len);
2952  if (rpcrt4_http_async_read(request, async_data, cancel_event, buf, count) <= 0) return;
2953  len -= count;
2954  }
2955 }
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int len
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
GLenum GLsizei len
Definition: glext.h:6722
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
Definition: tftpd.h:85

Referenced by authorize_request(), and rpcrt4_ncacn_http_open().

◆ encode_base64()

static UINT encode_base64 ( const char bin,
unsigned int  len,
WCHAR base64 
)
static

Definition at line 2561 of file rpc_transport.c.

2562 {
2563  static const char enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2564  UINT i = 0, x;
2565 
2566  while (len > 0)
2567  {
2568  /* first 6 bits, all from bin[0] */
2569  base64[i++] = enc[(bin[0] & 0xfc) >> 2];
2570  x = (bin[0] & 3) << 4;
2571 
2572  /* next 6 bits, 2 from bin[0] and 4 from bin[1] */
2573  if (len == 1)
2574  {
2575  base64[i++] = enc[x];
2576  base64[i++] = '=';
2577  base64[i++] = '=';
2578  break;
2579  }
2580  base64[i++] = enc[x | ((bin[1] & 0xf0) >> 4)];
2581  x = (bin[1] & 0x0f) << 2;
2582 
2583  /* next 6 bits 4 from bin[1] and 2 from bin[2] */
2584  if (len == 2)
2585  {
2586  base64[i++] = enc[x];
2587  base64[i++] = '=';
2588  break;
2589  }
2590  base64[i++] = enc[x | ((bin[2] & 0xc0) >> 6)];
2591 
2592  /* last 6 bits, all from bin [2] */
2593  base64[i++] = enc[bin[2] & 0x3f];
2594  bin += 3;
2595  len -= 3;
2596  }
2597  base64[i] = 0;
2598  return i;
2599 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLenum GLsizei len
Definition: glext.h:6722
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
unsigned int UINT
Definition: ndis.h:50
static struct _PeImage bin

Referenced by insert_authorization_header().

◆ get_authvalue()

static BOOL get_authvalue ( HINTERNET  request,
DWORD  scheme,
WCHAR buffer,
DWORD  buflen 
)
static

Definition at line 2736 of file rpc_transport.c.

2737 {
2738  DWORD len, index = 0;
2739  for (;;)
2740  {
2741  len = buflen;
2743  if (auth_scheme_from_header(buffer) == scheme) break;
2744  }
2745  return TRUE;
2746 }
static DWORD auth_scheme_from_header(const WCHAR *header)
#define TRUE
Definition: types.h:120
DWORD scheme
GLuint buffer
Definition: glext.h:5915
#define HTTP_QUERY_WWW_AUTHENTICATE
Definition: wininet.h:1563
unsigned int len
#define FALSE
Definition: types.h:117
GLuint index
Definition: glext.h:6031
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
GLenum GLsizei len
Definition: glext.h:6722
Definition: tftpd.h:85

Referenced by do_authorization().

◆ get_np_event()

static HANDLE get_np_event ( RpcConnection_np connection)
static

Definition at line 97 of file rpc_transport.c.

98 {
99  HANDLE event = InterlockedExchangePointer(&connection->event_cache, NULL);
100  return event ? event : CreateEventW(NULL, TRUE, FALSE, NULL);
101 }
#define TRUE
Definition: types.h:120
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define FALSE
Definition: types.h:117
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
struct _cl_event * event
Definition: glext.h:7739
#define NULL
Definition: types.h:112

Referenced by rpcrt4_conn_np_read(), rpcrt4_conn_np_write(), and rpcrt4_protseq_np_get_wait_array().

◆ has_credentials()

static BOOL has_credentials ( RpcConnection_http httpc)
static

Definition at line 2989 of file rpc_transport.c.

2990 {
2993 
2995  return FALSE;
2996 
2997  creds = httpc->common.QOS->qos->u.HttpCredentials;
2999  return FALSE;
3000 
3001  id = creds->TransportCredentials;
3002  if (!id || !id->User || !id->Password) return FALSE;
3003 
3004  return TRUE;
3005 }
union _RPC_SECURITY_QOS_V2_W::@3167 u
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
#define RPC_C_HTTP_AUTHN_TARGET_SERVER
Definition: rpcdce.h:202
#define TRUE
Definition: types.h:120
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
#define FALSE
Definition: types.h:117
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
GLenum GLuint id
Definition: glext.h:5579
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
RpcQualityOfService * QOS
Definition: rpc_binding.h:81

Referenced by rpcrt4_ncacn_http_open().

◆ insert_authorization_header()

static RPC_STATUS insert_authorization_header ( HINTERNET  request,
ULONG  scheme,
char data,
int  data_len 
)
static

Definition at line 2896 of file rpc_transport.c.

2897 {
2898  static const WCHAR authW[] = {'A','u','t','h','o','r','i','z','a','t','i','o','n',':',' '};
2899  static const WCHAR basicW[] = {'B','a','s','i','c',' '};
2900  static const WCHAR negotiateW[] = {'N','e','g','o','t','i','a','t','e',' '};
2901  static const WCHAR ntlmW[] = {'N','T','L','M',' '};
2902  int scheme_len, auth_len = ARRAY_SIZE(authW), len = ((data_len + 2) * 4) / 3;
2903  const WCHAR *scheme_str;
2904  WCHAR *header, *ptr;
2906 
2907  switch (scheme)
2908  {
2910  scheme_str = basicW;
2911  scheme_len = ARRAY_SIZE(basicW);
2912  break;
2914  scheme_str = negotiateW;
2915  scheme_len = ARRAY_SIZE(negotiateW);
2916  break;
2918  scheme_str = ntlmW;
2919  scheme_len = ARRAY_SIZE(ntlmW);
2920  break;
2921  default:
2922  ERR("unknown scheme %u\n", scheme);
2923  return RPC_S_SERVER_UNAVAILABLE;
2924  }
2925  if ((header = HeapAlloc(GetProcessHeap(), 0, (auth_len + scheme_len + len + 2) * sizeof(WCHAR))))
2926  {
2927  memcpy(header, authW, auth_len * sizeof(WCHAR));
2928  ptr = header + auth_len;
2929  memcpy(ptr, scheme_str, scheme_len * sizeof(WCHAR));
2930  ptr += scheme_len;
2932  ptr[len++] = '\r';
2933  ptr[len++] = '\n';
2934  ptr[len] = 0;
2936  status = RPC_S_OK;
2938  }
2939  return status;
2940 }
static const WCHAR basicW[]
#define RPC_C_HTTP_AUTHN_SCHEME_BASIC
Definition: rpcdce.h:205
DWORD scheme
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
static const WCHAR negotiateW[]
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
unsigned int len
long RPC_STATUS
Definition: rpc.h:52
static PVOID ptr
Definition: dispmode.c:27
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
static const WCHAR ntlmW[]
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned int data_len
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define RPC_C_HTTP_AUTHN_SCHEME_NTLM
Definition: rpcdce.h:206
#define RPC_C_HTTP_AUTHN_SCHEME_NEGOTIATE
Definition: rpcdce.h:209
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1297
static UINT encode_base64(const char *bin, unsigned int len, WCHAR *base64)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:110
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: tftpd.h:85
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:594
struct CFHEADER header
Definition: fdi.c:101
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by authorize_request().

◆ insert_content_length_header()

static RPC_STATUS insert_content_length_header ( HINTERNET  request,
DWORD  len 
)
static

Definition at line 2385 of file rpc_transport.c.

2386 {
2387  static const WCHAR fmtW[] =
2388  {'C','o','n','t','e','n','t','-','L','e','n','g','t','h',':',' ','%','u','\r','\n',0};
2389  WCHAR header[ARRAY_SIZE(fmtW) + 10];
2390 
2391  swprintf(header, fmtW, len);
2393  return RPC_S_SERVER_UNAVAILABLE;
2394 }
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define HTTP_ADDREQ_FLAG_REPLACE
Definition: wininet.h:1711
#define HTTP_ADDREQ_FLAG_ADD
Definition: wininet.h:1707
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest, LPCWSTR lpszHeader, DWORD dwHeaderLength, DWORD dwModifier)
Definition: http.c:1297
GLenum GLsizei len
Definition: glext.h:6722
int _cdecl swprintf(const WCHAR *,...)
#define ARRAY_SIZE(a)
Definition: main.h:24
Definition: tftpd.h:85
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_http_prepare_in_pipe(), and rpcrt4_http_prepare_out_pipe().

◆ is_pipe_listening()

static RPC_STATUS is_pipe_listening ( const char pipe_name)
static

Definition at line 637 of file rpc_transport.c.

638 {
639  return WaitNamedPipeA(pipe_name, 1) ? RPC_S_OK : RPC_S_NOT_LISTENING;
640 }
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:433
#define RPC_S_NOT_LISTENING
Definition: winerror.h:1026
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_np_is_server_listening(), and rpcrt4_ncalrpc_np_is_server_listening().

◆ is_secure()

static BOOL is_secure ( RpcConnection_http httpc)
static

Definition at line 3007 of file rpc_transport.c.

3008 {
3009  return httpc->common.QOS &&
3012 }
union _RPC_SECURITY_QOS_V2_W::@3167 u
RpcConnection common
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
#define RPC_C_HTTP_FLAG_USE_SSL
Definition: rpcdce.h:198
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
RpcQualityOfService * QOS
Definition: rpc_binding.h:81

Referenced by open_connection(), rpcrt4_ncacn_http_open(), and set_auth_cookie().

◆ ncacn_pipe_name()

static char* ncacn_pipe_name ( const char endpoint)
static

Definition at line 503 of file rpc_transport.c.

505 {
506 #ifdef __REACTOS__
507  static const char prefix[] = "\\\\";
508  static const char local[] = ".";
509  char ComputerName[MAX_COMPUTERNAME_LENGTH + 1];
510  DWORD bufLen = ARRAY_SIZE(ComputerName);
511 #else
512  static const char prefix[] = "\\\\.";
513 #endif
514  char *pipe_name;
515 
516 #ifdef __REACTOS__
517  if (server != NULL && *server != 0)
518  {
519  /* Trim any leading UNC server prefix. */
520  if (server[0] == '\\' && server[1] == '\\')
521  server += 2;
522 
523  /* If the server represents the local computer, use instead
524  * the local prefix to avoid a round in UNC name resolution. */
525  if (GetComputerNameA(ComputerName, &bufLen) &&
526  (stricmp(ComputerName, server) == 0))
527  {
528  server = local;
529  }
530  }
531  else
532  {
533  server = local;
534  }
535 #endif
536 
537  /* protseq=ncacn_np: named pipes */
538 #ifdef __REACTOS__
539  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(server) + strlen(endpoint));
540  strcpy(pipe_name, prefix);
541  strcat(pipe_name, server);
542  strcat(pipe_name, endpoint);
543 #else
544  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
545  strcat(strcpy(pipe_name, prefix), endpoint);
546 #endif
547  return pipe_name;
548 }
BOOL WINAPI SHIM_OBJ_NAME() GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: shimtest.c:21
static rfbScreenInfoPtr server
Definition: vnc.c:74
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_Check_return_ _CRTIMP int __cdecl stricmp(_In_z_ const char *_Str1, _In_z_ const char *_Str2)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define local
Definition: zutil.h:30
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
Definition: nis.h:10
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:714

Referenced by rpcrt4_ncacn_np_is_server_listening(), rpcrt4_ncacn_np_open(), and rpcrt4_protseq_ncacn_np_open_endpoint().

◆ ncalrpc_pipe_name()

static char* ncalrpc_pipe_name ( const char endpoint)
static

Definition at line 439 of file rpc_transport.c.

440 {
441  static const char prefix[] = "\\\\.\\pipe\\lrpc\\";
442  char *pipe_name;
443 
444  /* protseq=ncalrpc: supposed to use NT LPC ports,
445  * but we'll implement it with named pipes for now */
446  pipe_name = I_RpcAllocate(sizeof(prefix) + strlen(endpoint));
447  strcat(strcpy(pipe_name, prefix), endpoint);
448  return pipe_name;
449 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: nis.h:10
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:714

Referenced by rpcrt4_ncalrpc_np_is_server_listening(), rpcrt4_ncalrpc_open(), and rpcrt4_protseq_ncalrpc_open_endpoint().

◆ prepare_async_request()

static void prepare_async_request ( RpcHttpAsyncData async_data)
static

Definition at line 1997 of file rpc_transport.c.

1998 {
1999  ResetEvent(async_data->completion_event);
2000  RpcHttpAsyncData_AddRef(async_data);
2001 }
static ULONG RpcHttpAsyncData_AddRef(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714

Referenced by authorize_request(), rpcrt4_http_async_read(), rpcrt4_http_prepare_in_pipe(), rpcrt4_http_prepare_out_pipe(), rpcrt4_ncacn_http_wait_for_incoming_data(), and send_echo_request().

◆ release_np_event()

static void release_np_event ( RpcConnection_np connection,
HANDLE  event 
)
static

Definition at line 103 of file rpc_transport.c.

104 {
105  event = InterlockedExchangePointer(&connection->event_cache, event);
106  if (event)
108 }
#define CloseHandle
Definition: compat.h:598
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
struct _cl_event * event
Definition: glext.h:7739

Referenced by rpcrt4_conn_np_read(), rpcrt4_conn_np_write(), and rpcrt4_protseq_np_wait_for_new_connection().

◆ RpcHttpAsyncData_AddRef()

static ULONG RpcHttpAsyncData_AddRef ( RpcHttpAsyncData data)
static

Definition at line 1977 of file rpc_transport.c.

1978 {
1979  return InterlockedIncrement(&data->refs);
1980 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by prepare_async_request().

◆ RpcHttpAsyncData_Release()

static ULONG RpcHttpAsyncData_Release ( RpcHttpAsyncData data)
static

Definition at line 1982 of file rpc_transport.c.

1983 {
1984  ULONG refs = InterlockedDecrement(&data->refs);
1985  if (!refs)
1986  {
1987  TRACE("destroying async data %p\n", data);
1988  CloseHandle(data->completion_event);
1989  HeapFree(GetProcessHeap(), 0, data->inet_buffers.lpvBuffer);
1990  data->cs.DebugInfo->Spare[0] = 0;
1992  HeapFree(GetProcessHeap(), 0, data);
1993  }
1994  return refs;
1995 }
#define CloseHandle
Definition: compat.h:598
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by rpcrt4_http_internet_callback(), rpcrt4_ncacn_http_close(), and wait_async_request().

◆ RpcNetworkInqProtseqsA()

RPC_STATUS WINAPI RpcNetworkInqProtseqsA ( RPC_PROTSEQ_VECTORA **  protseqs)

Definition at line 3959 of file rpc_transport.c.

3960 {
3961  RPC_PROTSEQ_VECTORA *pvector;
3962  unsigned int i;
3964 
3965  TRACE("(%p)\n", protseqs);
3966 
3967  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned char*)*ARRAY_SIZE(protseq_list)));
3968  if (!*protseqs)
3969  goto end;
3970  pvector = *protseqs;
3971  pvector->Count = 0;
3972  for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3973  {
3974  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_list[i].name)+1);
3975  if (pvector->Protseq[i] == NULL)
3976  goto end;
3977  strcpy((char*)pvector->Protseq[i], protseq_list[i].name);
3978  pvector->Count++;
3979  }
3980  status = RPC_S_OK;
3981 
3982 end:
3983  if (status != RPC_S_OK)
3985  return status;
3986 }
static struct list protseqs
Definition: rpc_server.c:68
unsigned char * Protseq[1]
Definition: rpcdce.h:91
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned int Count
Definition: rpcdce.h:90
static const struct protseq_ops protseq_list[]
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint GLuint end
Definition: gl.h:1545
RPC_STATUS WINAPI RpcProtseqVectorFreeA(RPC_PROTSEQ_VECTORA **protseqs)
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
#define NULL
Definition: types.h:112
Definition: name.c:38
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

◆ RpcNetworkInqProtseqsW()

RPC_STATUS WINAPI RpcNetworkInqProtseqsW ( RPC_PROTSEQ_VECTORW **  protseqs)

Definition at line 3926 of file rpc_transport.c.

3927 {
3928  RPC_PROTSEQ_VECTORW *pvector;
3929  unsigned int i;
3931 
3932  TRACE("(%p)\n", protseqs);
3933 
3934  *protseqs = HeapAlloc(GetProcessHeap(), 0, sizeof(RPC_PROTSEQ_VECTORW)+(sizeof(unsigned short*)*ARRAY_SIZE(protseq_list)));
3935  if (!*protseqs)
3936  goto end;
3937  pvector = *protseqs;
3938  pvector->Count = 0;
3939  for (i = 0; i < ARRAY_SIZE(protseq_list); i++)
3940  {
3941  pvector->Protseq[i] = HeapAlloc(GetProcessHeap(), 0, (strlen(protseq_list[i].name)+1)*sizeof(unsigned short));
3942  if (pvector->Protseq[i] == NULL)
3943  goto end;
3945  (WCHAR*)pvector->Protseq[i], strlen(protseq_list[i].name) + 1);
3946  pvector->Count++;
3947  }
3948  status = RPC_S_OK;
3949 
3950 end:
3951  if (status != RPC_S_OK)
3953  return status;
3954 }
static struct list protseqs
Definition: rpc_server.c:68
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
unsigned int Count
Definition: rpcdce.h:96
static const struct protseq_ops protseq_list[]
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
RPC_STATUS WINAPI RpcProtseqVectorFreeW(RPC_PROTSEQ_VECTORW **protseqs)
unsigned short * Protseq[1]
Definition: rpcdce.h:97
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLuint GLuint end
Definition: gl.h:1545
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
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
Definition: name.c:38
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

◆ RpcNetworkIsProtseqValidA()

RPC_STATUS WINAPI RpcNetworkIsProtseqValidA ( RPC_CSTR  protseq)

Definition at line 3874 of file rpc_transport.c.

3875 {
3876  UNICODE_STRING protseqW;
3877 
3878  if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq))
3879  {
3881  RtlFreeUnicodeString(&protseqW);
3882  return ret;
3883  }
3884  return RPC_S_OUT_OF_MEMORY;
3885 }
long RPC_STATUS
Definition: rpc.h:52
#define RPC_S_OUT_OF_MEMORY
Definition: rpcnterr.h:24
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret
RPC_STATUS WINAPI RpcNetworkIsProtseqValidW(RPC_WSTR protseq)

Referenced by test_rpc_ncacn_ip_tcp().

◆ RpcNetworkIsProtseqValidW()

RPC_STATUS WINAPI RpcNetworkIsProtseqValidW ( RPC_WSTR  protseq)

Definition at line 3857 of file rpc_transport.c.

3858 {
3859  char ps[0x10];
3860 
3861  WideCharToMultiByte(CP_ACP, 0, protseq, -1,
3862  ps, sizeof ps, NULL, NULL);
3864  return RPC_S_OK;
3865 
3866  FIXME("Unknown protseq %s\n", debugstr_w(protseq));
3867 
3869 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
#define RPC_S_INVALID_RPC_PROTSEQ
Definition: winerror.h:1015
#define NULL
Definition: types.h:112
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcNetworkIsProtseqValidA().

◆ RpcProtseqVectorFreeA()

RPC_STATUS WINAPI RpcProtseqVectorFreeA ( RPC_PROTSEQ_VECTORA **  protseqs)

Definition at line 3890 of file rpc_transport.c.

3891 {
3892  TRACE("(%p)\n", protseqs);
3893 
3894  if (*protseqs)
3895  {
3896  unsigned int i;
3897  for (i = 0; i < (*protseqs)->Count; i++)
3898  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3900  *protseqs = NULL;
3901  }
3902  return RPC_S_OK;
3903 }
static struct list protseqs
Definition: rpc_server.c:68
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
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 NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcNetworkInqProtseqsA().

◆ RpcProtseqVectorFreeW()

RPC_STATUS WINAPI RpcProtseqVectorFreeW ( RPC_PROTSEQ_VECTORW **  protseqs)

Definition at line 3908 of file rpc_transport.c.

3909 {
3910  TRACE("(%p)\n", protseqs);
3911 
3912  if (*protseqs)
3913  {
3914  unsigned int i;
3915  for (i = 0; i < (*protseqs)->Count; i++)
3916  HeapFree(GetProcessHeap(), 0, (*protseqs)->Protseq[i]);
3918  *protseqs = NULL;
3919  }
3920  return RPC_S_OK;
3921 }
static struct list protseqs
Definition: rpc_server.c:68
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
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 NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcNetworkInqProtseqsW().

◆ RPCRT4_CloseConnection()

RPC_STATUS RPCRT4_CloseConnection ( RpcConnection Connection)

Definition at line 3606 of file rpc_transport.c.

3607 {
3608  TRACE("(Connection == ^%p)\n", Connection);
3609  if (SecIsValidHandle(&Connection->ctx))
3610  {
3611  DeleteSecurityContext(&Connection->ctx);
3612  SecInvalidateHandle(&Connection->ctx);
3613  }
3614  rpcrt4_conn_close(Connection);
3615  return RPC_S_OK;
3616 }
static int rpcrt4_conn_close(RpcConnection *Connection)
Definition: rpc_binding.h:200
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define SecInvalidateHandle(x)
Definition: sspi.h:58
#define TRACE(s)
Definition: solgame.cpp:4
CtxtHandle ctx
Definition: rpc_binding.h:74
#define RPC_S_OK
Definition: rpcnterr.h:22
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450

Referenced by RPCRT4_ReleaseConnection(), and RPCRT4_server_thread().

◆ rpcrt4_conn_create_pipe()

static RPC_STATUS rpcrt4_conn_create_pipe ( RpcConnection conn)
static

Definition at line 322 of file rpc_transport.c.

323 {
324  RpcConnection_np *connection = (RpcConnection_np *) conn;
325 #ifdef __REACTOS__
326  DWORD ErrCode;
327  SECURITY_ATTRIBUTES SecurityAttributes;
328  PSECURITY_DESCRIPTOR PipeSecDesc;
329 #endif
330 
331  TRACE("listening on %s\n", connection->listen_pipe);
332 
333 #ifdef __REACTOS__
334  ErrCode = rpcrt4_create_pipe_security(&PipeSecDesc);
335  if (ErrCode != ERROR_SUCCESS)
336  {
337  ERR("rpcrt4_conn_create_pipe(): Pipe security descriptor creation failed!\n");
339  }
340 
341  SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
342  SecurityAttributes.lpSecurityDescriptor = PipeSecDesc;
343  SecurityAttributes.bInheritHandle = FALSE;
344 
348  RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, &SecurityAttributes);
349  HeapFree(GetProcessHeap(), 0, PipeSecDesc);
350 #else
355 #endif
356  if (connection->pipe == INVALID_HANDLE_VALUE)
357  {
358  WARN("CreateNamedPipe failed with error %d\n", GetLastError());
360  {
362  }
363  else
364  {
366  }
367  }
368 
369  return RPC_S_OK;
370 }
#define PIPE_UNLIMITED_INSTANCES
Definition: winbase.h:175
#define ERROR_FILE_EXISTS
Definition: winerror.h:165
#define ERROR_SUCCESS
Definition: deptool.c:10
#define PIPE_TYPE_MESSAGE
Definition: winbase.h:168
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define FALSE
Definition: types.h:117
#define RPC_S_DUPLICATE_ENDPOINT
Definition: winerror.h:1048
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:164
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define ERR(fmt,...)
Definition: debug.h:110
LPVOID lpSecurityDescriptor
Definition: compat.h:193
#define NULL
Definition: types.h:112
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22
#define RPC_S_CANT_CREATE_ENDPOINT
Definition: winerror.h:1031
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES

Referenced by rpcrt4_ncacn_np_handoff(), rpcrt4_ncalrpc_handoff(), rpcrt4_protseq_ncacn_np_open_endpoint(), rpcrt4_protseq_ncalrpc_open_endpoint(), and rpcrt4_protseq_np_get_wait_array().

◆ rpcrt4_conn_np_alloc()

static RpcConnection* rpcrt4_conn_np_alloc ( void  )
static

Definition at line 91 of file rpc_transport.c.

92 {
94  return &npc->common;
95 }
RpcConnection common
Definition: rpc_transport.c:82
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HEAP_ZERO_MEMORY
Definition: compat.h:134

◆ rpcrt4_conn_np_cancel_call()

static void rpcrt4_conn_np_cancel_call ( RpcConnection conn)
static

Definition at line 782 of file rpc_transport.c.

783 {
784  RpcConnection_np *connection = (RpcConnection_np *)conn;
785  CancelIoEx(connection->pipe, NULL);
786 }
#define NULL
Definition: types.h:112

◆ rpcrt4_conn_np_close()

static int rpcrt4_conn_np_close ( RpcConnection conn)
static

Definition at line 747 of file rpc_transport.c.

748 {
749  RpcConnection_np *connection = (RpcConnection_np *) conn;
750  if (connection->pipe)
751  {
752  FlushFileBuffers(connection->pipe);
753  CloseHandle(connection->pipe);
754  connection->pipe = 0;
755  }
756  if (connection->listen_event)
757  {
758  CloseHandle(connection->listen_event);
759  connection->listen_event = 0;
760  }
761  if (connection->event_cache)
762  {
763  CloseHandle(connection->event_cache);
764  connection->event_cache = 0;
765  }
766  return 0;
767 }
#define CloseHandle
Definition: compat.h:598
BOOL WINAPI FlushFileBuffers(IN HANDLE hFile)
Definition: fileinfo.c:25

◆ rpcrt4_conn_np_close_read()

static void rpcrt4_conn_np_close_read ( RpcConnection conn)
static

Definition at line 769 of file rpc_transport.c.

770 {
771  RpcConnection_np *connection = (RpcConnection_np*)conn;
773 
774  connection->read_closed = TRUE;
775 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
776  NtCancelIoFile(connection->pipe, &io_status);
777 #else
778  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
779 #endif
780 }
#define TRUE
Definition: types.h:120
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:86
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4018

◆ rpcrt4_conn_np_handoff()

static void rpcrt4_conn_np_handoff ( RpcConnection_np old_npc,
RpcConnection_np new_npc 
)
static

Definition at line 607 of file rpc_transport.c.

608 {
609  /* because of the way named pipes work, we'll transfer the connected pipe
610  * to the child, then reopen the server binding to continue listening */
611 
612  new_npc->pipe = old_npc->pipe;
613  old_npc->pipe = 0;
614  assert(!old_npc->listen_event);
615 }
#define assert(x)
Definition: debug.h:53

Referenced by rpcrt4_ncacn_np_handoff(), and rpcrt4_ncalrpc_handoff().

◆ rpcrt4_conn_np_impersonate_client()

static RPC_STATUS rpcrt4_conn_np_impersonate_client ( RpcConnection conn)
static

Definition at line 906 of file rpc_transport.c.

907 {
908  RpcConnection_np *npc = (RpcConnection_np *)conn;
909  BOOL ret;
910 
911  TRACE("(%p)\n", conn);
912 
913  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
915 
917  if (!ret)
918  {
920  WARN("ImpersonateNamedPipeClient failed with error %u\n", error);
921  switch (error)
922  {
925  }
926  }
927  return RPC_S_OK;
928 }
BOOL WINAPI ImpersonateNamedPipeClient(HANDLE hNamedPipe)
Definition: security.c:1026
#define error(str)
Definition: mkdosfs.c:1605
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1073
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:112
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ERROR_CANNOT_IMPERSONATE
Definition: winerror.h:849
unsigned int BOOL
Definition: ntddk_ex.h:94
RPC_STATUS RPCRT4_default_impersonate_client(RpcConnection *conn)
Definition: rpc_message.c:1131
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ rpcrt4_conn_np_read()

static int rpcrt4_conn_np_read ( RpcConnection conn,
void buffer,
unsigned int  count 
)
static

Definition at line 689 of file rpc_transport.c.

690 {
691  RpcConnection_np *connection = (RpcConnection_np *) conn;
692  HANDLE event;
694 
695  event = get_np_event(connection);
696  if (!event)
697  return -1;
698 
699  if (connection->read_closed)
701  else
702  status = NtReadFile(connection->pipe, event, NULL, NULL, &connection->io_status, buffer, count, NULL, NULL);
703  if (status == STATUS_PENDING)
704  {
705  /* check read_closed again before waiting to avoid a race */
706  if (connection->read_closed)
707  {
709 #ifdef __REACTOS__ /* FIXME: We should also cancel I/O for other threads */
710  NtCancelIoFile(connection->pipe, &io_status);
711 #else
712  NtCancelIoFileEx(connection->pipe, &connection->io_status, &io_status);
713 #endif
714  }
716  status = connection->io_status.u.Status;
717  }
718  release_np_event(connection, event);
719  return status && status != STATUS_BUFFER_OVERFLOW ? -1 : connection->io_status.Information;
720 }
static HANDLE get_np_event(RpcConnection_np *connection)
Definition: rpc_transport.c:97
GLuint GLuint GLsizei count
Definition: gl.h:1545
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
GLuint buffer
Definition: glext.h:5915
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
IO_STATUS_BLOCK io_status
Definition: rpc_transport.c:86
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
NTSYSAPI NTSTATUS WINAPI NtCancelIoFileEx(HANDLE, PIO_STATUS_BLOCK, PIO_STATUS_BLOCK)
struct _cl_event * event
Definition: glext.h:7739
static void release_np_event(RpcConnection_np *connection, HANDLE event)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define NULL
Definition: types.h:112
NTSTATUS NTAPI NtCancelIoFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: file.c:4018
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
Definition: ps.c:97

Referenced by rpcrt4_conn_np_wait_for_incoming_data().

◆ rpcrt4_conn_np_revert_to_self()

static RPC_STATUS rpcrt4_conn_np_revert_to_self ( RpcConnection conn)
static

Definition at line 930 of file rpc_transport.c.

931 {
932  BOOL ret;
933 
934  TRACE("(%p)\n", conn);
935 
936  if (conn->AuthInfo && SecIsValidHandle(&conn->ctx))
937  return RPCRT4_default_revert_to_self(conn);
938 
939  ret = RevertToSelf();
940  if (!ret)
941  {
942  WARN("RevertToSelf failed with error %u\n", GetLastError());
944  }
945  return RPC_S_OK;
946 }
RPC_STATUS RPCRT4_default_revert_to_self(RpcConnection *conn)
Definition: rpc_message.c:1159
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1073
BOOL WINAPI RevertToSelf(VOID)
Definition: security.c:1610
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define WARN(fmt,...)
Definition: debug.h:112
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
int ret
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ rpcrt4_conn_np_wait_for_incoming_data()

static int rpcrt4_conn_np_wait_for_incoming_data ( RpcConnection conn)
static

Definition at line 788 of file rpc_transport.c.

789 {
790  return rpcrt4_conn_np_read(conn, NULL, 0);
791 }
static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int count)
#define NULL
Definition: types.h:112

◆ rpcrt4_conn_np_write()

static int rpcrt4_conn_np_write ( RpcConnection conn,
const void buffer,
unsigned int  count 
)
static

Definition at line 722 of file rpc_transport.c.

723 {
724  RpcConnection_np *connection = (RpcConnection_np *) conn;
726  HANDLE event;
728 
729  event = get_np_event(connection);
730  if (!event)
731  return -1;
732 
733  status = NtWriteFile(connection->pipe, event, NULL, NULL, &io_status, buffer, count, NULL, NULL);
734  if (status == STATUS_PENDING)
735  {
737  status = io_status.u.Status;
738  }
739  release_np_event(connection, event);
740  if (status)
741  return -1;
742 
743  assert(io_status.Information == count);
744  return count;
745 }
static HANDLE get_np_event(RpcConnection_np *connection)
Definition: rpc_transport.c:97
GLuint GLuint GLsizei count
Definition: gl.h:1545
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE PIO_APC_ROUTINE void PIO_STATUS_BLOCK io_status
Definition: comm.c:54
#define assert(x)
Definition: debug.h:53
GLuint buffer
Definition: glext.h:5915
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
struct _cl_event * event
Definition: glext.h:7739
static void release_np_event(RpcConnection_np *connection, HANDLE event)
#define NULL
Definition: types.h:112
#define INFINITE
Definition: serial.h:102
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ rpcrt4_conn_open_pipe()

static RPC_STATUS rpcrt4_conn_open_pipe ( RpcConnection Connection,
LPCSTR  pname,
BOOL  wait 
)
static

Definition at line 372 of file rpc_transport.c.

373 {
374  RpcConnection_np *npc = (RpcConnection_np *) Connection;
375  HANDLE pipe;
376  DWORD err, dwMode;
377 
378  TRACE("connecting to %s\n", pname);
379 
380  while (TRUE) {
381  DWORD dwFlags = 0;
382  if (Connection->QOS)
383  {
385  switch (Connection->QOS->qos->ImpersonationType)
386  {
388  /* FIXME: what to do here? */
389  break;
392  break;
395  break;
398  break;
401  break;
402  }
403  if (Connection->QOS->qos->IdentityTracking == RPC_C_QOS_IDENTITY_DYNAMIC)
405  }
408  if (pipe != INVALID_HANDLE_VALUE) break;
409  err = GetLastError();
410  if (err == ERROR_PIPE_BUSY) {
412  TRACE("retrying busy server\n");
413  continue;
414  }
415  TRACE("connection failed, error=%x\n", err);
416  return RPC_S_SERVER_TOO_BUSY;
417 #ifdef __REACTOS__
418  } else if (err == ERROR_BAD_NETPATH) {
419  TRACE("connection failed, error=%x\n", err);
421 #endif
422  }
423  if (!wait || !WaitNamedPipeA(pname, NMPWAIT_WAIT_FOREVER)) {
424  err = GetLastError();
425  WARN("connection failed, error=%x\n", err);
427  }
428  }
429 
430  /* success */
431  /* pipe is connected; change to message-read mode. */
432  dwMode = PIPE_READMODE_MESSAGE;
433  SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
434  npc->pipe = pipe;
435 
436  return RPC_S_OK;
437 }
#define TRUE
Definition: types.h:120
#define SECURITY_IDENTIFICATION
Definition: winbase.h:538
#define WARN(fmt,...)
Definition: debug.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define RPC_C_IMP_LEVEL_ANONYMOUS
Definition: rpcdce.h:174
#define RPC_C_IMP_LEVEL_IDENTIFY
Definition: rpcdce.h:175
#define NMPWAIT_USE_DEFAULT_WAIT
Definition: winbase.h:134
#define RPC_C_IMP_LEVEL_IMPERSONATE
Definition: rpcdce.h:176
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
BOOL WINAPI WaitNamedPipeA(LPCSTR lpNamedPipeName, DWORD nTimeOut)
Definition: npipe.c:433
GLenum pname
Definition: glext.h:5645
#define SECURITY_DELEGATION
Definition: winbase.h:540
#define GENERIC_WRITE
Definition: nt_native.h:90
#define NMPWAIT_WAIT_FOREVER
Definition: winbase.h:133
#define SECURITY_CONTEXT_TRACKING
Definition: winbase.h:541
#define OPEN_EXISTING
Definition: compat.h:634
#define SECURITY_SQOS_PRESENT
Definition: winbase.h:543
#define TRACE(s)
Definition: solgame.cpp:4
#define RPC_C_QOS_IDENTITY_DYNAMIC
Definition: rpcdce.h:181
BOOL WINAPI SetNamedPipeHandleState(HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout)
Definition: npipe.c:774
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERROR_PIPE_BUSY
Definition: winerror.h:283
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define GENERIC_READ
Definition: compat.h:135
#define err(...)
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
#define SECURITY_ANONYMOUS
Definition: winbase.h:537
#define SECURITY_IMPERSONATION
Definition: winbase.h:539
#define RPC_S_SERVER_TOO_BUSY
Definition: winerror.h:1034
#define PIPE_READMODE_MESSAGE
Definition: winbase.h:170
#define NULL
Definition: types.h:112
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599
#define FILE_FLAG_OVERLAPPED
Definition: disk.h:46
#define RPC_C_IMP_LEVEL_DEFAULT
Definition: rpcdce.h:173
#define RPC_C_IMP_LEVEL_DELEGATE
Definition: rpcdce.h:177
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_np_open(), and rpcrt4_ncalrpc_open().

◆ rpcrt4_conn_release_and_wait()

void rpcrt4_conn_release_and_wait ( RpcConnection connection)

Definition at line 3682 of file rpc_transport.c.

3683 {
3684  HANDLE event = NULL;
3685 
3686  if (connection->ref > 1)
3687  event = connection->wait_release = CreateEventW(NULL, TRUE, FALSE, NULL);
3688 
3689  RPCRT4_ReleaseConnection(connection);
3690 
3691  if(event)
3692  {
3694  CloseHandle(event);
3695  }
3696 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
void RPCRT4_ReleaseConnection(RpcConnection *connection)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
HANDLE wait_release
Definition: rpc_binding.h:66
struct _cl_event * event
Definition: glext.h:7739
#define NULL
Definition: types.h:112
#define INFINITE
Definition: serial.h:102

Referenced by RPCRT4_server_thread().

◆ rpcrt4_conn_tcp_alloc()

static RpcConnection* rpcrt4_conn_tcp_alloc ( void  )
static

Definition at line 1431 of file rpc_transport.c.

1432 {
1433  RpcConnection_tcp *tcpc;
1435  if (tcpc == NULL)
1436  return NULL;
1437  tcpc->sock = -1;
1438  if (!rpcrt4_sock_wait_init(tcpc))
1439  {
1440  HeapFree(GetProcessHeap(), 0, tcpc);
1441  return NULL;
1442  }
1443  return &tcpc->common;
1444 }
static BOOL rpcrt4_sock_wait_init(RpcConnection_tcp *tcpc)
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
RpcConnection common
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define HeapFree(x, y, z)
Definition: compat.h:594

◆ rpcrt4_conn_tcp_cancel_call()

static void rpcrt4_conn_tcp_cancel_call ( RpcConnection conn)
static

Definition at line 1781 of file rpc_transport.c.

1782 {
1783  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1784 
1785  TRACE("%p\n", connection);
1786 
1787  SetEvent(connection->cancel_event);
1788 }
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define TRACE(s)
Definition: solgame.cpp:4

◆ rpcrt4_conn_tcp_close()

static int rpcrt4_conn_tcp_close ( RpcConnection conn)
static

Definition at line 1761 of file rpc_transport.c.

1762 {
1763  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1764 
1765  TRACE("%d\n", connection->sock);
1766 
1767  if (connection->sock != -1)
1768  closesocket(connection->sock);
1769  connection->sock = -1;
1770  CloseHandle(connection->sock_event);
1771  CloseHandle(connection->cancel_event);
1772  return 0;
1773 }
#define CloseHandle
Definition: compat.h:598
#define closesocket
Definition: ncftp.h:477
#define TRACE(s)
Definition: solgame.cpp:4

◆ rpcrt4_conn_tcp_close_read()

static void rpcrt4_conn_tcp_close_read ( RpcConnection conn)
static

Definition at line 1775 of file rpc_transport.c.

1776 {
1777  RpcConnection_tcp *connection = (RpcConnection_tcp *) conn;
1778  shutdown(connection->sock, SD_RECEIVE);
1779 }
INT WSAAPI shutdown(IN SOCKET s, IN INT how)
Definition: sockctrl.c:506
#define SD_RECEIVE
Definition: winsock.h:54

◆ rpcrt4_conn_tcp_handoff()

static RPC_STATUS rpcrt4_conn_tcp_handoff ( RpcConnection old_conn,
RpcConnection new_conn 
)
static

Definition at line 1675 of file rpc_transport.c.

1676 {
1677  int ret;
1678  struct sockaddr_in address;
1679  socklen_t addrsize;
1682  u_long nonblocking;
1683 
1684  addrsize = sizeof(address);
1685  ret = accept(server->sock, (struct sockaddr*) &address, &addrsize);
1686  if (ret < 0)
1687  {
1688  ERR("Failed to accept a TCP connection: error %d\n", ret);
1689  return RPC_S_OUT_OF_RESOURCES;
1690  }
1691 
1692  nonblocking = 1;
1693  ioctlsocket(ret, FIONBIO, &nonblocking);
1694  client->sock = ret;
1695 
1696  client->common.NetworkAddr = HeapAlloc(GetProcessHeap(), 0, INET6_ADDRSTRLEN);
1697  ret = getnameinfo((struct sockaddr*)&address, addrsize, client->common.NetworkAddr, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
1698  if (ret != 0)
1699  {
1700  ERR("Failed to retrieve the IP address, error %d\n", ret);
1701  return RPC_S_OUT_OF_RESOURCES;
1702  }
1703 
1704  TRACE("Accepted a new TCP connection from %s\n", client->common.NetworkAddr);
1705  return RPC_S_OK;
1706 }
static rfbScreenInfoPtr server
Definition: vnc.c:74
unsigned long u_long
Definition: linux.h:269
#define NI_NUMERICHOST
Definition: ws2def.h:354
#define ioctlsocket
Definition: ncftp.h:481
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static FILE * client
Definition: client.c:41
GLuint address
Definition: glext.h:9393
int socklen_t
Definition: tcp.c:35
int ret
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define FIONBIO
Definition: winsock.h:149
#define ERR(fmt,...)
Definition: debug.h:110
#define getnameinfo
Definition: wspiapi.h:45
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define NULL
Definition: types.h:112
#define INET6_ADDRSTRLEN
Definition: ws2ipdef.h:132
#define RPC_S_OK
Definition: rpcnterr.h:22

◆ rpcrt4_conn_tcp_is_server_listening()

static RPC_STATUS rpcrt4_conn_tcp_is_server_listening ( const char endpoint)
static

Definition at line 1790 of file rpc_transport.c.

1791 {
1792  FIXME("\n");
1793  return RPC_S_ACCESS_DENIED;
1794 }
#define RPC_S_ACCESS_DENIED
Definition: rpcnterr.h:29
#define FIXME(fmt,...)
Definition: debug.h:111

◆ rpcrt4_conn_tcp_read()

static int rpcrt4_conn_tcp_read ( RpcConnection Connection,
void buffer,
unsigned int  count 
)
static

Definition at line 1708 of file rpc_transport.c.

1710 {
1711  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1712  int bytes_read = 0;
1713  while (bytes_read != count)
1714  {
1715  int r = recv(tcpc->sock, (char *)buffer + bytes_read, count - bytes_read, 0);
1716  if (!r)
1717  return -1;
1718  else if (r > 0)
1719  bytes_read += r;
1720  else if (WSAGetLastError() == WSAEINTR)
1721  continue;
1722  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1723  {
1724  WARN("recv() failed: %u\n", WSAGetLastError());
1725  return -1;
1726  }
1727  else
1728  {
1729  if (!rpcrt4_sock_wait_for_recv(tcpc))
1730  return -1;
1731  }
1732  }
1733  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_read);
1734  return bytes_read;
1735 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WARN(fmt,...)
Definition: debug.h:112
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
GLuint buffer
Definition: glext.h:5915
#define TRACE(s)
Definition: solgame.cpp:4
INT WSAAPI WSAGetLastError(VOID)
Definition: dllmain.c:112
static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc)
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define WSAEINTR
Definition: winerror.h:1942

◆ rpcrt4_conn_tcp_wait_for_incoming_data()

static int rpcrt4_conn_tcp_wait_for_incoming_data ( RpcConnection Connection)
static

Definition at line 1796 of file rpc_transport.c.

1797 {
1798  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1799 
1800  TRACE("%p\n", Connection);
1801 
1802  if (!rpcrt4_sock_wait_for_recv(tcpc))
1803  return -1;
1804  return 0;
1805 }
#define TRACE(s)
Definition: solgame.cpp:4
static BOOL rpcrt4_sock_wait_for_recv(RpcConnection_tcp *tcpc)

◆ rpcrt4_conn_tcp_write()

static int rpcrt4_conn_tcp_write ( RpcConnection Connection,
const void buffer,
unsigned int  count 
)
static

Definition at line 1737 of file rpc_transport.c.

1739 {
1740  RpcConnection_tcp *tcpc = (RpcConnection_tcp *) Connection;
1741  int bytes_written = 0;
1742  while (bytes_written != count)
1743  {
1744  int r = send(tcpc->sock, (const char *)buffer + bytes_written, count - bytes_written, 0);
1745  if (r >= 0)
1746  bytes_written += r;
1747  else if (WSAGetLastError() == WSAEINTR)
1748  continue;
1749  else if (WSAGetLastError() != WSAEWOULDBLOCK)
1750  return -1;
1751  else
1752  {
1753  if (!rpcrt4_sock_wait_for_send(tcpc))
1754  return -1;
1755  }
1756  }
1757  TRACE("%d %p %u -> %d\n", tcpc->sock, buffer, count, bytes_written);
1758  return bytes_written;
1759 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WSAEWOULDBLOCK
Definition: winerror.h:1948
GLuint buffer
Definition: glext.h:5915
#define TRACE(s)
Definition: solgame.cpp:4
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
static BOOL rpcrt4_sock_wait_for_send(RpcConnection_tcp *tcpc)
#define WSAEINTR
Definition: winerror.h:1942

◆ RPCRT4_CreateConnection()

RPC_STATUS RPCRT4_CreateConnection ( RpcConnection **  Connection,
BOOL  server,
LPCSTR  Protseq,
LPCSTR  NetworkAddr,
LPCSTR  Endpoint,
LPCWSTR  NetworkOptions,
RpcAuthInfo AuthInfo,
RpcQualityOfService QOS,
LPCWSTR  CookieAuth 
)

Definition at line 3618 of file rpc_transport.c.

3621 {
3622  static LONG next_id;
3623  const struct connection_ops *ops;
3624  RpcConnection* NewConnection;
3625 
3626  ops = rpcrt4_get_conn_protseq_ops(Protseq);
3627  if (!ops)
3628  {
3629  FIXME("not supported for protseq %s\n", Protseq);
3631  }
3632 
3633  NewConnection = ops->alloc();
3634  NewConnection->ref = 1;
3635  NewConnection->server = server;
3636  NewConnection->ops = ops;
3637  NewConnection->NetworkAddr = RPCRT4_strdupA(NetworkAddr);
3638  NewConnection->Endpoint = RPCRT4_strdupA(Endpoint);
3639  NewConnection->NetworkOptions = RPCRT4_strdupW(NetworkOptions);
3640  NewConnection->CookieAuth = RPCRT4_strdupW(CookieAuth);
3641  NewConnection->MaxTransmissionSize = RPC_MAX_PACKET_SIZE;
3642  NewConnection->NextCallId = 1;
3643 
3644  SecInvalidateHandle(&NewConnection->ctx);
3645  if (AuthInfo) RpcAuthInfo_AddRef(AuthInfo);
3646  NewConnection->AuthInfo = AuthInfo;
3647  NewConnection->auth_context_id = InterlockedIncrement( &next_id );
3649  NewConnection->QOS = QOS;
3650 
3651  list_init(&NewConnection->conn_pool_entry);
3652  list_init(&NewConnection->protseq_entry);
3653 
3654  TRACE("connection: %p\n", NewConnection);
3655  *Connection = NewConnection;
3656 
3657  return RPC_S_OK;
3658 }
USHORT MaxTransmissionSize
Definition: rpc_binding.h:71
struct list protseq_entry
Definition: rpc_binding.h:94
static rfbScreenInfoPtr server
Definition: vnc.c:74
USHORT NextCallId
Definition: rpc_binding.h:93
static const struct connection_ops * rpcrt4_get_conn_protseq_ops(const char *protseq)
const struct connection_ops * ops
Definition: rpc_binding.h:70
struct list conn_pool_entry
Definition: rpc_binding.h:85
#define SecInvalidateHandle(x)
Definition: sspi.h:58
long LONG
Definition: pedump.c:60
ULONG RpcAuthInfo_AddRef(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1179
#define FIXME(fmt,...)
Definition: debug.h:111
#define RPC_S_PROTSEQ_NOT_SUPPORTED
Definition: winerror.h:1014
#define TRACE(s)
Definition: solgame.cpp:4
LPWSTR NetworkOptions
Definition: rpc_binding.h:69
LPSTR NetworkAddr
Definition: rpc_binding.h:67
LPWSTR CookieAuth
Definition: rpc_binding.h:82
CtxtHandle ctx
Definition: rpc_binding.h:74
RpcConnection *(* alloc)(void)
Definition: rpc_binding.h:102
#define InterlockedIncrement
Definition: armddk.h:53
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
#define RPCRT4_strdupA(x)
Definition: rpc_binding.h:151
ULONG RpcQualityOfService_AddRef(RpcQualityOfService *qos)
Definition: rpc_binding.c:1356
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149
#define RPC_MAX_PACKET_SIZE
Definition: rpc_defs.h:184
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
ULONG auth_context_id
Definition: rpc_binding.h:78
struct _QualityOfService QOS
#define RPCRT4_strdupW(x)
Definition: rpc_binding.h:152
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by RpcAssoc_GetClientConnection(), rpcrt4_protseq_ncacn_ip_tcp_open_endpoint(), rpcrt4_protseq_ncacn_np_open_endpoint(), rpcrt4_protseq_ncalrpc_open_endpoint(), and rpcrt4_spawn_connection().

◆ rpcrt4_get_conn_protseq_ops()

static const struct connection_ops* rpcrt4_get_conn_protseq_ops ( const char protseq)
static

Definition at line 3587 of file rpc_transport.c.

3588 {
3589  unsigned int i;
3590  for(i = 0; i < ARRAY_SIZE(conn_protseq_list); i++)
3591  if (!strcmp(conn_protseq_list[i].name, protseq))
3592  return &conn_protseq_list[i];
3593  return NULL;
3594 }
static const struct connection_ops conn_protseq_list[]
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
#define NULL
Definition: types.h:112
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by RpcNetworkIsProtseqValidW(), RPCRT4_CreateConnection(), RPCRT4_IsServerListening(), and RpcTransport_GetTopOfTower().

◆ rpcrt4_get_protseq_ops()

const struct protseq_ops* rpcrt4_get_protseq_ops ( const char protseq)

Definition at line 3578 of file rpc_transport.c.

3579 {
3580  unsigned int i;
3581  for(i = 0; i < ARRAY_SIZE(protseq_list); i++)
3582  if (!strcmp(protseq_list[i].name, protseq))
3583  return &protseq_list[i];
3584  return NULL;
3585 }
static const struct protseq_ops protseq_list[]
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
#define NULL
Definition: types.h:112
Definition: name.c:38
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by alloc_serverprotoseq().

◆ RPCRT4_GrabConnection()

RpcConnection* RPCRT4_GrabConnection ( RpcConnection connection)

Definition at line 3698 of file rpc_transport.c.

3699 {
3700  LONG ref = InterlockedIncrement(&connection->ref);
3701  TRACE("%p ref=%u\n", connection, ref);
3702  return connection;
3703 }
Definition: send.c:48
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by RPCRT4_io_thread(), and RPCRT4_server_thread().

◆ rpcrt4_http_async_read()

static int rpcrt4_http_async_read ( HINTERNET  req,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
void buffer,
unsigned int  count 
)
static

Definition at line 2324 of file rpc_transport.c.

2326 {
2327  char *buf = buffer;
2328  BOOL ret;
2329  unsigned int bytes_left = count;
2331 
2332  async_data->inet_buffers.lpvBuffer = HeapAlloc(GetProcessHeap(), 0, count);
2333 
2334  while (bytes_left)
2335  {
2336  async_data->inet_buffers.dwBufferLength = bytes_left;
2337  prepare_async_request(async_data);
2338  ret = InternetReadFileExW(req, &async_data->inet_buffers, IRF_ASYNC, 0);
2339  status = wait_async_request(async_data, ret, cancel_event);
2340  if (status != RPC_S_OK)
2341  {
2343  TRACE("call cancelled\n");
2344  break;
2345  }
2346 
2347  if (!async_data->inet_buffers.dwBufferLength)
2348  break;
2349  memcpy(buf, async_data->inet_buffers.lpvBuffer,
2350  async_data->inet_buffers.dwBufferLength);
2351 
2352  bytes_left -= async_data->inet_buffers.dwBufferLength;
2353  buf += async_data->inet_buffers.dwBufferLength;
2354  }
2355 
2356  HeapFree(GetProcessHeap(), 0, async_data->inet_buffers.lpvBuffer);
2357  async_data->inet_buffers.lpvBuffer = NULL;
2358 
2359  TRACE("%p %p %u -> %u\n", req, buffer, count, status);
2360  return status == RPC_S_OK ? count : -1;
2361 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define IRF_ASYNC
Definition: wininet.h:622
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
GLuint buffer
Definition: glext.h:5915
INTERNET_BUFFERSW inet_buffers
DWORD dwBufferLength
Definition: wininet.h:278
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
long RPC_STATUS
Definition: rpc.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define RPC_S_CALL_CANCELLED
Definition: winerror.h:1125
int ret
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:2248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define NULL
Definition: types.h:112
LPVOID lpvBuffer
Definition: wininet.h:277
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22
Definition: ps.c:97

Referenced by drain_content(), rpcrt4_http_prepare_out_pipe(), rpcrt4_http_read_http_packet(), rpcrt4_ncacn_http_read(), and send_echo_request().

◆ rpcrt4_http_check_response()

static RPC_STATUS rpcrt4_http_check_response ( HINTERNET  hor)
static

Definition at line 2163 of file rpc_transport.c.

2164 {
2165  BOOL ret;
2167  DWORD size;
2168  DWORD index;
2169  WCHAR buf[32];
2170  WCHAR *status_text = buf;
2171  TRACE("\n");
2172 
2173  index = 0;
2174  size = sizeof(status_code);
2176  if (!ret)
2177  return GetLastError();
2178  if (status_code == HTTP_STATUS_OK)
2179  return RPC_S_OK;
2180  index = 0;
2181  size = sizeof(buf);
2182  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
2184  {
2185  status_text = HeapAlloc(GetProcessHeap(), 0, size);
2186  ret = HttpQueryInfoW(hor, HTTP_QUERY_STATUS_TEXT, status_text, &size, &index);
2187  }
2188 
2189  ERR("server returned: %d %s\n", status_code, ret ? debugstr_w(status_text) : "<status text unavailable>");
2190  if(status_text != buf) HeapFree(GetProcessHeap(), 0, status_text);
2191 
2193  return ERROR_ACCESS_DENIED;
2194  return RPC_S_SERVER_UNAVAILABLE;
2195 }
#define HTTP_QUERY_STATUS_TEXT
Definition: wininet.h:1543
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
struct status_code status_code
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define HTTP_STATUS_DENIED
Definition: winhttp.h:256
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
int ret
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
#define index(s, c)
Definition: various.h:29
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define ERR(fmt,...)
Definition: debug.h:110
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by authorize_request(), rpcrt4_http_prepare_out_pipe(), rpcrt4_ncacn_http_open(), and send_echo_request().

◆ rpcrt4_http_internet_callback()

static VOID WINAPI rpcrt4_http_internet_callback ( HINTERNET  hInternet,
DWORD_PTR  dwContext,
DWORD  dwInternetStatus,
LPVOID  lpvStatusInformation,
DWORD  dwStatusInformationLength 
)
static

Definition at line 2138 of file rpc_transport.c.

2144 {
2145  RpcHttpAsyncData *async_data = (RpcHttpAsyncData *)dwContext;
2146 
2147  switch (dwInternetStatus)
2148  {
2150  TRACE("INTERNET_STATUS_REQUEST_COMPLETED\n");
2151  if (async_data)
2152  {
2153  INTERNET_ASYNC_RESULT *async_result = lpvStatusInformation;
2154 
2155  async_data->async_result = async_result->dwResult ? ERROR_SUCCESS : async_result->dwError;
2156  SetEvent(async_data->completion_event);
2157  RpcHttpAsyncData_Release(async_data);
2158  }
2159  break;
2160  }
2161 }
#define ERROR_SUCCESS
Definition: deptool.c:10
static ULONG RpcHttpAsyncData_Release(RpcHttpAsyncData *data)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define TRACE(s)
Definition: solgame.cpp:4
DWORD_PTR dwResult
Definition: wininet.h:155
#define INTERNET_STATUS_REQUEST_COMPLETE
Definition: wininet.h:898

Referenced by rpcrt4_http_internet_connect().

◆ rpcrt4_http_internet_connect()

static RPC_STATUS rpcrt4_http_internet_connect ( RpcConnection_http httpc)
static

Definition at line 2197 of file rpc_transport.c.

2198 {
2199  static const WCHAR wszUserAgent[] = {'M','S','R','P','C',0};
2200  LPWSTR proxy = NULL;
2201  LPWSTR user = NULL;
2202  LPWSTR password = NULL;
2203  LPWSTR servername = NULL;
2204  const WCHAR *option;
2206 
2207  if (httpc->common.QOS &&
2209  {
2210  const RPC_HTTP_TRANSPORT_CREDENTIALS_W *http_cred = httpc->common.QOS->qos->u.HttpCredentials;
2211  if (http_cred->TransportCredentials)
2212  {
2213  WCHAR *p;
2214  const SEC_WINNT_AUTH_IDENTITY_W *cred = http_cred->TransportCredentials;
2215  ULONG len = cred->DomainLength + 1 + cred->UserLength;
2216  user = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
2217  if (!user)
2218  return RPC_S_OUT_OF_RESOURCES;
2219  p = user;
2220  if (cred->DomainLength)
2221  {
2222  memcpy(p, cred->Domain, cred->DomainLength * sizeof(WCHAR));
2223  p += cred->DomainLength;
2224  *p = '\\';
2225  p++;
2226  }
2227  memcpy(p, cred->User, cred->UserLength * sizeof(WCHAR));
2228  p[cred->UserLength] = 0;
2229 
2231  }
2232  }
2233 
2234  for (option = httpc->common.NetworkOptions; option;
2235  option = (wcschr(option, ',') ? wcschr(option, ',')+1 : NULL))
2236  {
2237  static const WCHAR wszRpcProxy[] = {'R','p','c','P','r','o','x','y','=',0};
2238  static const WCHAR wszHttpProxy[] = {'H','t','t','p','P','r','o','x','y','=',0};
2239 
2240  if (!_wcsnicmp(option, wszRpcProxy, ARRAY_SIZE(wszRpcProxy)-1))
2241  {
2242  const WCHAR *value_start = option + ARRAY_SIZE(wszRpcProxy)-1;
2243  const WCHAR *value_end;
2244  const WCHAR *p;
2245 
2246  value_end = wcschr(option, ',');
2247  if (!value_end)
2248  value_end = value_start + lstrlenW(value_start);
2249  for (p = value_start; p < value_end; p++)
2250  if (*p == ':')
2251  {
2252  port = wcstol(p+1, NULL, 10);
2253  value_end = p;
2254  break;
2255  }
2256  TRACE("RpcProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2257  servername = RPCRT4_strndupW(value_start, value_end-value_start);
2258  }
2259  else if (!_wcsnicmp(option, wszHttpProxy, ARRAY_SIZE(wszHttpProxy)-1))
2260  {
2261  const WCHAR *value_start = option + ARRAY_SIZE(wszHttpProxy)-1;
2262  const WCHAR *value_end;
2263 
2264  value_end = wcschr(option, ',');
2265  if (!value_end)
2266  value_end = value_start + lstrlenW(value_start);
2267  TRACE("HttpProxy value is %s\n", debugstr_wn(value_start, value_end-value_start));
2268  proxy = RPCRT4_strndupW(value_start, value_end-value_start);
2269  }
2270  else
2271  FIXME("unhandled option %s\n", debugstr_w(option));
2272  }
2273 
2276  if (!httpc->app_info)
2277  {
2279  HeapFree(GetProcessHeap(), 0, user);
2280  HeapFree(GetProcessHeap(), 0, proxy);
2281  HeapFree(GetProcessHeap(), 0, servername);
2282  ERR("InternetOpenW failed with error %d\n", GetLastError());
2283  return RPC_S_SERVER_UNAVAILABLE;
2284  }
2286 
2287  /* if no RpcProxy option specified, set the HTTP server address to the
2288  * RPC server address */
2289  if (!servername)
2290  {
2291  servername = HeapAlloc(GetProcessHeap(), 0, (strlen(httpc->common.NetworkAddr) + 1)*sizeof(WCHAR));
2292  if (!servername)
2293  {
2295  HeapFree(GetProcessHeap(), 0, user);
2296  HeapFree(GetProcessHeap(), 0, proxy);
2297  return RPC_S_OUT_OF_RESOURCES;
2298  }
2299  MultiByteToWideChar(CP_ACP, 0, httpc->common.NetworkAddr, -1, servername, strlen(httpc->common.NetworkAddr) + 1);
2300  }
2301 
2302  port = (httpc->common.QOS &&
2306 
2307  httpc->session = InternetConnectW(httpc->app_info, servername, port, user, password,
2308  INTERNET_SERVICE_HTTP, 0, 0);
2309 
2311  HeapFree(GetProcessHeap(), 0, user);
2312  HeapFree(GetProcessHeap(), 0, proxy);
2313 
2314  if (!httpc->session)
2315  {
2316  ERR("InternetConnectW failed with error %d\n", GetLastError());
2317  HeapFree(GetProcessHeap(), 0, servername);
2318  return RPC_S_SERVER_UNAVAILABLE;
2319  }
2320  httpc->servername = servername;
2321  return RPC_S_OK;
2322 }
unsigned short * Domain
Definition: rpcdce.h:225
int proxy
Definition: main.c:67
union _RPC_SECURITY_QOS_V2_W::@3167 u
static VOID WINAPI rpcrt4_http_internet_callback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
unsigned short * User
Definition: rpcdce.h:223
SEC_WINNT_AUTH_IDENTITY_W * TransportCredentials
Definition: rpcdce.h:245
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned short * Password
Definition: rpcdce.h:227
#define CP_ACP
Definition: compat.h:109
RpcConnection common
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
RPC_HTTP_TRANSPORT_CREDENTIALS_W * HttpCredentials
Definition: rpcdce.h:279
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
#define lstrlenW
Definition: compat.h:609
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
WORD INTERNET_PORT
Definition: winhttp.h:38
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
Definition: getopt.h:108
GLuint GLenum option
Definition: glext.h:11211
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(HINTERNET hInternet, INTERNET_STATUS_CALLBACK lpfnIntCB)
Definition: internet.c:2075
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPWSTR NetworkOptions
Definition: rpc_binding.h:69
LPSTR NetworkAddr
Definition: rpc_binding.h:67
#define INTERNET_FLAG_ASYNC
Definition: wininet.h:64
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
RPC_SECURITY_QOS_V2_W * qos
Definition: rpc_binding.h:57
#define debugstr_wn
Definition: kernel32.h:33
#define ERR(fmt,...)
Definition: debug.h:110
#define INTERNET_DEFAULT_HTTPS_PORT
Definition: winhttp.h:37
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
ULONG AdditionalSecurityInfoType
Definition: rpcdce.h:276
#define ARRAY_SIZE(a)
Definition: main.h:24
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define RPC_C_HTTP_FLAG_USE_SSL
Definition: rpcdce.h:198
unsigned int ULONG
Definition: retypes.h:1
#define RPC_C_AUTHN_INFO_TYPE_HTTP
Definition: rpcdce.h:195
RpcQualityOfService * QOS
Definition: rpc_binding.h:81
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1258
LPWSTR RPCRT4_strndupW(LPCWSTR src, INT slen)
Definition: rpc_binding.c:91
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
USHORT port
Definition: uri.c:228
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
void user(int argc, const char *argv[])
Definition: cmds.c:1350
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_http_keep_connection_active_timer_proc()

static VOID rpcrt4_http_keep_connection_active_timer_proc ( PVOID  param,
BOOLEAN  dummy 
)
static

Definition at line 2093 of file rpc_transport.c.

2094 {
2095  HINTERNET in_request = param;
2096  RpcPktHdr *idle_pkt;
2097 
2099  0, 0);
2100  if (idle_pkt)
2101  {
2102  DWORD bytes_written;
2103  InternetWriteFile(in_request, idle_pkt, idle_pkt->common.frag_len, &bytes_written);
2104  RPCRT4_FreeHeader(idle_pkt);
2105  }
2106 }
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
RpcPktCommonHdr common
Definition: rpc_defs.h:152
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2114
unsigned short frag_len
Definition: rpc_defs.h:33
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NDR_LOCAL_DATA_REPRESENTATION
Definition: rpcndr.h:107
RpcPktHdr * RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size)
Definition: rpc_message.c:291

Referenced by rpcrt4_http_timer_thread().

◆ rpcrt4_http_prepare_in_pipe()

static RPC_STATUS rpcrt4_http_prepare_in_pipe ( HINTERNET  in_request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
const UUID connection_uuid,
const UUID in_pipe_uuid,
const UUID association_uuid,
BOOL  authorized 
)
static

Definition at line 2397 of file rpc_transport.c.

2400 {
2401  BOOL ret;
2403  RpcPktHdr *hdr;
2404  INTERNET_BUFFERSW buffers_in;
2405  DWORD bytes_written;
2406 
2407  if (!authorized)
2408  {
2409  /* ask wininet to authorize, if necessary */
2410  status = send_echo_request(in_request, async_data, cancel_event);
2411  if (status != RPC_S_OK) return status;
2412  }
2413  memset(&buffers_in, 0, sizeof(buffers_in));
2414  buffers_in.dwStructSize = sizeof(buffers_in);
2415  /* FIXME: get this from the registry */
2416  buffers_in.dwBufferTotal = 1024 * 1024 * 1024; /* 1Gb */
2417  status = insert_content_length_header(in_request, buffers_in.dwBufferTotal);
2418  if (status != RPC_S_OK) return status;
2419 
2420  prepare_async_request(async_data);
2421  ret = HttpSendRequestExW(in_request, &buffers_in, NULL, 0, 0);
2422  status = wait_async_request(async_data, ret, cancel_event);
2423  if (status != RPC_S_OK) return status;
2424 
2425  TRACE("sending HTTP connect header to server\n");
2426  hdr = RPCRT4_BuildHttpConnectHeader(FALSE, connection_uuid, in_pipe_uuid, association_uuid);
2427  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2428  ret = InternetWriteFile(in_request, hdr, hdr->common.frag_len, &bytes_written);
2430  if (!ret)
2431  {
2432  ERR("InternetWriteFile failed with error %d\n", GetLastError());
2433  return RPC_S_SERVER_UNAVAILABLE;
2434  }
2435 
2436  return RPC_S_OK;
2437 }
DWORD dwStructSize
Definition: wininet.h:272
static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
char hdr[14]
Definition: iptest.cpp:33
DWORD dwBufferTotal
Definition: wininet.h:279
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
long RPC_STATUS
Definition: rpc.h:52
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:344
BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest, LPINTERNET_BUFFERSW lpBuffersIn, LPINTERNET_BUFFERSW lpBuffersOut, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:5500
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
Definition: internet.c:2114
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ERR(fmt,...)
Definition: debug.h:110
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define NULL
Definition: types.h:112
#define memset(x, y, z)
Definition: compat.h:39
static SERVICE_STATUS status
Definition: service.c:31
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
Definition: ps.c:97

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_http_prepare_out_pipe()

static RPC_STATUS rpcrt4_http_prepare_out_pipe ( HINTERNET  out_request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
const UUID connection_uuid,
const UUID out_pipe_uuid,
ULONG flow_control_increment,
BOOL  authorized 
)
static

Definition at line 2484 of file rpc_transport.c.

2488 {
2489  BOOL ret;
2491  RpcPktHdr *hdr;
2492  BYTE *data_from_server;
2493  RpcPktHdr pkt_from_server;
2494  ULONG field1, field3;
2495  BYTE buf[20];
2496 
2497  if (!authorized)
2498  {
2499  /* ask wininet to authorize, if necessary */
2500  status = send_echo_request(out_request, async_data, cancel_event);
2501  if (status != RPC_S_OK) return status;
2502  }
2503  else
2504  rpcrt4_http_async_read(out_request, async_data, cancel_event, buf, sizeof(buf));
2505 
2506  hdr = RPCRT4_BuildHttpConnectHeader(TRUE, connection_uuid, out_pipe_uuid, NULL);
2507  if (!hdr) return RPC_S_OUT_OF_RESOURCES;
2508 
2509  status = insert_content_length_header(out_request, hdr->common.frag_len);
2510  if (status != RPC_S_OK)
2511  {
2513  return status;
2514  }
2515 
2516  TRACE("sending HTTP connect header to server\n");
2517  prepare_async_request(async_data);
2518  ret = HttpSendRequestW(out_request, NULL, 0, hdr, hdr->common.frag_len);
2519  status = wait_async_request(async_data, ret, cancel_event);
2521  if (status != RPC_S_OK) return status;
2522 
2523  status = rpcrt4_http_check_response(out_request);
2524  if (status != RPC_S_OK) return status;
2525 
2526  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2527  &pkt_from_server, &data_from_server);
2528  if (status != RPC_S_OK) return status;
2529  status = RPCRT4_ParseHttpPrepareHeader1(&pkt_from_server, data_from_server,
2530  &field1);
2531  HeapFree(GetProcessHeap(), 0, data_from_server);
2532  if (status != RPC_S_OK) return status;
2533  TRACE("received (%d) from first prepare header\n", field1);
2534 
2535  for (;;)
2536  {
2537  status = rpcrt4_http_read_http_packet(out_request, async_data, cancel_event,
2538  &pkt_from_server, &data_from_server);
2539  if (status != RPC_S_OK) return status;
2540  if (pkt_from_server.http.flags != 0x0001) break;
2541 
2542  TRACE("http idle packet, waiting for real packet\n");
2543  HeapFree(GetProcessHeap(), 0, data_from_server);
2544  if (pkt_from_server.http.num_data_items != 0)
2545  {
2546  ERR("HTTP idle packet should have no data items instead of %d\n",
2547  pkt_from_server.http.num_data_items);
2548  return RPC_S_PROTOCOL_ERROR;
2549  }
2550  }
2551  status = RPCRT4_ParseHttpPrepareHeader2(&pkt_from_server, data_from_server,
2552  &field1, flow_control_increment,
2553  &field3);
2554  HeapFree(GetProcessHeap(), 0, data_from_server);
2555  if (status != RPC_S_OK) return status;
2556  TRACE("received (0x%08x 0x%08x %d) from second prepare header\n", field1, *flow_control_increment, field3);
2557 
2558  return RPC_S_OK;
2559 }
static RPC_STATUS send_echo_request(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event)
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
char hdr[14]
Definition: iptest.cpp:33
RPC_STATUS RPCRT4_ParseHttpPrepareHeader1(RpcPktHdr *header, unsigned char *data, ULONG *field1)
Definition: rpc_message.c:566
#define TRUE
Definition: types.h:120
VOID RPCRT4_FreeHeader(RpcPktHdr *Header)
Definition: rpc_message.c:403
static RPC_STATUS wait_async_request(RpcHttpAsyncData *async_data, BOOL call_ret, HANDLE cancel_event)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
long RPC_STATUS
Definition: rpc.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short flags
Definition: rpc_defs.h:138
RpcPktHdr * RPCRT4_BuildHttpConnectHeader(int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
Definition: rpc_message.c:344
static RPC_STATUS rpcrt4_http_read_http_packet(HINTERNET request, RpcHttpAsyncData *async_data, HANDLE cancel_event, RpcPktHdr *hdr, BYTE **data)
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5595
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
static void prepare_async_request(RpcHttpAsyncData *async_data)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
int ret
RPC_STATUS RPCRT4_ParseHttpPrepareHeader2(RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3)
Definition: rpc_message.c:591
unsigned char BYTE
Definition: xxhash.c:193
RpcPktHttpHdr http
Definition: rpc_defs.h:159
#define ERR(fmt,...)
Definition: debug.h:110
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
static RPC_STATUS rpcrt4_http_check_response(HINTERNET hor)
unsigned short num_data_items
Definition: rpc_defs.h:139
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22
static RPC_STATUS insert_content_length_header(HINTERNET request, DWORD len)
Definition: ps.c:97

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_http_read_http_packet()

static RPC_STATUS rpcrt4_http_read_http_packet ( HINTERNET  request,
RpcHttpAsyncData async_data,
HANDLE  cancel_event,
RpcPktHdr hdr,
BYTE **  data 
)
static

Definition at line 2439 of file rpc_transport.c.

2441 {
2442  unsigned short data_len;
2443  unsigned int size;
2444 
2445  if (rpcrt4_http_async_read(request, async_data, cancel_event, hdr, sizeof(hdr->common)) < 0)
2446  return RPC_S_SERVER_UNAVAILABLE;
2447  if (hdr->common.ptype != PKT_HTTP || hdr->common.frag_len < sizeof(hdr->http))
2448  {
2449  ERR("wrong packet type received %d or wrong frag_len %d\n",
2450  hdr->common.ptype, hdr->common.frag_len);
2451  return RPC_S_PROTOCOL_ERROR;
2452  }
2453 
2454  size = sizeof(hdr->http) - sizeof(hdr->common);
2455  if (rpcrt4_http_async_read(request, async_data, cancel_event, &hdr->common + 1, size) < 0)
2456  return RPC_S_SERVER_UNAVAILABLE;
2457 
2458  data_len = hdr->common.frag_len - sizeof(hdr->http);
2459  if (data_len)
2460  {
2461  *data = HeapAlloc(GetProcessHeap(), 0, data_len);
2462  if (!*data)
2463  return RPC_S_OUT_OF_RESOURCES;
2464  if (rpcrt4_http_async_read(request, async_data, cancel_event, *data, data_len) < 0)
2465  {
2466  HeapFree(GetProcessHeap(), 0, *data);
2467  return RPC_S_SERVER_UNAVAILABLE;
2468  }
2469  }
2470  else
2471  *data = NULL;
2472 
2473  if (!RPCRT4_IsValidHttpPacket(hdr, *data, data_len))
2474  {
2475  ERR("invalid http packet\n");
2476  HeapFree(GetProcessHeap(), 0, *data);
2477  return RPC_S_PROTOCOL_ERROR;
2478  }
2479 
2480  return RPC_S_OK;
2481 }
static int rpcrt4_http_async_read(HINTERNET req, RpcHttpAsyncData *async_data, HANDLE cancel_event, void *buffer, unsigned int count)
char hdr[14]
Definition: iptest.cpp:33
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1039
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ERR(fmt,...)
Definition: debug.h:110
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1032
#define NULL
Definition: types.h:112
Definition: tftpd.h:85
BOOL RPCRT4_IsValidHttpPacket(RpcPktHdr *hdr, unsigned char *data, unsigned short data_len)
Definition: rpc_message.c:483
#define HeapFree(x, y, z)
Definition: compat.h:594
#define RPC_S_OK
Definition: rpcnterr.h:22

Referenced by rpcrt4_http_prepare_out_pipe().

◆ rpcrt4_http_timer_calc_timeout()

static DWORD rpcrt4_http_timer_calc_timeout ( DWORD last_sent_time)
inlinestatic

Definition at line 2108 of file rpc_transport.c.

2109 {
2111  DWORD cached_last_sent_time = *last_sent_time;
2112  return HTTP_IDLE_TIME - (cur_time - cached_last_sent_time > HTTP_IDLE_TIME ? 0 : cur_time - cached_last_sent_time);
2113 }
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
time_t cur_time
#define HTTP_IDLE_TIME
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by rpcrt4_http_timer_thread().

◆ rpcrt4_http_timer_thread()

static DWORD CALLBACK rpcrt4_http_timer_thread ( PVOID  param)
static

Definition at line 2115 of file rpc_transport.c.

2116 {
2117  HttpTimerThreadData *data_in = param;
2119  DWORD timeout;
2120 
2121  data = *data_in;
2122  HeapFree(GetProcessHeap(), 0, data_in);
2123 
2124  for (timeout = HTTP_IDLE_TIME;
2125  WaitForSingleObject(data.timer_cancelled, timeout) == WAIT_TIMEOUT;
2126  timeout = rpcrt4_http_timer_calc_timeout(data.last_sent_time))
2127  {
2128  /* are we too soon after last send? */
2129  if (GetTickCount() - *data.last_sent_time < HTTP_IDLE_TIME)
2130  continue;
2132  }
2133 
2134  CloseHandle(data.timer_cancelled);
2135  return 0;
2136 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
#define HTTP_IDLE_TIME
Definition: dhcpd.h:245
GLbitfield GLuint64 timeout
Definition: glext.h:7164
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define GetProcessHeap()
Definition: compat.h:595
GLfloat param
Definition: glext.h:5796
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define WAIT_TIMEOUT
Definition: dderror.h:14
static VOID rpcrt4_http_keep_connection_active_timer_proc(PVOID param, BOOLEAN dummy)
static DWORD rpcrt4_http_timer_calc_timeout(DWORD *last_sent_time)
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by rpcrt4_ncacn_http_open().

◆ rpcrt4_ip_tcp_get_top_of_tower()

static size_t rpcrt4_ip_tcp_get_top_of_tower ( unsigned char tower_data,
const char networkaddr,
unsigned char  tcp_protid,
const char endpoint 
)
static

Definition at line 1220 of file rpc_transport.c.

1224 {
1225  twr_tcp_floor_t *tcp_floor;
1226  twr_ipv4_floor_t *ipv4_floor;
1227  struct addrinfo *ai;
1228  struct addrinfo hints;
1229  int ret;
1230  size_t size = sizeof(*tcp_floor) + sizeof(*ipv4_floor);
1231 
1232  TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
1233 
1234  if (!tower_data)
1235  return size;
1236 
1237  tcp_floor = (twr_tcp_floor_t *)tower_data;
1238  tower_data += sizeof(*tcp_floor);
1239 
1240  ipv4_floor = (twr_ipv4_floor_t *)tower_data;
1241 
1242  tcp_floor->count_lhs = sizeof(tcp_floor->protid);
1243  tcp_floor->protid = tcp_protid;
1244  tcp_floor->count_rhs = sizeof(tcp_floor->port);
1245 
1246  ipv4_floor->count_lhs = sizeof(ipv4_floor->protid);
1247  ipv4_floor->protid = EPM_PROTOCOL_IP;
1248  ipv4_floor->count_rhs = sizeof(ipv4_floor->ipv4addr);
1249 
1250  hints.ai_flags = AI_NUMERICHOST;
1251  /* FIXME: only support IPv4 at the moment. how is IPv6 represented by the EPM? */
1252  hints.ai_family = PF_INET;
1253  hints.ai_socktype = SOCK_STREAM;
1254  hints.ai_protocol = IPPROTO_TCP;
1255  hints.ai_addrlen = 0;
1256  hints.ai_addr = NULL;
1257  hints.ai_canonname = NULL;
1258  hints.ai_next = NULL;
1259 
1260  ret = getaddrinfo(networkaddr, endpoint, &hints, &ai);
1261  if (ret)
1262  {
1263  ret = getaddrinfo("0.0.0.0", endpoint, &hints, &ai);
1264  if (ret)
1265  {
1266  ERR("getaddrinfo failed: %s\n", gai_strerror(ret));
1267  return 0;
1268  }
1269  }
1270 
1271  if (ai->ai_family == PF_INET)
1272  {
1273  const struct sockaddr_in *sin = (const struct sockaddr_in *)ai->ai_addr;
1274  tcp_floor->port = sin->sin_port;
1275  ipv4_floor->ipv4addr = sin->sin_addr.s_addr;
1276  }
1277  else
1278  {
1279  ERR("unexpected protocol family %d\n", ai->ai_family);
1280  freeaddrinfo(ai);
1281  return 0;
1282  }
1283 
1284  freeaddrinfo(ai);
1285 
1286  return size;
1287 }
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80
#define freeaddrinfo
Definition: wspiapi.h:46
u_int16 port
Definition: epm_towers.h:70
#define EPM_PROTOCOL_IP
Definition: epm_towers.h:31
#define PF_INET
Definition: winsock.h:373
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define gai_strerror
Definition: ws2tcpip.h:521
int ret
#define ERR(fmt,...)
Definition: debug.h:110
u_int16 count_lhs
Definition: epm_towers.h:67
#define AI_NUMERICHOST
Definition: ws2def.h:295
Definition: nis.h:10
u_int16 count_rhs
Definition: epm_towers.h:69
#define NULL
Definition: types.h:112
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define SOCK_STREAM
Definition: tcpip.h:118
struct sockaddr * ai_addr
Definition: ws2def.h:671
#define getaddrinfo
Definition: wspiapi.h:44
int ai_family
Definition: ws2def.h:666

Referenced by rpcrt4_ncacn_http_get_top_of_tower(), and rpcrt4_ncacn_ip_tcp_get_top_of_tower().

◆ rpcrt4_ip_tcp_parse_top_of_tower()

static RPC_STATUS rpcrt4_ip_tcp_parse_top_of_tower ( const unsigned char tower_data,
size_t  tower_size,
char **  networkaddr,
unsigned char  tcp_protid,
char **  endpoint 
)
static

Definition at line 1289 of file rpc_transport.c.

1294 {
1295  const twr_tcp_floor_t *tcp_floor = (const twr_tcp_floor_t *)tower_data;
1296  const twr_ipv4_floor_t *ipv4_floor;
1297  struct in_addr in_addr;
1298 
1299  TRACE("(%p, %d, %p, %p)\n", tower_data, (int)tower_size, networkaddr, endpoint);
1300 
1301  if (tower_size < sizeof(*tcp_floor))
1302  return EPT_S_NOT_REGISTERED;
1303 
1304  tower_data += sizeof(*tcp_floor);
1305  tower_size -= sizeof(*tcp_floor);
1306 
1307  if (tower_size < sizeof(*ipv4_floor))
1308  return EPT_S_NOT_REGISTERED;
1309 
1310  ipv4_floor = (const twr_ipv4_floor_t *)tower_data;
1311 
1312  if ((tcp_floor->count_lhs != sizeof(tcp_floor->protid)) ||
1313  (tcp_floor->protid != tcp_protid) ||
1314  (tcp_floor->count_rhs != sizeof(tcp_floor->port)) ||
1315  (ipv4_floor->count_lhs != sizeof(ipv4_floor->protid)) ||
1316  (ipv4_floor->protid != EPM_PROTOCOL_IP) ||
1317  (ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
1318  return EPT_S_NOT_REGISTERED;
1319 
1320  if (endpoint)
1321  {
1322  *endpoint = I_RpcAllocate(6 /* sizeof("65535") + 1 */);
1323  if (!*endpoint)
1324  return RPC_S_OUT_OF_RESOURCES;
1325  sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
1326  }
1327 
1328  if (networkaddr)
1329  {
1330  *networkaddr = I_RpcAllocate(INET_ADDRSTRLEN);
1331  if (!*networkaddr)
1332  {
1333  if (endpoint)
1334  {
1335  I_RpcFree(*endpoint);
1336  *endpoint = NULL;
1337  }
1338  return RPC_S_OUT_OF_RESOURCES;
1339  }
1340  in_addr.s_addr = ipv4_floor->ipv4addr;
1341  if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
1342  {
1343  ERR("inet_ntop: %u\n", WSAGetLastError());
1344  I_RpcFree(*networkaddr);
1345  *networkaddr = NULL;
1346  if (endpoint)
1347  {
1348&