ReactOS 0.4.16-dev-1946-g52006dd
rpc_message.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winuser.h"
#include "rpc.h"
#include "rpcndr.h"
#include "rpcdcep.h"
#include "wine/debug.h"
#include "rpc_binding.h"
#include "rpc_defs.h"
#include "rpc_message.h"
#include "rpc_assoc.h"
#include "ncastatus.h"
Include dependency graph for rpc_message.c:

Go to the source code of this file.

Macros

#define AUTH_ALIGNMENT   16
 
#define ROUND_UP_AMOUNT(value, alignment)    (((alignment) - (((value) % (alignment)))) % (alignment))
 
#define ROUND_UP(value, alignment)   (((value) + ((alignment) - 1)) & ~((alignment)-1))
 
#define WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, type, value)
 
#define WRITE_HTTP_PAYLOAD_FIELD_UUID(payload, type, uuid)
 
#define WRITE_HTTP_PAYLOAD_FIELD_FLOW_CONTROL(payload, bytes_transmitted, flow_control_increment, uuid)
 
#define READ_HTTP_PAYLOAD_FIELD_TYPE(data)   *(ULONG *)(data)
 
#define GET_HTTP_PAYLOAD_FIELD_DATA(data)   ((data) + sizeof(ULONG))
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (rpc)
 
static RPC_STATUS I_RpcReAllocateBuffer (PRPC_MESSAGE pMsg)
 
DWORD RPCRT4_GetHeaderSize (const RpcPktHdr *Header)
 
static BOOL packet_has_body (const RpcPktHdr *Header)
 
static BOOL packet_has_auth_verifier (const RpcPktHdr *Header)
 
static BOOL packet_does_auth_negotiation (const RpcPktHdr *Header)
 
static VOID RPCRT4_BuildCommonHeader (RpcPktCommonHdr *Header, unsigned char PacketType, ULONG DataRepresentation)
 
static RpcPktHdrRPCRT4_BuildRequestHeader (ULONG DataRepresentation, ULONG BufferLength, unsigned short ProcNum, UUID *ObjectUuid)
 
RpcPktHdrRPCRT4_BuildResponseHeader (ULONG DataRepresentation, ULONG BufferLength)
 
RpcPktHdrRPCRT4_BuildFaultHeader (ULONG DataRepresentation, RPC_STATUS Status)
 
RpcPktHdrRPCRT4_BuildBindHeader (ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, const RPC_SYNTAX_IDENTIFIER *AbstractId, const RPC_SYNTAX_IDENTIFIER *TransferId)
 
static RpcPktHdrRPCRT4_BuildAuthHeader (ULONG DataRepresentation)
 
RpcPktHdrRPCRT4_BuildBindNackHeader (ULONG DataRepresentation, unsigned char RpcVersion, unsigned char RpcVersionMinor, unsigned short RejectReason)
 
RpcPktHdrRPCRT4_BuildBindAckHeader (ULONG DataRepresentation, unsigned short MaxTransmissionSize, unsigned short MaxReceiveSize, ULONG AssocGroupId, LPCSTR ServerAddress, unsigned char ResultCount, const RpcResult *Results)
 
RpcPktHdrRPCRT4_BuildHttpHeader (ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size)
 
RpcPktHdrRPCRT4_BuildHttpConnectHeader (int out_pipe, const UUID *connection_uuid, const UUID *pipe_uuid, const UUID *association_uuid)
 
RpcPktHdrRPCRT4_BuildHttpFlowControlHeader (BOOL server, ULONG bytes_transmitted, ULONG flow_control_increment, const UUID *pipe_uuid)
 
NCA_STATUS RPC2NCA_STATUS (RPC_STATUS status)
 
static RPC_STATUS NCA2RPC_STATUS (NCA_STATUS status)
 
BOOL RPCRT4_IsValidHttpPacket (RpcPktHdr *hdr, unsigned char *data, unsigned short data_len)
 
static unsigned charRPCRT4_NextHttpHeaderField (unsigned char *data)
 
RPC_STATUS RPCRT4_ParseHttpPrepareHeader1 (RpcPktHdr *header, unsigned char *data, ULONG *field1)
 
RPC_STATUS RPCRT4_ParseHttpPrepareHeader2 (RpcPktHdr *header, unsigned char *data, ULONG *field1, ULONG *bytes_until_next_packet, ULONG *field3)
 
RPC_STATUS RPCRT4_ParseHttpFlowControlHeader (RpcPktHdr *header, unsigned char *data, BOOL server, ULONG *bytes_transmitted, ULONG *flow_control_increment, UUID *pipe_uuid)
 
RPC_STATUS RPCRT4_default_secure_packet (RpcConnection *Connection, enum secure_packet_direction dir, RpcPktHdr *hdr, unsigned int hdr_size, unsigned char *stub_data, unsigned int stub_data_size, RpcAuthVerifier *auth_hdr, unsigned char *auth_value, unsigned int auth_value_size)
 
RPC_STATUS RPCRT4_SendWithAuth (RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength, const void *Auth, unsigned int AuthLength)
 
RPC_STATUS RPCRT4_default_authorize (RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_size, unsigned char *out_buffer, unsigned int *out_size)
 
RPC_STATUS RPCRT4_ClientConnectionAuth (RpcConnection *conn, BYTE *challenge, ULONG count)
 
RPC_STATUS RPCRT4_ServerConnectionAuth (RpcConnection *conn, BOOL start, RpcAuthVerifier *auth_data_in, ULONG auth_length_in, unsigned char **auth_data_out, ULONG *auth_length_out)
 
BOOL RPCRT4_default_is_authorized (RpcConnection *Connection)
 
RPC_STATUS RPCRT4_default_impersonate_client (RpcConnection *conn)
 
RPC_STATUS RPCRT4_default_revert_to_self (RpcConnection *conn)
 
RPC_STATUS RPCRT4_default_inquire_auth_client (RpcConnection *conn, RPC_AUTHZ_HANDLE *privs, RPC_WSTR *server_princ_name, ULONG *authn_level, ULONG *authn_svc, ULONG *authz_svc, ULONG flags)
 
RPC_STATUS RPCRT4_Send (RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength)
 
RPC_STATUS RPCRT4_ValidateCommonHeader (const RpcPktCommonHdr *hdr)
 
static RPC_STATUS RPCRT4_default_receive_fragment (RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
 
static RPC_STATUS RPCRT4_receive_fragment (RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
 
RPC_STATUS RPCRT4_ReceiveWithAuth (RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, ULONG *auth_length_out)
 
static RPC_STATUS RPCRT4_Receive (RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg)
 
RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax (PRPC_MESSAGE pMsg)
 
RPC_STATUS WINAPI I_RpcGetBuffer (PRPC_MESSAGE pMsg)
 
RPC_STATUS WINAPI I_RpcFreeBuffer (PRPC_MESSAGE pMsg)
 
static void CALLBACK async_apc_notifier_proc (ULONG_PTR ulParam)
 
static DWORD WINAPI async_notifier_proc (LPVOID p)
 
RPC_STATUS WINAPI I_RpcSend (PRPC_MESSAGE pMsg)
 
static BOOL is_hard_error (RPC_STATUS status)
 
RPC_STATUS WINAPI I_RpcReceive (PRPC_MESSAGE pMsg)
 
RPC_STATUS WINAPI I_RpcSendReceive (PRPC_MESSAGE pMsg)
 
RPC_STATUS WINAPI I_RpcAsyncSetHandle (PRPC_MESSAGE pMsg, PRPC_ASYNC_STATE pAsync)
 
RPC_STATUS WINAPI I_RpcAsyncAbortCall (PRPC_ASYNC_STATE pAsync, ULONG ExceptionCode)
 

Macro Definition Documentation

◆ AUTH_ALIGNMENT

#define AUTH_ALIGNMENT   16

Definition at line 49 of file rpc_message.c.

◆ GET_HTTP_PAYLOAD_FIELD_DATA

#define GET_HTTP_PAYLOAD_FIELD_DATA (   data)    ((data) + sizeof(ULONG))

Definition at line 559 of file rpc_message.c.

◆ READ_HTTP_PAYLOAD_FIELD_TYPE

#define READ_HTTP_PAYLOAD_FIELD_TYPE (   data)    *(ULONG *)(data)

Definition at line 558 of file rpc_message.c.

◆ ROUND_UP

#define ROUND_UP (   value,
  alignment 
)    (((value) + ((alignment) - 1)) & ~((alignment)-1))

Definition at line 54 of file rpc_message.c.

◆ ROUND_UP_AMOUNT

#define ROUND_UP_AMOUNT (   value,
  alignment 
)     (((alignment) - (((value) % (alignment)))) % (alignment))

Definition at line 52 of file rpc_message.c.

◆ WRITE_HTTP_PAYLOAD_FIELD_FLOW_CONTROL

#define WRITE_HTTP_PAYLOAD_FIELD_FLOW_CONTROL (   payload,
  bytes_transmitted,
  flow_control_increment,
  uuid 
)
Value:
do { \
*(unsigned int *)(payload) = 0x00000001; \
(payload) += 4; \
*(unsigned int *)(payload) = (bytes_transmitted); \
(payload) += 4; \
*(unsigned int *)(payload) = (flow_control_increment); \
(payload) += 4; \
*(UUID *)(payload) = (uuid); \
(payload) += sizeof(UUID); \
} while (0)
Definition: msctf.idl:532

Definition at line 333 of file rpc_message.c.

◆ WRITE_HTTP_PAYLOAD_FIELD_UINT32

#define WRITE_HTTP_PAYLOAD_FIELD_UINT32 (   payload,
  type,
  value 
)
Value:
do { \
*(unsigned int *)(payload) = (type); \
(payload) += 4; \
*(unsigned int *)(payload) = (value); \
(payload) += 4; \
} while (0)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: pdh_main.c:96

Definition at line 317 of file rpc_message.c.

◆ WRITE_HTTP_PAYLOAD_FIELD_UUID

#define WRITE_HTTP_PAYLOAD_FIELD_UUID (   payload,
  type,
  uuid 
)
Value:
do { \
*(unsigned int *)(payload) = (type); \
(payload) += 4; \
*(UUID *)(payload) = (uuid); \
(payload) += sizeof(UUID); \
} while (0)

Definition at line 325 of file rpc_message.c.

Function Documentation

◆ async_apc_notifier_proc()

static void CALLBACK async_apc_notifier_proc ( ULONG_PTR  ulParam)
static

Definition at line 1715 of file rpc_message.c.

1716{
1718 state->u.APC.NotificationRoutine(state, NULL, state->Event);
1719}
static int state
Definition: maze.c:121
#define NULL
Definition: types.h:112

Referenced by async_notifier_proc().

◆ async_notifier_proc()

static DWORD WINAPI async_notifier_proc ( LPVOID  p)
static

Definition at line 1721 of file rpc_message.c.

1722{
1723 RpcConnection *conn = p;
1725
1726 if (state && conn->ops->wait_for_incoming_data(conn) != -1)
1727 {
1728 state->Event = RpcCallComplete;
1729 switch (state->NotificationType)
1730 {
1732 TRACE("RpcNotificationTypeEvent %p\n", state->u.hEvent);
1733 SetEvent(state->u.hEvent);
1734 break;
1736 TRACE("RpcNotificationTypeApc %p\n", state->u.APC.hThread);
1738 break;
1740 TRACE("RpcNotificationTypeIoc %p, 0x%lx, 0x%Ix, %p\n",
1741 state->u.IOC.hIOPort, state->u.IOC.dwNumberOfBytesTransferred,
1742 state->u.IOC.dwCompletionKey, state->u.IOC.lpOverlapped);
1743 PostQueuedCompletionStatus(state->u.IOC.hIOPort,
1744 state->u.IOC.dwNumberOfBytesTransferred,
1745 state->u.IOC.dwCompletionKey,
1746 state->u.IOC.lpOverlapped);
1747 break;
1749 TRACE("RpcNotificationTypeHwnd %p 0x%x\n", state->u.HWND.hWnd,
1750 state->u.HWND.Msg);
1751 PostMessageW(state->u.HWND.hWnd, state->u.HWND.Msg, 0, 0);
1752 break;
1754 TRACE("RpcNotificationTypeCallback %p\n", state->u.NotificationRoutine);
1755 state->u.NotificationRoutine(state, NULL, state->Event);
1756 break;
1758 TRACE("RpcNotificationTypeNone\n");
1759 break;
1760 default:
1761 FIXME("unknown NotificationType: %d/0x%x\n", state->NotificationType, state->NotificationType);
1762 break;
1763 }
1764 }
1765
1766 return 0;
1767}
#define FIXME(fmt,...)
Definition: precomp.h:53
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:959
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI PostQueuedCompletionStatus(IN HANDLE CompletionHandle, IN DWORD dwNumberOfBytesTransferred, IN ULONG_PTR dwCompletionKey, IN LPOVERLAPPED lpOverlapped)
Definition: iocompl.c:192
static void CALLBACK async_apc_notifier_proc(ULONG_PTR ulParam)
Definition: rpc_message.c:1715
@ RpcNotificationTypeIoc
Definition: rpcasync.h:107
@ RpcNotificationTypeHwnd
Definition: rpcasync.h:108
@ RpcNotificationTypeApc
Definition: rpcasync.h:106
@ RpcNotificationTypeEvent
Definition: rpcasync.h:105
@ RpcNotificationTypeNone
Definition: rpcasync.h:104
@ RpcNotificationTypeCallback
Definition: rpcasync.h:109
@ RpcCallComplete
Definition: rpcasync.h:114
#define TRACE(s)
Definition: solgame.cpp:4
RPC_ASYNC_STATE * async_state
Definition: rpc_binding.h:87
const struct connection_ops * ops
Definition: rpc_binding.h:70
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
uint32_t ULONG_PTR
Definition: typedefs.h:65
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by I_RpcSend().

◆ I_RpcAsyncAbortCall()

RPC_STATUS WINAPI I_RpcAsyncAbortCall ( PRPC_ASYNC_STATE  pAsync,
ULONG  ExceptionCode 
)

Definition at line 1973 of file rpc_message.c.

1974{
1975 FIXME("(%p, %ld): stub\n", pAsync, ExceptionCode);
1977}
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
Definition: cdprocs.h:1774
#define RPC_S_INVALID_ASYNC_HANDLE
Definition: winerror.h:1517

◆ I_RpcAsyncSetHandle()

RPC_STATUS WINAPI I_RpcAsyncSetHandle ( PRPC_MESSAGE  pMsg,
PRPC_ASYNC_STATE  pAsync 
)

Definition at line 1945 of file rpc_message.c.

1946{
1947 RpcBinding* bind = pMsg->Handle;
1948 RpcConnection *conn;
1949
1950 TRACE("(%p, %p)\n", pMsg, pAsync);
1951
1952 if (!bind || bind->server || !pMsg->ReservedForRuntime) return RPC_S_INVALID_BINDING;
1953
1954 conn = pMsg->ReservedForRuntime;
1955 conn->async_state = pAsync;
1956
1957 return RPC_S_OK;
1958}
#define RPC_S_OK
Definition: rpcnterr.h:22
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
void * ReservedForRuntime
Definition: rpcdcep.h:45
RPC_BINDING_HANDLE Handle
Definition: rpcdcep.h:38
#define RPC_S_INVALID_BINDING
Definition: winerror.h:1369

Referenced by do_ndr_async_client_call().

◆ I_RpcFreeBuffer()

RPC_STATUS WINAPI I_RpcFreeBuffer ( PRPC_MESSAGE  pMsg)

Definition at line 1692 of file rpc_message.c.

1693{
1694 RpcBinding* bind = pMsg->Handle;
1695
1696 TRACE("(%p) Buffer=%p\n", pMsg, pMsg->Buffer);
1697
1698 if (!bind)
1699 {
1700 ERR("no binding\n");
1701 return RPC_S_INVALID_BINDING;
1702 }
1703
1704 if (pMsg->ReservedForRuntime)
1705 {
1706 RpcConnection *conn = pMsg->ReservedForRuntime;
1709 pMsg->ReservedForRuntime = NULL;
1710 }
1711 I_RpcFree(pMsg->Buffer);
1712 return RPC_S_OK;
1713}
#define ERR(fmt,...)
Definition: precomp.h:57
RPC_STATUS RPCRT4_CloseBinding(RpcBinding *Binding, RpcConnection *Connection)
Definition: rpc_binding.c:276
RPC_STATUS RPCRT4_ReleaseBinding(RpcBinding *Binding)
Definition: rpc_binding.c:237
void WINAPI I_RpcFree(void *Object)
Definition: rpcrt4_main.c:755
void * Buffer
Definition: rpcdcep.h:40

Referenced by ClientRpcChannelBuffer_FreeBuffer(), NdrFreeBuffer(), and ServerRpcChannelBuffer_FreeBuffer().

◆ I_RpcGetBuffer()

RPC_STATUS WINAPI I_RpcGetBuffer ( PRPC_MESSAGE  pMsg)

Definition at line 1634 of file rpc_message.c.

1635{
1637 RpcBinding* bind = pMsg->Handle;
1638
1639 TRACE("(%p): BufferLength=%d\n", pMsg, pMsg->BufferLength);
1640
1641 if (!bind)
1642 {
1643 WARN("no binding\n");
1644 return RPC_S_INVALID_BINDING;
1645 }
1646
1647 pMsg->Buffer = I_RpcAllocate(pMsg->BufferLength);
1648 TRACE("Buffer=%p\n", pMsg->Buffer);
1649
1650 if (!pMsg->Buffer)
1651 return ERROR_OUTOFMEMORY;
1652
1653 if (!bind->server)
1654 {
1656 if (status != RPC_S_OK)
1657 I_RpcFree(pMsg->Buffer);
1658 }
1659 else
1660 status = RPC_S_OK;
1661
1662 return status;
1663}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1570
void *WINAPI I_RpcAllocate(unsigned int Size)
Definition: rpcrt4_main.c:747
long RPC_STATUS
Definition: rpc.h:48
unsigned int BufferLength
Definition: rpcdcep.h:41
Definition: ps.c:97

Referenced by ClientRpcChannelBuffer_GetBuffer(), hello_CtxClose(), hello_CtxOpen(), NdrGetBuffer(), NdrpCompleteAsyncServerCall(), NdrStubCall2(), and ServerRpcChannelBuffer_GetBuffer().

◆ I_RpcNegotiateTransferSyntax()

RPC_STATUS WINAPI I_RpcNegotiateTransferSyntax ( PRPC_MESSAGE  pMsg)

Definition at line 1570 of file rpc_message.c.

1571{
1572 RpcBinding* bind = pMsg->Handle;
1573 RpcConnection* conn;
1575
1576 TRACE("(%p)\n", pMsg);
1577
1578 if (!bind || bind->server)
1579 {
1580 ERR("no binding\n");
1581 return RPC_S_INVALID_BINDING;
1582 }
1583
1584 /* if we already have a connection, we don't need to negotiate again */
1585 if (!pMsg->ReservedForRuntime)
1586 {
1588 if (!cif) return RPC_S_INTERFACE_NOT_FOUND;
1589
1590 if (!bind->Endpoint || !bind->Endpoint[0])
1591 {
1592 TRACE("automatically resolving partially bound binding\n");
1594 if (status != RPC_S_OK) return status;
1595 }
1596
1598 &cif->InterfaceId, NULL);
1599
1600 if (status == RPC_S_OK)
1601 {
1602 pMsg->ReservedForRuntime = conn;
1604 }
1605 }
1606
1607 return status;
1608}
void RPCRT4_AddRefBinding(RpcBinding *Binding)
Definition: rpc_binding.c:232
RPC_STATUS RPCRT4_OpenBinding(RpcBinding *Binding, RpcConnection **Connection, const RPC_SYNTAX_IDENTIFIER *TransferSyntax, const RPC_SYNTAX_IDENTIFIER *InterfaceId, BOOL *from_cache)
Definition: rpc_binding.c:255
RPC_STATUS WINAPI RpcEpResolveBinding(RPC_BINDING_HANDLE Binding, RPC_IF_HANDLE IfSpec)
Definition: rpc_epmap.c:430
RPC_SYNTAX_IDENTIFIER InterfaceId
Definition: rpcdcep.h:117
RPC_SYNTAX_IDENTIFIER TransferSyntax
Definition: rpcdcep.h:118
void * RpcInterfaceInformation
Definition: rpcdcep.h:44
#define RPC_S_INTERFACE_NOT_FOUND
Definition: winerror.h:1424

Referenced by I_RpcGetBuffer().

◆ I_RpcReAllocateBuffer()

static RPC_STATUS I_RpcReAllocateBuffer ( PRPC_MESSAGE  pMsg)
static

Definition at line 1668 of file rpc_message.c.

1669{
1670 TRACE("(%p): BufferLength=%d\n", pMsg, pMsg->BufferLength);
1671 pMsg->Buffer = realloc(pMsg->Buffer, pMsg->BufferLength);
1672
1673 TRACE("Buffer=%p\n", pMsg->Buffer);
1674 return pMsg->Buffer ? RPC_S_OK : ERROR_OUTOFMEMORY;
1675}
#define realloc
Definition: debug_ros.c:6

Referenced by RPCRT4_ReceiveWithAuth().

◆ I_RpcReceive()

RPC_STATUS WINAPI I_RpcReceive ( PRPC_MESSAGE  pMsg)

Definition at line 1853 of file rpc_message.c.

1854{
1855 RpcBinding* bind = pMsg->Handle;
1857 RpcPktHdr *hdr = NULL;
1858 RpcConnection *conn;
1859
1860 TRACE("(%p)\n", pMsg);
1861 if (!bind || bind->server || !pMsg->ReservedForRuntime) return RPC_S_INVALID_BINDING;
1862
1863 conn = pMsg->ReservedForRuntime;
1864 status = RPCRT4_Receive(conn, &hdr, pMsg);
1865 if (status != RPC_S_OK) {
1866 WARN("receive failed with error %lx\n", status);
1867 goto fail;
1868 }
1869
1870 switch (hdr->common.ptype) {
1871 case PKT_RESPONSE:
1872 break;
1873 case PKT_FAULT:
1874 ERR ("we got fault packet with status 0x%x\n", hdr->fault.status);
1875 status = NCA2RPC_STATUS(hdr->fault.status);
1876 if (is_hard_error(status))
1877 goto fail;
1878 break;
1879 default:
1880 WARN("bad packet type %d\n", hdr->common.ptype);
1882 goto fail;
1883 }
1884
1885 /* success */
1886 free(hdr);
1887 return status;
1888
1889fail:
1890 free(hdr);
1892 pMsg->ReservedForRuntime = NULL;
1893 return status;
1894}
#define free
Definition: debug_ros.c:5
char hdr[14]
Definition: iptest.cpp:33
void RPCRT4_ReleaseConnection(RpcConnection *Connection)
@ PKT_FAULT
Definition: rpc_defs.h:191
@ PKT_RESPONSE
Definition: rpc_defs.h:190
static RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1550
static RPC_STATUS NCA2RPC_STATUS(NCA_STATUS status)
Definition: rpc_message.c:437
static BOOL is_hard_error(RPC_STATUS status)
Definition: rpc_message.c:1833
#define RPC_S_PROTOCOL_ERROR
Definition: winerror.h:1395

Referenced by I_RpcSendReceive(), and NdrpCompleteAsyncClientCall().

◆ I_RpcSend()

RPC_STATUS WINAPI I_RpcSend ( PRPC_MESSAGE  pMsg)

Definition at line 1786 of file rpc_message.c.

1787{
1788 RpcBinding* bind = pMsg->Handle;
1790 RpcConnection* conn;
1792 RpcPktHdr *hdr;
1793 BOOL from_cache = TRUE;
1794
1795 TRACE("(%p)\n", pMsg);
1796 if (!bind || bind->server || !pMsg->ReservedForRuntime) return RPC_S_INVALID_BINDING;
1797
1798 for (;;)
1799 {
1800 conn = pMsg->ReservedForRuntime;
1802 pMsg->BufferLength,
1804 &bind->ObjectUuid);
1805 if (!hdr)
1806 return ERROR_OUTOFMEMORY;
1807
1808 hdr->common.call_id = conn->NextCallId++;
1809 status = RPCRT4_Send(conn, hdr, pMsg->Buffer, pMsg->BufferLength);
1810 free(hdr);
1811 if (status == RPC_S_OK || conn->server || !from_cache)
1812 break;
1813
1814 WARN("Send failed, trying to reconnect\n");
1815 cif = pMsg->RpcInterfaceInformation;
1817 pMsg->ReservedForRuntime = NULL;
1818 status = RPCRT4_OpenBinding(bind, &conn, &cif->TransferSyntax, &cif->InterfaceId, &from_cache);
1819 if (status != RPC_S_OK) break;
1820 pMsg->ReservedForRuntime = conn;
1821 }
1822
1823 if (status == RPC_S_OK && pMsg->RpcFlags & RPC_BUFFER_ASYNC)
1824 {
1827 }
1828
1829 return status;
1830}
#define TRUE
Definition: types.h:120
BOOL WINAPI QueueUserWorkItem(IN LPTHREAD_START_ROUTINE Function, IN PVOID Context, IN ULONG Flags)
Definition: thread.c:1076
unsigned int BOOL
Definition: ntddk_ex.h:94
static RpcPktHdr * RPCRT4_BuildRequestHeader(ULONG DataRepresentation, ULONG BufferLength, unsigned short ProcNum, UUID *ObjectUuid)
Definition: rpc_message.c:125
static DWORD WINAPI async_notifier_proc(LPVOID p)
Definition: rpc_message.c:1721
RPC_STATUS RPCRT4_Send(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength)
Definition: rpc_message.c:1219
#define RPC_BUFFER_ASYNC
Definition: rpcdcep.h:70
#define RPC_FLAGS_VALID_BIT
Definition: rpcdcep.h:52
unsigned int ProcNum
Definition: rpcdcep.h:42
ULONG DataRepresentation
Definition: rpcdcep.h:39
ULONG RpcFlags
Definition: rpcdcep.h:48
USHORT NextCallId
Definition: rpc_binding.h:93
#define RPC_S_OUT_OF_RESOURCES
Definition: winerror.h:1388
#define WT_EXECUTELONGFUNCTION
Definition: winnt_old.h:1089
#define WT_EXECUTEDEFAULT
Definition: winnt_old.h:1084

Referenced by do_ndr_async_client_call(), and I_RpcSendReceive().

◆ I_RpcSendReceive()

RPC_STATUS WINAPI I_RpcSendReceive ( PRPC_MESSAGE  pMsg)

Definition at line 1914 of file rpc_message.c.

1915{
1917 void *original_buffer;
1918
1919 TRACE("(%p)\n", pMsg);
1920
1921 original_buffer = pMsg->Buffer;
1922 status = I_RpcSend(pMsg);
1923 if (status == RPC_S_OK)
1924 status = I_RpcReceive(pMsg);
1925 /* free the buffer replaced by a new buffer in I_RpcReceive */
1926 if (status == RPC_S_OK)
1927 I_RpcFree(original_buffer);
1928 return status;
1929}
RPC_STATUS WINAPI I_RpcSend(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1786
RPC_STATUS WINAPI I_RpcReceive(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1853

Referenced by NdrSendReceive(), and rpc_sendreceive_thread().

◆ is_hard_error()

static BOOL is_hard_error ( RPC_STATUS  status)
inlinestatic

Definition at line 1833 of file rpc_message.c.

1834{
1835 switch (status)
1836 {
1837 case 0: /* user-defined fault */
1841 case RPC_S_CALL_FAILED:
1844 return TRUE;
1845 default:
1846 return FALSE;
1847 }
1848}
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define RPC_S_CALL_FAILED_DNE
Definition: winerror.h:1394
#define RPC_S_CALL_FAILED
Definition: winerror.h:1393
#define RPC_S_SEC_PKG_ERROR
Definition: winerror.h:1489

Referenced by I_RpcReceive().

◆ NCA2RPC_STATUS()

static RPC_STATUS NCA2RPC_STATUS ( NCA_STATUS  status)
static

Definition at line 437 of file rpc_message.c.

438{
439 switch (status)
440 {
443 case NCA_S_UNK_IF: return RPC_S_UNKNOWN_IF;
474 default: return status;
475 }
476}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define NCA_S_UNK_IF
Definition: ncastatus.h:25
#define NCA_S_FAULT_ILL_INST
Definition: ncastatus.h:47
#define NCA_S_MANAGER_NOT_ENTERED
Definition: ncastatus.h:45
#define NCA_S_FAULT_INT_DIV_BY_ZERO
Definition: ncastatus.h:34
#define NCA_S_UNSPEC_REJECT
Definition: ncastatus.h:42
#define NCA_S_FAULT_INT_OVERFLOW
Definition: ncastatus.h:49
#define NCA_S_FAULT_PIPE_MEMORY
Definition: ncastatus.h:57
#define NCA_S_FAULT_REMOTE_NO_MEMORY
Definition: ncastatus.h:59
#define NCA_S_RPC_VERSION_MISMATCH
Definition: ncastatus.h:41
#define NCA_S_COMM_FAILURE
Definition: ncastatus.h:23
#define NCA_S_SERVER_TOO_BUSY
Definition: ncastatus.h:30
#define NCA_S_FAULT_FP_OVERFLOW
Definition: ncastatus.h:38
#define NCA_S_FAULT_UNSPEC
Definition: ncastatus.h:50
#define NCA_S_BAD_ACTID
Definition: ncastatus.h:43
#define NCA_S_FAULT_FP_DIV_ZERO
Definition: ncastatus.h:36
#define NCA_S_FAULT_FP_ERROR
Definition: ncastatus.h:48
#define NCA_S_FAULT_PIPE_CLOSED
Definition: ncastatus.h:53
#define NCA_S_FAULT_CONTEXT_MISMATCH
Definition: ncastatus.h:58
#define NCA_S_UNSUPPORTED_TYPE
Definition: ncastatus.h:32
#define NCA_S_FAULT_ADDR_ERROR
Definition: ncastatus.h:35
#define NCA_S_WHO_ARE_YOU_FAILED
Definition: ncastatus.h:44
#define NCA_S_FAULT_PIPE_DISCIPLINE
Definition: ncastatus.h:55
#define NCA_S_FAULT_PIPE_EMPTY
Definition: ncastatus.h:52
#define NCA_S_FAULT_CANCEL
Definition: ncastatus.h:46
#define NCA_S_OUT_ARGS_TOO_BIG
Definition: ncastatus.h:29
#define NCA_S_OP_RNG_ERROR
Definition: ncastatus.h:24
#define NCA_S_FAULT_PIPE_COMM_ERROR
Definition: ncastatus.h:56
#define NCA_S_YOU_CRASHED
Definition: ncastatus.h:27
#define NCA_S_FAULT_FP_UNDERFLOW
Definition: ncastatus.h:37
#define NCA_S_FAULT_INVALID_TAG
Definition: ncastatus.h:39
#define NCA_S_FAULT_INVALID_BOUND
Definition: ncastatus.h:40
#define NCA_S_PROTO_ERROR
Definition: ncastatus.h:28
#define NCA_S_FAULT_PIPE_ORDER
Definition: ncastatus.h:54
#define RPC_S_SERVER_TOO_BUSY
Definition: winerror.h:1390
#define RPC_S_ADDRESS_ERROR
Definition: winerror.h:1433
#define RPC_X_WRONG_PIPE_ORDER
Definition: winerror.h:1495
#define RPC_S_INVALID_BOUND
Definition: winerror.h:1400
#define RPC_S_INVALID_TAG
Definition: winerror.h:1399
#define RPC_S_FP_DIV_ZERO
Definition: winerror.h:1434
#define RPC_X_PIPE_DISCIPLINE_ERROR
Definition: winerror.h:1520
#define RPC_S_UNSUPPORTED_TYPE
Definition: winerror.h:1398
#define RPC_S_UNKNOWN_IF
Definition: winerror.h:1384
#define RPC_S_FP_UNDERFLOW
Definition: winerror.h:1435
#define RPC_S_CALL_CANCELLED
Definition: winerror.h:1482
#define RPC_X_PIPE_CLOSED
Definition: winerror.h:1519
#define RPC_S_ZERO_DIVIDE
Definition: winerror.h:1432
#define RPC_X_PIPE_EMPTY
Definition: winerror.h:1521
#define RPC_S_COMM_FAILURE
Definition: winerror.h:1484
#define RPC_S_PROCNUM_OUT_OF_RANGE
Definition: winerror.h:1410
#define RPC_S_FP_OVERFLOW
Definition: winerror.h:1436
#define ERROR_NOT_ENOUGH_SERVER_MEMORY
Definition: winerror.h:990

Referenced by I_RpcReceive().

◆ packet_does_auth_negotiation()

static BOOL packet_does_auth_negotiation ( const RpcPktHdr Header)
static

Definition at line 94 of file rpc_message.c.

95{
96 switch (Header->common.ptype)
97 {
98 case PKT_BIND:
99 case PKT_BIND_ACK:
100 case PKT_AUTH3:
103 return TRUE;
104 default:
105 return FALSE;
106 }
107}
Definition: Header.h:9
@ PKT_ALTER_CONTEXT
Definition: rpc_defs.h:202
@ PKT_BIND
Definition: rpc_defs.h:199
@ PKT_ALTER_CONTEXT_RESP
Definition: rpc_defs.h:203
@ PKT_AUTH3
Definition: rpc_defs.h:204
@ PKT_BIND_ACK
Definition: rpc_defs.h:200

Referenced by RPCRT4_ReceiveWithAuth(), and RPCRT4_Send().

◆ packet_has_auth_verifier()

static BOOL packet_has_auth_verifier ( const RpcPktHdr Header)
static

Definition at line 88 of file rpc_message.c.

89{
90 return !(Header->common.ptype == PKT_BIND_NACK) &&
91 !(Header->common.ptype == PKT_SHUTDOWN);
92}
@ PKT_BIND_NACK
Definition: rpc_defs.h:201
@ PKT_SHUTDOWN
Definition: rpc_defs.h:205

Referenced by RPCRT4_SendWithAuth().

◆ packet_has_body()

static BOOL packet_has_body ( const RpcPktHdr Header)
static

Definition at line 81 of file rpc_message.c.

82{
83 return (Header->common.ptype == PKT_FAULT) ||
84 (Header->common.ptype == PKT_REQUEST) ||
85 (Header->common.ptype == PKT_RESPONSE);
86}
@ PKT_REQUEST
Definition: rpc_defs.h:188

Referenced by RPCRT4_default_secure_packet(), and RPCRT4_SendWithAuth().

◆ RPC2NCA_STATUS()

NCA_STATUS RPC2NCA_STATUS ( RPC_STATUS  status)

Definition at line 404 of file rpc_message.c.

405{
406 switch (status)
407 {
411 case RPC_S_UNKNOWN_IF: return NCA_S_UNK_IF;
433 default: return status;
434 }
435}
#define STATUS_INTEGER_OVERFLOW
Definition: log.c:20
#define STATUS_FLOAT_UNDERFLOW
Definition: ntstatus.h:477
#define STATUS_FLOAT_OVERFLOW
Definition: ntstatus.h:475
#define STATUS_FLOAT_DIVIDE_BY_ZERO
Definition: ntstatus.h:472
#define STATUS_FLOAT_INVALID_OPERATION
Definition: ntstatus.h:474
#define STATUS_INTEGER_DIVIDE_BY_ZERO
Definition: ntstatus.h:478
#define RPC_X_SS_HANDLES_MISMATCH
Definition: winerror.h:1442
#define RPC_S_NOT_LISTENING
Definition: winerror.h:1382

Referenced by process_request_packet().

◆ RPCRT4_BuildAuthHeader()

static RpcPktHdr * RPCRT4_BuildAuthHeader ( ULONG  DataRepresentation)
static

Definition at line 215 of file rpc_message.c.

216{
218
219 header = calloc(1, sizeof(*header));
220 if (header == NULL)
221 return NULL;
222
223 RPCRT4_BuildCommonHeader(&header->common, PKT_AUTH3, DataRepresentation);
224 header->common.frag_len = sizeof(*header);
225
226 return (RpcPktHdr*)header;
227}
#define calloc
Definition: rosglue.h:14
static VOID RPCRT4_BuildCommonHeader(RpcPktCommonHdr *Header, unsigned char PacketType, ULONG DataRepresentation)
Definition: rpc_message.c:109

Referenced by RPCRT4_ClientConnectionAuth().

◆ RPCRT4_BuildBindAckHeader()

RpcPktHdr * RPCRT4_BuildBindAckHeader ( ULONG  DataRepresentation,
unsigned short  MaxTransmissionSize,
unsigned short  MaxReceiveSize,
ULONG  AssocGroupId,
LPCSTR  ServerAddress,
unsigned char  ResultCount,
const RpcResult Results 
)

Definition at line 254 of file rpc_message.c.

261{
263 ULONG header_size;
264 RpcAddressString *server_address;
266
267 header_size = sizeof(header->bind_ack) +
268 ROUND_UP(FIELD_OFFSET(RpcAddressString, string[strlen(ServerAddress) + 1]), 4) +
269 FIELD_OFFSET(RpcResultList, results[ResultCount]);
270
271 header = calloc(1, header_size);
272 if (header == NULL) {
273 return NULL;
274 }
275
276 RPCRT4_BuildCommonHeader(&header->common, PKT_BIND_ACK, DataRepresentation);
277 header->common.frag_len = header_size;
278 header->bind_ack.max_tsize = MaxTransmissionSize;
279 header->bind_ack.max_rsize = MaxReceiveSize;
280 header->bind_ack.assoc_gid = AssocGroupId;
281 server_address = (RpcAddressString*)(&header->bind_ack + 1);
282 server_address->length = strlen(ServerAddress) + 1;
283 strcpy(server_address->string, ServerAddress);
284 /* results is 4-byte aligned */
285 results = (RpcResultList*)((ULONG_PTR)server_address + ROUND_UP(FIELD_OFFSET(RpcAddressString, string[server_address->length]), 4));
286 results->num_results = ResultCount;
287 memcpy(&results->results[0], Results, ResultCount * sizeof(*Results));
288
289 return header;
290}
static struct _test_info results[8]
Definition: SetCursorPos.c:31
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ROUND_UP(value, alignment)
Definition: rpc_message.c:54
strcpy
Definition: string.h:131
unsigned short length
Definition: rpc_defs.h:91
char string[ANYSIZE_ARRAY]
Definition: rpc_defs.h:92
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG
Definition: typedefs.h:59

Referenced by process_bind_packet_no_send().

◆ RPCRT4_BuildBindHeader()

RpcPktHdr * RPCRT4_BuildBindHeader ( ULONG  DataRepresentation,
unsigned short  MaxTransmissionSize,
unsigned short  MaxReceiveSize,
ULONG  AssocGroupId,
const RPC_SYNTAX_IDENTIFIER AbstractId,
const RPC_SYNTAX_IDENTIFIER TransferId 
)

Definition at line 186 of file rpc_message.c.

192{
194 RpcContextElement *ctxt_elem;
195
196 header = calloc(1, sizeof(header->bind) + FIELD_OFFSET(RpcContextElement, transfer_syntaxes[1]));
197 if (header == NULL) {
198 return NULL;
199 }
200 ctxt_elem = (RpcContextElement *)(&header->bind + 1);
201
202 RPCRT4_BuildCommonHeader(&header->common, PKT_BIND, DataRepresentation);
203 header->common.frag_len = sizeof(header->bind) + FIELD_OFFSET(RpcContextElement, transfer_syntaxes[1]);
204 header->bind.max_tsize = MaxTransmissionSize;
205 header->bind.max_rsize = MaxReceiveSize;
206 header->bind.assoc_gid = AssocGroupId;
207 header->bind.num_elements = 1;
208 ctxt_elem->num_syntaxes = 1;
209 ctxt_elem->abstract_syntax = *AbstractId;
210 ctxt_elem->transfer_syntaxes[0] = *TransferId;
211
212 return header;
213}
RPC_SYNTAX_IDENTIFIER transfer_syntaxes[ANYSIZE_ARRAY]
Definition: rpc_defs.h:72
RPC_SYNTAX_IDENTIFIER abstract_syntax
Definition: rpc_defs.h:71
unsigned char num_syntaxes
Definition: rpc_defs.h:69

Referenced by RpcAssoc_BindConnection().

◆ RPCRT4_BuildBindNackHeader()

RpcPktHdr * RPCRT4_BuildBindNackHeader ( ULONG  DataRepresentation,
unsigned char  RpcVersion,
unsigned char  RpcVersionMinor,
unsigned short  RejectReason 
)

Definition at line 229 of file rpc_message.c.

233{
235#ifndef _MSC_VER
237#endif
238
239 header = calloc(1, sizeof(*header));
240 if (header == NULL) {
241 return NULL;
242 }
243
244 RPCRT4_BuildCommonHeader(&header->common, PKT_BIND_NACK, DataRepresentation);
245 header->common.frag_len = FIELD_OFFSET(RpcPktBindNAckHdr, protocols[1]);
246 header->reject_reason = RejectReason;
247 header->protocols_count = 1;
248 header->protocols[0].rpc_ver = RpcVersion;
249 header->protocols[0].rpc_ver_minor = RpcVersionMinor;
250
251 return (RpcPktHdr *)header;
252}
struct protocol * protocols
Definition: dispatch.c:56
#define C_ASSERT(e)
Definition: intsafe.h:73

Referenced by handle_bind_error().

◆ RPCRT4_BuildCommonHeader()

static VOID RPCRT4_BuildCommonHeader ( RpcPktCommonHdr Header,
unsigned char  PacketType,
ULONG  DataRepresentation 
)
static

Definition at line 109 of file rpc_message.c.

111{
112 Header->rpc_ver = RPC_VER_MAJOR;
113 Header->rpc_ver_minor = RPC_VER_MINOR;
114 Header->ptype = PacketType;
115 Header->drep[0] = LOBYTE(LOWORD(DataRepresentation));
116 Header->drep[1] = HIBYTE(LOWORD(DataRepresentation));
117 Header->drep[2] = LOBYTE(HIWORD(DataRepresentation));
118 Header->drep[3] = HIBYTE(HIWORD(DataRepresentation));
119 Header->auth_len = 0;
120 Header->call_id = 1;
121 Header->flags = 0;
122 /* Flags and fragment length are computed in RPCRT4_Send. */
123}
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
#define LOWORD(l)
Definition: pedump.c:82
#define RPC_VER_MAJOR
Definition: rpc_defs.h:176
#define RPC_VER_MINOR
Definition: rpc_defs.h:177
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by RPCRT4_BuildAuthHeader(), RPCRT4_BuildBindAckHeader(), RPCRT4_BuildBindHeader(), RPCRT4_BuildBindNackHeader(), RPCRT4_BuildFaultHeader(), RPCRT4_BuildHttpHeader(), RPCRT4_BuildRequestHeader(), and RPCRT4_BuildResponseHeader().

◆ RPCRT4_BuildFaultHeader()

RpcPktHdr * RPCRT4_BuildFaultHeader ( ULONG  DataRepresentation,
RPC_STATUS  Status 
)

Definition at line 170 of file rpc_message.c.

171{
173
174 header = calloc(1, sizeof(*header));
175 if (header == NULL) {
176 return NULL;
177 }
178
179 RPCRT4_BuildCommonHeader(&header->common, PKT_FAULT, DataRepresentation);
180 header->common.frag_len = sizeof(*header);
181 header->status = Status;
182
183 return (RpcPktHdr *)header;
184}
Status
Definition: gdiplustypes.h:25

Referenced by process_request_packet().

◆ RPCRT4_BuildHttpConnectHeader()

RpcPktHdr * RPCRT4_BuildHttpConnectHeader ( int  out_pipe,
const UUID connection_uuid,
const UUID pipe_uuid,
const UUID association_uuid 
)

Definition at line 345 of file rpc_message.c.

349{
351 unsigned int size;
352 char *payload;
353
354 size = 8 + 4 + sizeof(UUID) + 4 + sizeof(UUID) + 8;
355 if (!out_pipe)
356 size += 8 + 4 + sizeof(UUID);
357
359 out_pipe ? 4 : 6, size);
360 if (!header) return NULL;
361 payload = (char *)(&header->http+1);
362
363 /* FIXME: what does this part of the payload do? */
364 WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, 0x00000006, 0x00000001);
365
366 WRITE_HTTP_PAYLOAD_FIELD_UUID(payload, 0x00000003, *connection_uuid);
367 WRITE_HTTP_PAYLOAD_FIELD_UUID(payload, 0x00000003, *pipe_uuid);
368
369 if (out_pipe)
370 /* FIXME: what does this part of the payload do? */
371 WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, 0x00000000, 0x00010000);
372 else
373 {
374 /* FIXME: what does this part of the payload do? */
375 WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, 0x00000004, 0x40000000);
376 /* FIXME: what does this part of the payload do? */
377 WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, 0x00000005, 0x000493e0);
378
379 WRITE_HTTP_PAYLOAD_FIELD_UUID(payload, 0x0000000c, *association_uuid);
380 }
381
382 return header;
383}
GLsizeiptr size
Definition: glext.h:5919
GUID UUID
Definition: module.h:1093
#define WRITE_HTTP_PAYLOAD_FIELD_UUID(payload, type, uuid)
Definition: rpc_message.c:325
RpcPktHdr * RPCRT4_BuildHttpHeader(ULONG DataRepresentation, unsigned short flags, unsigned short num_data_items, unsigned int payload_size)
Definition: rpc_message.c:292
#define WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, type, value)
Definition: rpc_message.c:317
#define NDR_LOCAL_DATA_REPRESENTATION
Definition: rpcndr.h:68

Referenced by rpcrt4_http_prepare_in_pipe(), and rpcrt4_http_prepare_out_pipe().

◆ RPCRT4_BuildHttpFlowControlHeader()

RpcPktHdr * RPCRT4_BuildHttpFlowControlHeader ( BOOL  server,
ULONG  bytes_transmitted,
ULONG  flow_control_increment,
const UUID pipe_uuid 
)

Definition at line 385 of file rpc_message.c.

388{
390 char *payload;
391
393 5 * sizeof(ULONG) + sizeof(UUID));
394 if (!header) return NULL;
395 payload = (char *)(&header->http+1);
396
397 WRITE_HTTP_PAYLOAD_FIELD_UINT32(payload, 0x0000000d, (server ? 0x0 : 0x3));
398
399 WRITE_HTTP_PAYLOAD_FIELD_FLOW_CONTROL(payload, bytes_transmitted,
400 flow_control_increment, *pipe_uuid);
401 return header;
402}
#define WRITE_HTTP_PAYLOAD_FIELD_FLOW_CONTROL(payload, bytes_transmitted, flow_control_increment, uuid)
Definition: rpc_message.c:333
static rfbScreenInfoPtr server
Definition: vnc.c:74

Referenced by rpcrt4_ncacn_http_receive_fragment().

◆ RPCRT4_BuildHttpHeader()

RpcPktHdr * RPCRT4_BuildHttpHeader ( ULONG  DataRepresentation,
unsigned short  flags,
unsigned short  num_data_items,
unsigned int  payload_size 
)

Definition at line 292 of file rpc_message.c.

296{
298
299 header = calloc(1, sizeof(header->http) + payload_size);
300 if (header == NULL) {
301 ERR("failed to allocate memory\n");
302 return NULL;
303 }
304
305 RPCRT4_BuildCommonHeader(&header->common, PKT_HTTP, DataRepresentation);
306 /* since the packet isn't current sent using RPCRT4_Send, set the flags
307 * manually here */
308 header->common.flags = RPC_FLG_FIRST|RPC_FLG_LAST;
309 header->common.call_id = 0;
310 header->common.frag_len = sizeof(header->http) + payload_size;
311 header->http.flags = flags;
312 header->http.num_data_items = num_data_items;
313
314 return header;
315}
GLbitfield flags
Definition: glext.h:7161
#define RPC_FLG_LAST
Definition: rpc_defs.h:180
#define RPC_FLG_FIRST
Definition: rpc_defs.h:179
@ PKT_HTTP
Definition: rpc_defs.h:208

Referenced by RPCRT4_BuildHttpConnectHeader(), RPCRT4_BuildHttpFlowControlHeader(), and rpcrt4_http_keep_connection_active_timer_proc().

◆ RPCRT4_BuildRequestHeader()

static RpcPktHdr * RPCRT4_BuildRequestHeader ( ULONG  DataRepresentation,
ULONG  BufferLength,
unsigned short  ProcNum,
UUID ObjectUuid 
)
static

Definition at line 125 of file rpc_message.c.

129{
131 BOOL has_object;
133
134 has_object = (ObjectUuid != NULL && !UuidIsNil(ObjectUuid, &status));
135 header = calloc(1, sizeof(header->request) + (has_object ? sizeof(UUID) : 0));
136 if (header == NULL) {
137 return NULL;
138 }
139
140 RPCRT4_BuildCommonHeader(&header->common, PKT_REQUEST, DataRepresentation);
141 header->common.frag_len = sizeof(header->request);
142 header->request.alloc_hint = BufferLength;
143 header->request.context_id = 0;
144 header->request.opnum = ProcNum;
145 if (has_object) {
146 header->common.flags |= RPC_FLG_OBJECT_UUID;
147 header->common.frag_len += sizeof(UUID);
148 memcpy(&header->request + 1, ObjectUuid, sizeof(UUID));
149 }
150
151 return header;
152}
#define RPC_FLG_OBJECT_UUID
Definition: rpc_defs.h:181
int WINAPI UuidIsNil(UUID *Uuid, RPC_STATUS *Status)
Definition: rpcrt4_main.c:293
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777

Referenced by I_RpcSend().

◆ RPCRT4_BuildResponseHeader()

RpcPktHdr * RPCRT4_BuildResponseHeader ( ULONG  DataRepresentation,
ULONG  BufferLength 
)

Definition at line 154 of file rpc_message.c.

155{
157
158 header = calloc(1, sizeof(*header));
159 if (header == NULL) {
160 return NULL;
161 }
162
163 RPCRT4_BuildCommonHeader(&header->common, PKT_RESPONSE, DataRepresentation);
164 header->common.frag_len = sizeof(*header);
165 header->alloc_hint = BufferLength;
166
167 return (RpcPktHdr *)header;
168}

Referenced by process_request_packet().

◆ RPCRT4_ClientConnectionAuth()

RPC_STATUS RPCRT4_ClientConnectionAuth ( RpcConnection conn,
BYTE challenge,
ULONG  count 
)

Definition at line 988 of file rpc_message.c.

990{
991 RpcPktHdr *resp_hdr;
993 unsigned char *out_buffer;
994 unsigned int out_len = 0;
995
996 TRACE("challenge %s, %ld bytes\n", challenge, count);
997
998 status = rpcrt4_conn_authorize(conn, FALSE, challenge, count, NULL, &out_len);
999 if (status) return status;
1000 out_buffer = malloc(out_len);
1002 status = rpcrt4_conn_authorize(conn, FALSE, challenge, count, out_buffer, &out_len);
1003 if (status) return status;
1004
1006
1007 if (resp_hdr)
1008 status = RPCRT4_SendWithAuth(conn, resp_hdr, NULL, 0, out_buffer, out_len);
1009 else
1011
1013 free(resp_hdr);
1014
1015 return status;
1016}
#define malloc
Definition: debug_ros.c:4
GLuint GLuint GLsizei count
Definition: gl.h:1545
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID out_buffer
Definition: file.c:100
static RPC_STATUS rpcrt4_conn_authorize(RpcConnection *conn, BOOL first_time, unsigned char *in_buffer, unsigned int in_len, unsigned char *out_buffer, unsigned int *out_len)
Definition: rpc_binding.h:221
static RpcPktHdr * RPCRT4_BuildAuthHeader(ULONG DataRepresentation)
Definition: rpc_message.c:215
RPC_STATUS RPCRT4_SendWithAuth(RpcConnection *Connection, RpcPktHdr *Header, void *Buffer, unsigned int BufferLength, const void *Auth, unsigned int AuthLength)
Definition: rpc_message.c:757

Referenced by RpcAssoc_BindConnection().

◆ RPCRT4_default_authorize()

RPC_STATUS RPCRT4_default_authorize ( RpcConnection conn,
BOOL  first_time,
unsigned char in_buffer,
unsigned int  in_size,
unsigned char out_buffer,
unsigned int out_size 
)

Definition at line 868 of file rpc_message.c.

873{
875 SecBufferDesc out_desc;
876 SecBufferDesc inp_desc;
877 SecPkgContext_Sizes secctx_sizes;
878 BOOL continue_needed;
879 ULONG context_req;
881
882 if (!out_buffer)
883 {
884 *out_size = conn->AuthInfo->cbMaxToken;
885 return RPC_S_OK;
886 }
887
888 in.BufferType = SECBUFFER_TOKEN;
889 in.pvBuffer = in_buffer;
890 in.cbBuffer = in_size;
891
892 out.BufferType = SECBUFFER_TOKEN;
893 out.pvBuffer = out_buffer;
894 out.cbBuffer = *out_size;
895
896 out_desc.ulVersion = 0;
897 out_desc.cBuffers = 1;
898 out_desc.pBuffers = &out;
899
900 inp_desc.ulVersion = 0;
901 inp_desc.cBuffers = 1;
902 inp_desc.pBuffers = &in;
903
904 if (conn->server)
905 {
908
910 context_req |= ASC_REQ_INTEGRITY;
913
915 first_time ? NULL : &conn->ctx,
916 &inp_desc, context_req, SECURITY_NETWORK_DREP,
917 &conn->ctx,
918 &out_desc, &conn->attr, &conn->exp);
919 if (r == SEC_E_OK || r == SEC_I_COMPLETE_NEEDED)
920 {
921 /* authorisation done, so nothing more to send */
922 out.cbBuffer = 0;
923 }
924 }
925 else
926 {
929
931 context_req |= ISC_REQ_INTEGRITY;
934
936 first_time ? NULL: &conn->ctx,
937 first_time ? conn->AuthInfo->server_principal_name : NULL,
938 context_req, 0, SECURITY_NETWORK_DREP,
939 first_time ? NULL : &inp_desc, 0, &conn->ctx,
940 &out_desc, &conn->attr, &conn->exp);
941 }
942 if (FAILED(r))
943 {
944 WARN("InitializeSecurityContext failed with error 0x%08lx\n", r);
945 goto failed;
946 }
947
948 TRACE("r = 0x%08lx, attr = 0x%08lx\n", r, conn->attr);
949 continue_needed = ((r == SEC_I_CONTINUE_NEEDED) ||
951
953 {
954 TRACE("complete needed\n");
955 r = CompleteAuthToken(&conn->ctx, &out_desc);
956 if (FAILED(r))
957 {
958 WARN("CompleteAuthToken failed with error 0x%08lx\n", r);
959 goto failed;
960 }
961 }
962
963 TRACE("cbBuffer = %ld\n", out.cbBuffer);
964
965 if (!continue_needed)
966 {
967 r = QueryContextAttributesA(&conn->ctx, SECPKG_ATTR_SIZES, &secctx_sizes);
968 if (FAILED(r))
969 {
970 WARN("QueryContextAttributes failed with error 0x%08lx\n", r);
971 goto failed;
972 }
973 conn->signature_auth_len = secctx_sizes.cbMaxSignature;
974 conn->encryption_auth_len = secctx_sizes.cbSecurityTrailer;
975 }
976
977 *out_size = out.cbBuffer;
978 return RPC_S_OK;
979
980failed:
981 *out_size = 0;
982 return ERROR_ACCESS_DENIED; /* FIXME: is this correct? */
983}
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint in
Definition: glext.h:9616
static unsigned char * in_buffer
Definition: iccvid.c:87
#define FAILED(hr)
Definition: intsafe.h:51
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG in_size
Definition: file.c:100
#define ISC_REQ_CONFIDENTIALITY
Definition: sspi.h:366
LONG SECURITY_STATUS
Definition: sspi.h:34
#define ASC_REQ_CONNECTION
Definition: sspi.h:435
#define ASC_REQ_DELEGATE
Definition: sspi.h:426
#define ASC_REQ_CONFIDENTIALITY
Definition: sspi.h:430
#define SECBUFFER_TOKEN
Definition: sspi.h:161
#define SECURITY_NETWORK_DREP
Definition: sspi.h:474
#define ISC_REQ_INTEGRITY
Definition: sspi.h:378
#define ISC_REQ_DELEGATE
Definition: sspi.h:362
#define ASC_REQ_USE_DCE_STYLE
Definition: sspi.h:433
#define SECPKG_ATTR_SIZES
Definition: sspi.h:521
#define ISC_REQ_MUTUAL_AUTH
Definition: sspi.h:363
#define ASC_REQ_INTEGRITY
Definition: sspi.h:440
#define ISC_REQ_CONNECTION
Definition: sspi.h:373
#define ISC_REQ_USE_DCE_STYLE
Definition: sspi.h:371
#define RPC_C_AUTHN_LEVEL_PKT_PRIVACY
Definition: rpcdce.h:151
#define RPC_C_AUTHN_LEVEL_PKT_INTEGRITY
Definition: rpcdce.h:150
ULONG AuthnLevel
Definition: rpc_binding.h:40
CredHandle cred
Definition: rpc_binding.h:42
ULONG cbMaxToken
Definition: rpc_binding.h:44
LPWSTR server_principal_name
Definition: rpc_binding.h:50
TimeStamp exp
Definition: rpc_binding.h:75
RpcAuthInfo * AuthInfo
Definition: rpc_binding.h:77
ULONG signature_auth_len
Definition: rpc_binding.h:80
ULONG encryption_auth_len
Definition: rpc_binding.h:79
CtxtHandle ctx
Definition: rpc_binding.h:74
ULONG cBuffers
Definition: sspi.h:182
ULONG ulVersion
Definition: sspi.h:181
ULONG cbSecurityTrailer
Definition: sspi.h:564
ULONG cbMaxSignature
Definition: sspi.h:562
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define SEC_E_OK
Definition: winerror.h:3450
#define SEC_I_COMPLETE_NEEDED
Definition: winerror.h:4325
#define SEC_I_CONTINUE_NEEDED
Definition: winerror.h:4324
#define SEC_I_COMPLETE_AND_CONTINUE
Definition: winerror.h:4326
SECURITY_STATUS WINAPI InitializeSecurityContextW(PCredHandle phCredential, PCtxtHandle phContext, SEC_WCHAR *pszTargetName, ULONG fContextReq, ULONG Reserved1, ULONG TargetDataRep, PSecBufferDesc pInput, ULONG Reserved2, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:301
SECURITY_STATUS WINAPI CompleteAuthToken(PCtxtHandle phContext, PSecBufferDesc pToken)
Definition: wrapper.c:420
SECURITY_STATUS WINAPI QueryContextAttributesA(PCtxtHandle phContext, ULONG ulAttribute, void *pBuffer)
Definition: wrapper.c:505
SECURITY_STATUS WINAPI AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSecBufferDesc pInput, ULONG fContextReq, ULONG TargetDataRep, PCtxtHandle phNewContext, PSecBufferDesc pOutput, ULONG *pfContextAttr, PTimeStamp ptsExpiry)
Definition: wrapper.c:365

◆ RPCRT4_default_impersonate_client()

RPC_STATUS RPCRT4_default_impersonate_client ( RpcConnection conn)

Definition at line 1127 of file rpc_message.c.

1128{
1129 SECURITY_STATUS sec_status;
1130
1131 TRACE("(%p)\n", conn);
1132
1133 if (!conn->AuthInfo || !SecIsValidHandle(&conn->ctx))
1135 sec_status = ImpersonateSecurityContext(&conn->ctx);
1136 if (sec_status != SEC_E_OK)
1137 WARN("ImpersonateSecurityContext returned 0x%08lx\n", sec_status);
1138 switch (sec_status)
1139 {
1141 return RPC_S_CANNOT_SUPPORT;
1144 case SEC_E_OK:
1145 return RPC_S_OK;
1146 default:
1147 return RPC_S_SEC_PKG_ERROR;
1148 }
1149}
#define SecIsValidHandle(x)
Definition: sspi.h:63
#define SEC_E_NO_IMPERSONATION
Definition: winerror.h:4317
#define RPC_S_CANNOT_SUPPORT
Definition: winerror.h:1429
#define SEC_E_UNSUPPORTED_FUNCTION
Definition: winerror.h:4308
#define RPC_S_NO_CONTEXT_AVAILABLE
Definition: winerror.h:1430
SECURITY_STATUS WINAPI ImpersonateSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:565

Referenced by rpcrt4_conn_np_impersonate_client().

◆ RPCRT4_default_inquire_auth_client()

RPC_STATUS RPCRT4_default_inquire_auth_client ( RpcConnection conn,
RPC_AUTHZ_HANDLE privs,
RPC_WSTR server_princ_name,
ULONG authn_level,
ULONG authn_svc,
ULONG authz_svc,
ULONG  flags 
)

Definition at line 1185 of file rpc_message.c.

1188{
1189 if (!conn->AuthInfo) return RPC_S_BINDING_HAS_NO_AUTH;
1190
1191 if (privs)
1192 {
1193 FIXME("privs not implemented\n");
1194 *privs = NULL;
1195 }
1196 if (server_princ_name)
1197 {
1198 *server_princ_name = wcsdup(conn->AuthInfo->server_principal_name);
1199 if (!*server_princ_name) return ERROR_OUTOFMEMORY;
1200 }
1201 if (authn_level) *authn_level = conn->AuthInfo->AuthnLevel;
1202 if (authn_svc) *authn_svc = conn->AuthInfo->AuthnSvc;
1203 if (authz_svc)
1204 {
1205 FIXME("authorization service not implemented\n");
1206 *authz_svc = RPC_C_AUTHZ_NONE;
1207 }
1208 if (flags)
1209 FIXME("flags 0x%lx not implemented\n", flags);
1210
1211 return RPC_S_OK;
1212}
#define RPC_C_AUTHZ_NONE
Definition: rpcdce.h:167
_Check_return_ _CRTIMP wchar_t *__cdecl wcsdup(_In_z_ const wchar_t *_Str)
ULONG AuthnSvc
Definition: rpc_binding.h:41
#define RPC_S_BINDING_HAS_NO_AUTH
Definition: winerror.h:1411

◆ RPCRT4_default_is_authorized()

BOOL RPCRT4_default_is_authorized ( RpcConnection Connection)

Definition at line 1118 of file rpc_message.c.

1119{
1120 return Connection->AuthInfo && SecIsValidHandle(&Connection->ctx);
1121}

◆ RPCRT4_default_receive_fragment()

static RPC_STATUS RPCRT4_default_receive_fragment ( RpcConnection Connection,
RpcPktHdr **  Header,
void **  Payload 
)
static

Definition at line 1284 of file rpc_message.c.

1285{
1287 DWORD hdr_length;
1288 LONG dwRead;
1289 RpcPktCommonHdr common_hdr;
1290
1291 *Header = NULL;
1292 *Payload = NULL;
1293
1294 TRACE("(%p, %p, %p)\n", Connection, Header, Payload);
1295
1296 /* read packet common header */
1297 dwRead = rpcrt4_conn_read(Connection, &common_hdr, sizeof(common_hdr));
1298 if (dwRead != sizeof(common_hdr)) {
1299 WARN("Short read of header, %ld bytes\n", dwRead);
1301 goto fail;
1302 }
1303
1304 status = RPCRT4_ValidateCommonHeader(&common_hdr);
1305 if (status != RPC_S_OK) goto fail;
1306
1307 hdr_length = RPCRT4_GetHeaderSize((RpcPktHdr*)&common_hdr);
1308 if (hdr_length == 0) {
1309 WARN("header length == 0\n");
1311 goto fail;
1312 }
1313
1314 *Header = malloc(hdr_length);
1315 memcpy(*Header, &common_hdr, sizeof(common_hdr));
1316
1317 /* read the rest of packet header */
1318 dwRead = rpcrt4_conn_read(Connection, &(*Header)->common + 1, hdr_length - sizeof(common_hdr));
1319 if (dwRead != hdr_length - sizeof(common_hdr)) {
1320 WARN("bad header length, %ld bytes, hdr_length %ld\n", dwRead, hdr_length);
1322 goto fail;
1323 }
1324
1325 if (common_hdr.frag_len - hdr_length)
1326 {
1327 *Payload = malloc(common_hdr.frag_len - hdr_length);
1328 if (!*Payload)
1329 {
1331 goto fail;
1332 }
1333
1334 dwRead = rpcrt4_conn_read(Connection, *Payload, common_hdr.frag_len - hdr_length);
1335 if (dwRead != common_hdr.frag_len - hdr_length)
1336 {
1337 WARN("bad data length, %ld/%ld\n", dwRead, common_hdr.frag_len - hdr_length);
1339 goto fail;
1340 }
1341 }
1342 else
1343 *Payload = NULL;
1344
1345 /* success */
1346 status = RPC_S_OK;
1347
1348fail:
1349 if (status != RPC_S_OK) {
1350 free(*Header);
1351 *Header = NULL;
1352 free(*Payload);
1353 *Payload = NULL;
1354 }
1355 return status;
1356}
unsigned long DWORD
Definition: ntddk_ex.h:95
long LONG
Definition: pedump.c:60
static int rpcrt4_conn_read(RpcConnection *Connection, void *buffer, unsigned int len)
Definition: rpc_binding.h:184
RPC_STATUS RPCRT4_ValidateCommonHeader(const RpcPktCommonHdr *hdr)
Definition: rpc_message.c:1251
DWORD RPCRT4_GetHeaderSize(const RpcPktHdr *Header)
Definition: rpc_message.c:58
unsigned short frag_len
Definition: rpc_defs.h:33

Referenced by RPCRT4_receive_fragment().

◆ RPCRT4_default_revert_to_self()

RPC_STATUS RPCRT4_default_revert_to_self ( RpcConnection conn)

Definition at line 1155 of file rpc_message.c.

1156{
1157 SECURITY_STATUS sec_status;
1158
1159 TRACE("(%p)\n", conn);
1160
1161 if (!conn->AuthInfo || !SecIsValidHandle(&conn->ctx))
1163 sec_status = RevertSecurityContext(&conn->ctx);
1164 if (sec_status != SEC_E_OK)
1165 WARN("RevertSecurityContext returned 0x%08lx\n", sec_status);
1166 switch (sec_status)
1167 {
1169 return RPC_S_CANNOT_SUPPORT;
1172 case SEC_E_OK:
1173 return RPC_S_OK;
1174 default:
1175 return RPC_S_SEC_PKG_ERROR;
1176 }
1177}
SECURITY_STATUS WINAPI RevertSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:594

Referenced by rpcrt4_conn_np_revert_to_self().

◆ RPCRT4_default_secure_packet()

RPC_STATUS RPCRT4_default_secure_packet ( RpcConnection Connection,
enum secure_packet_direction  dir,
RpcPktHdr hdr,
unsigned int  hdr_size,
unsigned char stub_data,
unsigned int  stub_data_size,
RpcAuthVerifier auth_hdr,
unsigned char auth_value,
unsigned int  auth_value_size 
)

Definition at line 678 of file rpc_message.c.

684{
687 SECURITY_STATUS sec_status;
688
689 message.ulVersion = SECBUFFER_VERSION;
690 message.cBuffers = ARRAY_SIZE(buffers);
691 message.pBuffers = buffers;
692
693 buffers[0].cbBuffer = hdr_size;
695 buffers[0].pvBuffer = hdr;
696 buffers[1].cbBuffer = stub_data_size;
697 buffers[1].BufferType = SECBUFFER_DATA;
698 buffers[1].pvBuffer = stub_data;
699 buffers[2].cbBuffer = sizeof(*auth_hdr);
701 buffers[2].pvBuffer = auth_hdr;
702 buffers[3].cbBuffer = auth_value_size;
703 buffers[3].BufferType = SECBUFFER_TOKEN;
704 buffers[3].pvBuffer = auth_value;
705
706 if (dir == SECURE_PACKET_SEND)
707 {
709 {
710 sec_status = EncryptMessage(&Connection->ctx, 0, &message, 0 /* FIXME */);
711 if (sec_status != SEC_E_OK)
712 {
713 ERR("EncryptMessage failed with 0x%08lx\n", sec_status);
714 return RPC_S_SEC_PKG_ERROR;
715 }
716 }
717 else if (auth_hdr->auth_level != RPC_C_AUTHN_LEVEL_NONE)
718 {
719 sec_status = MakeSignature(&Connection->ctx, 0, &message, 0 /* FIXME */);
720 if (sec_status != SEC_E_OK)
721 {
722 ERR("MakeSignature failed with 0x%08lx\n", sec_status);
723 return RPC_S_SEC_PKG_ERROR;
724 }
725 }
726 }
727 else if (dir == SECURE_PACKET_RECEIVE)
728 {
730 {
731 sec_status = DecryptMessage(&Connection->ctx, &message, 0 /* FIXME */, 0);
732 if (sec_status != SEC_E_OK)
733 {
734 ERR("DecryptMessage failed with 0x%08lx\n", sec_status);
735 return RPC_S_SEC_PKG_ERROR;
736 }
737 }
738 else if (auth_hdr->auth_level != RPC_C_AUTHN_LEVEL_NONE)
739 {
740 sec_status = VerifySignature(&Connection->ctx, &message, 0 /* FIXME */, NULL);
741 if (sec_status != SEC_E_OK)
742 {
743 ERR("VerifySignature failed with 0x%08lx\n", sec_status);
744 return RPC_S_SEC_PKG_ERROR;
745 }
746 }
747 }
748
749 return RPC_S_OK;
750}
unsigned int dir
Definition: maze.c:112
#define ARRAY_SIZE(A)
Definition: main.h:20
const GLuint * buffers
Definition: glext.h:5916
#define SECBUFFER_DATA
Definition: sspi.h:160
#define SECBUFFER_READONLY_WITH_CHECKSUM
Definition: sspi.h:177
#define SECBUFFER_VERSION
Definition: sspi.h:187
@ SECURE_PACKET_SEND
Definition: rpc_binding.h:32
@ SECURE_PACKET_RECEIVE
Definition: rpc_binding.h:33
static BOOL packet_has_body(const RpcPktHdr *Header)
Definition: rpc_message.c:81
#define RPC_C_AUTHN_LEVEL_NONE
Definition: rpcdce.h:146
unsigned char auth_level
Definition: rpc_defs.h:166
Definition: tftpd.h:60
SECURITY_STATUS WINAPI EncryptMessage(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: wrapper.c:1006
SECURITY_STATUS WINAPI MakeSignature(PCtxtHandle phContext, ULONG fQOP, PSecBufferDesc pMessage, ULONG MessageSeqNo)
Definition: wrapper.c:623
SECURITY_STATUS WINAPI DecryptMessage(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: wrapper.c:1036
SECURITY_STATUS WINAPI VerifySignature(PCtxtHandle phContext, PSecBufferDesc pMessage, ULONG MessageSeqNo, PULONG pfQOP)
Definition: wrapper.c:653

◆ RPCRT4_GetHeaderSize()

DWORD RPCRT4_GetHeaderSize ( const RpcPktHdr Header)

Definition at line 58 of file rpc_message.c.

59{
60 static const DWORD header_sizes[] = {
61 sizeof(Header->request), 0, sizeof(Header->response),
62 sizeof(Header->fault), 0, 0, 0, 0, 0, 0, 0, sizeof(Header->bind),
63 sizeof(Header->bind_ack), sizeof(Header->bind_nack),
64 0, 0, sizeof(Header->auth3), 0, 0, 0, sizeof(Header->http)
65 };
66 ULONG ret = 0;
67
68 if (Header->common.ptype < ARRAY_SIZE(header_sizes)) {
69 ret = header_sizes[Header->common.ptype];
70 if (ret == 0)
71 FIXME("unhandled packet type %u\n", Header->common.ptype);
72 if (Header->common.flags & RPC_FLG_OBJECT_UUID)
73 ret += sizeof(UUID);
74 } else {
75 WARN("invalid packet type %u\n", Header->common.ptype);
76 }
77
78 return ret;
79}
return ret
Definition: mutex.c:146

Referenced by RPCRT4_default_receive_fragment(), rpcrt4_ncacn_http_receive_fragment(), RPCRT4_ReceiveWithAuth(), and RPCRT4_ValidateCommonHeader().

◆ RPCRT4_IsValidHttpPacket()

BOOL RPCRT4_IsValidHttpPacket ( RpcPktHdr hdr,
unsigned char data,
unsigned short  data_len 
)

Definition at line 479 of file rpc_message.c.

481{
482 unsigned short i;
483 BYTE *p = data;
484
485 for (i = 0; i < hdr->http.num_data_items; i++)
486 {
487 ULONG type;
488
489 if (data_len < sizeof(ULONG))
490 return FALSE;
491
492 type = *(ULONG *)p;
493 p += sizeof(ULONG);
494 data_len -= sizeof(ULONG);
495
496 switch (type)
497 {
498 case 0x3:
499 case 0xc:
500 if (data_len < sizeof(GUID))
501 return FALSE;
502 p += sizeof(GUID);
503 data_len -= sizeof(GUID);
504 break;
505 case 0x0:
506 case 0x2:
507 case 0x4:
508 case 0x5:
509 case 0x6:
510 case 0xd:
511 if (data_len < sizeof(ULONG))
512 return FALSE;
513 p += sizeof(ULONG);
514 data_len -= sizeof(ULONG);
515 break;
516 case 0x1:
517 if (data_len < 24)
518 return FALSE;
519 p += 24;
520 data_len -= 24;
521 break;
522 default:
523 FIXME("unimplemented type 0x%lx\n", type);
524 break;
525 }
526 }
527 return TRUE;
528}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
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 char BYTE
Definition: xxhash.c:193

Referenced by rpcrt4_http_read_http_packet(), and rpcrt4_ncacn_http_receive_fragment().

◆ RPCRT4_NextHttpHeaderField()

static unsigned char * RPCRT4_NextHttpHeaderField ( unsigned char data)
static

Definition at line 531 of file rpc_message.c.

532{
533 ULONG type;
534
535 type = *(ULONG *)data;
536 data += sizeof(ULONG);
537
538 switch (type)
539 {
540 case 0x3:
541 case 0xc:
542 return data + sizeof(GUID);
543 case 0x0:
544 case 0x2:
545 case 0x4:
546 case 0x5:
547 case 0x6:
548 case 0xd:
549 return data + sizeof(ULONG);
550 case 0x1:
551 return data + 24;
552 default:
553 FIXME("unimplemented type 0x%lx\n", type);
554 return data;
555 }
556}

Referenced by RPCRT4_ParseHttpFlowControlHeader(), and RPCRT4_ParseHttpPrepareHeader2().

◆ RPCRT4_ParseHttpFlowControlHeader()

RPC_STATUS RPCRT4_ParseHttpFlowControlHeader ( RpcPktHdr header,
unsigned char data,
BOOL  server,
ULONG bytes_transmitted,
ULONG flow_control_increment,
UUID pipe_uuid 
)

Definition at line 633 of file rpc_message.c.

638{
639 ULONG type;
640 if (header->http.flags != 0x2)
641 {
642 ERR("invalid flags 0x%x\n", header->http.flags);
644 }
645 if (header->http.num_data_items != 2)
646 {
647 ERR("invalid number of data items %d\n", header->http.num_data_items);
649 }
650
652 if (type != 0x0000000d)
653 {
654 ERR("invalid type for field 1: 0x%08lx\n", type);
656 }
657 if (*(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data) != (server ? 0x3 : 0x0))
658 {
659 ERR("invalid type for 0xd field data: 0x%08lx\n", *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data));
661 }
663
665 if (type != 0x00000001)
666 {
667 ERR("invalid type for field 2: 0x%08lx\n", type);
669 }
670 *bytes_transmitted = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data);
671 *flow_control_increment = *(ULONG *)(GET_HTTP_PAYLOAD_FIELD_DATA(data) + 4);
672 *pipe_uuid = *(UUID *)(GET_HTTP_PAYLOAD_FIELD_DATA(data) + 8);
673
674 return RPC_S_OK;
675}
static unsigned char * RPCRT4_NextHttpHeaderField(unsigned char *data)
Definition: rpc_message.c:531
#define GET_HTTP_PAYLOAD_FIELD_DATA(data)
Definition: rpc_message.c:559
#define READ_HTTP_PAYLOAD_FIELD_TYPE(data)
Definition: rpc_message.c:558

Referenced by rpcrt4_ncacn_http_receive_fragment().

◆ RPCRT4_ParseHttpPrepareHeader1()

RPC_STATUS RPCRT4_ParseHttpPrepareHeader1 ( RpcPktHdr header,
unsigned char data,
ULONG field1 
)

Definition at line 562 of file rpc_message.c.

564{
565 ULONG type;
566 if (header->http.flags != 0x0)
567 {
568 ERR("invalid flags 0x%x\n", header->http.flags);
570 }
571 if (header->http.num_data_items != 1)
572 {
573 ERR("invalid number of data items %d\n", header->http.num_data_items);
575 }
577 if (type != 0x00000002)
578 {
579 ERR("invalid type 0x%08lx\n", type);
581 }
583 return RPC_S_OK;
584}

Referenced by rpcrt4_http_prepare_out_pipe().

◆ RPCRT4_ParseHttpPrepareHeader2()

RPC_STATUS RPCRT4_ParseHttpPrepareHeader2 ( RpcPktHdr header,
unsigned char data,
ULONG field1,
ULONG bytes_until_next_packet,
ULONG field3 
)

Definition at line 587 of file rpc_message.c.

591{
592 ULONG type;
593 if (header->http.flags != 0x0)
594 {
595 ERR("invalid flags 0x%x\n", header->http.flags);
597 }
598 if (header->http.num_data_items != 3)
599 {
600 ERR("invalid number of data items %d\n", header->http.num_data_items);
602 }
603
605 if (type != 0x00000006)
606 {
607 ERR("invalid type for field 1: 0x%08lx\n", type);
609 }
612
614 if (type != 0x00000000)
615 {
616 ERR("invalid type for field 2: 0x%08lx\n", type);
618 }
619 *bytes_until_next_packet = *(ULONG *)GET_HTTP_PAYLOAD_FIELD_DATA(data);
621
623 if (type != 0x00000002)
624 {
625 ERR("invalid type for field 3: 0x%08lx\n", type);
627 }
629
630 return RPC_S_OK;
631}

Referenced by rpcrt4_http_prepare_out_pipe().

◆ RPCRT4_Receive()

static RPC_STATUS RPCRT4_Receive ( RpcConnection Connection,
RpcPktHdr **  Header,
PRPC_MESSAGE  pMsg 
)
static

Definition at line 1550 of file rpc_message.c.

1552{
1553 return RPCRT4_ReceiveWithAuth(Connection, Header, pMsg, NULL, NULL);
1554}
RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, ULONG *auth_length_out)
Definition: rpc_message.c:1372

Referenced by I_RpcReceive().

◆ RPCRT4_receive_fragment()

static RPC_STATUS RPCRT4_receive_fragment ( RpcConnection Connection,
RpcPktHdr **  Header,
void **  Payload 
)
static

Definition at line 1358 of file rpc_message.c.

1359{
1360 if (Connection->ops->receive_fragment)
1361 return Connection->ops->receive_fragment(Connection, Header, Payload);
1362 else
1363 return RPCRT4_default_receive_fragment(Connection, Header, Payload);
1364}
static RPC_STATUS RPCRT4_default_receive_fragment(RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
Definition: rpc_message.c:1284

Referenced by RPCRT4_ReceiveWithAuth().

◆ RPCRT4_ReceiveWithAuth()

RPC_STATUS RPCRT4_ReceiveWithAuth ( RpcConnection Connection,
RpcPktHdr **  Header,
PRPC_MESSAGE  pMsg,
unsigned char **  auth_data_out,
ULONG auth_length_out 
)

Definition at line 1372 of file rpc_message.c.

1376{
1378 DWORD hdr_length;
1379 unsigned short first_flag;
1380 ULONG data_length;
1381 ULONG buffer_length;
1382 ULONG auth_length = 0;
1383 unsigned char *auth_data = NULL;
1384 RpcPktHdr *CurrentHeader = NULL;
1385 void *payload = NULL;
1386
1387 *Header = NULL;
1388 pMsg->Buffer = NULL;
1389 if (auth_data_out) *auth_data_out = NULL;
1390 if (auth_length_out) *auth_length_out = 0;
1391
1392 TRACE("(%p, %p, %p, %p)\n", Connection, Header, pMsg, auth_data_out);
1393
1395
1396 status = RPCRT4_receive_fragment(Connection, Header, &payload);
1397 if (status != RPC_S_OK) goto fail;
1398
1399 hdr_length = RPCRT4_GetHeaderSize(*Header);
1400
1401 /* read packet body */
1402 switch ((*Header)->common.ptype) {
1403 case PKT_RESPONSE:
1404 pMsg->BufferLength = (*Header)->response.alloc_hint;
1405 break;
1406 case PKT_REQUEST:
1407 pMsg->BufferLength = (*Header)->request.alloc_hint;
1408 break;
1409 default:
1410 pMsg->BufferLength = (*Header)->common.frag_len - hdr_length - RPC_AUTH_VERIFIER_LEN(&(*Header)->common);
1411 }
1412
1413 TRACE("buffer length = %u\n", pMsg->BufferLength);
1414
1415 pMsg->Buffer = I_RpcAllocate(pMsg->BufferLength);
1416 if (!pMsg->Buffer)
1417 {
1419 goto fail;
1420 }
1421
1422 first_flag = RPC_FLG_FIRST;
1423 auth_length = (*Header)->common.auth_len;
1424 if (auth_length) {
1425 auth_data = malloc(RPC_AUTH_VERIFIER_LEN(&(*Header)->common));
1426 if (!auth_data) {
1428 goto fail;
1429 }
1430 }
1431 CurrentHeader = *Header;
1432 buffer_length = 0;
1433 while (TRUE)
1434 {
1435 unsigned int header_auth_len = RPC_AUTH_VERIFIER_LEN(&CurrentHeader->common);
1436
1437 /* verify header fields */
1438
1439 if ((CurrentHeader->common.frag_len < hdr_length) ||
1440 (CurrentHeader->common.frag_len - hdr_length < header_auth_len)) {
1441 WARN("frag_len %d too small for hdr_length %ld and auth_len %d\n",
1442 CurrentHeader->common.frag_len, hdr_length, CurrentHeader->common.auth_len);
1444 goto fail;
1445 }
1446
1447 if (CurrentHeader->common.auth_len != auth_length) {
1448 WARN("auth_len header field changed from %ld to %d\n",
1449 auth_length, CurrentHeader->common.auth_len);
1451 goto fail;
1452 }
1453
1454 if ((CurrentHeader->common.flags & RPC_FLG_FIRST) != first_flag) {
1455 TRACE("invalid packet flags\n");
1457 goto fail;
1458 }
1459
1460 data_length = CurrentHeader->common.frag_len - hdr_length - header_auth_len;
1461 if (data_length + buffer_length > pMsg->BufferLength) {
1462 TRACE("allocation hint exceeded, new buffer length = %ld\n",
1463 data_length + buffer_length);
1464 pMsg->BufferLength = data_length + buffer_length;
1466 if (status != RPC_S_OK) goto fail;
1467 }
1468
1469 memcpy((unsigned char *)pMsg->Buffer + buffer_length, payload, data_length);
1470
1471 if (header_auth_len) {
1472 if (header_auth_len < sizeof(RpcAuthVerifier) ||
1473 header_auth_len > RPC_AUTH_VERIFIER_LEN(&(*Header)->common)) {
1474 WARN("bad auth verifier length %d\n", header_auth_len);
1476 goto fail;
1477 }
1478
1479 /* FIXME: we should accumulate authentication data for the bind,
1480 * bind_ack, alter_context and alter_context_response if necessary.
1481 * however, the details of how this is done is very sketchy in the
1482 * DCE/RPC spec. for all other packet types that have authentication
1483 * verifier data then it is just duplicated in all the fragments */
1484 memcpy(auth_data, (unsigned char *)payload + data_length, header_auth_len);
1485
1486 /* these packets are handled specially, not by the generic SecurePacket
1487 * function */
1489 {
1491 CurrentHeader, hdr_length,
1492 (unsigned char *)pMsg->Buffer + buffer_length, data_length,
1493 (RpcAuthVerifier *)auth_data,
1494 auth_data + sizeof(RpcAuthVerifier),
1495 header_auth_len - sizeof(RpcAuthVerifier));
1496 if (status != RPC_S_OK) goto fail;
1497 }
1498 }
1499
1500 buffer_length += data_length;
1501 if (!(CurrentHeader->common.flags & RPC_FLG_LAST)) {
1502 TRACE("next header\n");
1503
1504 if (*Header != CurrentHeader)
1505 {
1506 free(CurrentHeader);
1507 CurrentHeader = NULL;
1508 }
1509 free(payload);
1510 payload = NULL;
1511
1512 status = RPCRT4_receive_fragment(Connection, &CurrentHeader, &payload);
1513 if (status != RPC_S_OK) goto fail;
1514
1515 first_flag = 0;
1516 } else {
1517 break;
1518 }
1519 }
1520 pMsg->BufferLength = buffer_length;
1521
1522 /* success */
1523 status = RPC_S_OK;
1524
1525fail:
1527 if (CurrentHeader != *Header)
1528 free(CurrentHeader);
1529 if (status != RPC_S_OK) {
1530 I_RpcFree(pMsg->Buffer);
1531 pMsg->Buffer = NULL;
1532 free(*Header);
1533 *Header = NULL;
1534 }
1535 if (auth_data_out && status == RPC_S_OK) {
1536 *auth_length_out = auth_length;
1537 *auth_data_out = auth_data;
1538 }
1539 else
1540 free(auth_data);
1541 free(payload);
1542 return status;
1543}
static RPC_STATUS rpcrt4_conn_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)
Definition: rpc_binding.h:228
static BOOL rpcrt4_conn_is_authorized(RpcConnection *Connection)
Definition: rpc_binding.h:216
void RPCRT4_SetThreadCurrentConnection(RpcConnection *Connection)
Definition: rpcrt4_main.c:985
#define RPC_AUTH_VERIFIER_LEN(common_hdr)
Definition: rpc_defs.h:173
static BOOL packet_does_auth_negotiation(const RpcPktHdr *Header)
Definition: rpc_message.c:94
static RPC_STATUS I_RpcReAllocateBuffer(PRPC_MESSAGE pMsg)
Definition: rpc_message.c:1668
static RPC_STATUS RPCRT4_receive_fragment(RpcConnection *Connection, RpcPktHdr **Header, void **Payload)
Definition: rpc_message.c:1358
unsigned char flags
Definition: rpc_defs.h:31
unsigned short auth_len
Definition: rpc_defs.h:34
RpcPktCommonHdr common
Definition: rpc_defs.h:152

Referenced by RpcAssoc_BindConnection(), RPCRT4_io_thread(), and RPCRT4_Receive().

◆ RPCRT4_Send()

RPC_STATUS RPCRT4_Send ( RpcConnection Connection,
RpcPktHdr Header,
void Buffer,
unsigned int  BufferLength 
)

Definition at line 1219 of file rpc_message.c.

1221{
1222 RPC_STATUS r;
1223
1225 Connection->AuthInfo &&
1226 !rpcrt4_conn_is_authorized(Connection))
1227 {
1228 unsigned int out_size = 0;
1229 unsigned char *out_buffer;
1230
1231 r = rpcrt4_conn_authorize(Connection, TRUE, NULL, 0, NULL, &out_size);
1232 if (r != RPC_S_OK) return r;
1233
1236
1237 /* tack on a negotiate packet */
1238 r = rpcrt4_conn_authorize(Connection, TRUE, NULL, 0, out_buffer, &out_size);
1239 if (r == RPC_S_OK)
1241
1243 }
1244 else
1245 r = RPCRT4_SendWithAuth(Connection, Header, Buffer, BufferLength, NULL, 0);
1246
1247 return r;
1248}
Definition: bufpool.h:45

Referenced by I_RpcSend(), process_request_packet(), and RpcAssoc_BindConnection().

◆ RPCRT4_SendWithAuth()

RPC_STATUS RPCRT4_SendWithAuth ( RpcConnection Connection,
RpcPktHdr Header,
void Buffer,
unsigned int  BufferLength,
const void Auth,
unsigned int  AuthLength 
)

Definition at line 757 of file rpc_message.c.

760{
761 PUCHAR buffer_pos;
762 DWORD hdr_size;
763 LONG count;
764 unsigned char *pkt;
765 LONG alen;
767
769
770 buffer_pos = Buffer;
771 /* The packet building functions save the packet header size, so we can use it. */
772 hdr_size = Header->common.frag_len;
773 if (AuthLength)
774 Header->common.auth_len = AuthLength;
775 else if (Connection->AuthInfo && packet_has_auth_verifier(Header))
776 {
778 Header->common.auth_len = Connection->encryption_auth_len;
779 else
780 Header->common.auth_len = Connection->signature_auth_len;
781 }
782 else
783 Header->common.auth_len = 0;
784 Header->common.flags |= RPC_FLG_FIRST;
785 Header->common.flags &= ~RPC_FLG_LAST;
786
787 alen = RPC_AUTH_VERIFIER_LEN(&Header->common);
788
789 while (!(Header->common.flags & RPC_FLG_LAST)) {
790 unsigned char auth_pad_len = Header->common.auth_len ? ROUND_UP_AMOUNT(BufferLength, AUTH_ALIGNMENT) : 0;
791 unsigned int pkt_size = BufferLength + hdr_size + alen + auth_pad_len;
792
793 /* decide if we need to split the packet into fragments */
794 if (pkt_size <= Connection->MaxTransmissionSize) {
795 Header->common.flags |= RPC_FLG_LAST;
796 Header->common.frag_len = pkt_size;
797 } else {
798 auth_pad_len = 0;
799 /* make sure packet payload will be a multiple of 16 */
800 Header->common.frag_len =
801 ((Connection->MaxTransmissionSize - hdr_size - alen) & ~(AUTH_ALIGNMENT-1)) +
802 hdr_size + alen;
803 }
804
805 pkt = calloc(1, Header->common.frag_len);
806
807 memcpy(pkt, Header, hdr_size);
808
809 /* fragment consisted of header only and is the last one */
810 if (hdr_size == Header->common.frag_len)
811 goto write;
812
813 memcpy(pkt + hdr_size, buffer_pos, Header->common.frag_len - hdr_size - auth_pad_len - alen);
814
815 /* add the authorization info */
816 if (Header->common.auth_len)
817 {
818 RpcAuthVerifier *auth_hdr = (RpcAuthVerifier *)&pkt[Header->common.frag_len - alen];
819
820 auth_hdr->auth_type = Connection->AuthInfo->AuthnSvc;
821 auth_hdr->auth_level = Connection->AuthInfo->AuthnLevel;
822 auth_hdr->auth_pad_length = auth_pad_len;
823 auth_hdr->auth_reserved = 0;
824 /* a unique number... */
825 auth_hdr->auth_context_id = Connection->auth_context_id;
826
827 if (AuthLength)
828 memcpy(auth_hdr + 1, Auth, AuthLength);
829 else
830 {
832 (RpcPktHdr *)pkt, hdr_size,
833 pkt + hdr_size, Header->common.frag_len - hdr_size - alen,
834 auth_hdr,
835 (unsigned char *)(auth_hdr + 1), Header->common.auth_len);
836 if (status != RPC_S_OK)
837 {
838 free(pkt);
840 return status;
841 }
842 }
843 }
844
845write:
846 count = rpcrt4_conn_write(Connection, pkt, Header->common.frag_len);
847 free(pkt);
848 if (count<0) {
849 WARN("rpcrt4_conn_write failed (auth)\n");
851 return RPC_S_CALL_FAILED;
852 }
853
854 buffer_pos += Header->common.frag_len - hdr_size - alen - auth_pad_len;
855 BufferLength -= Header->common.frag_len - hdr_size - alen - auth_pad_len;
856 Header->common.flags &= ~RPC_FLG_FIRST;
857 }
858
860 return RPC_S_OK;
861}
#define write
Definition: acwin.h:97
if(dx< 0)
Definition: linetemp.h:194
static int rpcrt4_conn_write(RpcConnection *Connection, const void *buffer, unsigned int len)
Definition: rpc_binding.h:190
static BOOL packet_has_auth_verifier(const RpcPktHdr *Header)
Definition: rpc_message.c:88
#define ROUND_UP_AMOUNT(value, alignment)
Definition: rpc_message.c:52
#define AUTH_ALIGNMENT
Definition: rpc_message.c:49
unsigned char auth_type
Definition: rpc_defs.h:165
unsigned char auth_pad_length
Definition: rpc_defs.h:167
unsigned char auth_reserved
Definition: rpc_defs.h:168
unsigned int auth_context_id
Definition: rpc_defs.h:169
USHORT MaxTransmissionSize
Definition: rpc_binding.h:71
ULONG auth_context_id
Definition: rpc_binding.h:78
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by process_bind_packet(), RPCRT4_ClientConnectionAuth(), and RPCRT4_Send().

◆ RPCRT4_ServerConnectionAuth()

RPC_STATUS RPCRT4_ServerConnectionAuth ( RpcConnection conn,
BOOL  start,
RpcAuthVerifier auth_data_in,
ULONG  auth_length_in,
unsigned char **  auth_data_out,
ULONG auth_length_out 
)

Definition at line 1021 of file rpc_message.c.

1027{
1028 unsigned char *out_buffer;
1029 unsigned int out_size;
1031
1032 if (start)
1033 {
1034 /* remove any existing authentication information */
1035 if (conn->AuthInfo)
1036 {
1038 conn->AuthInfo = NULL;
1039 }
1040 if (SecIsValidHandle(&conn->ctx))
1041 {
1042 DeleteSecurityContext(&conn->ctx);
1043 SecInvalidateHandle(&conn->ctx);
1044 }
1045 if (auth_length_in >= sizeof(RpcAuthVerifier))
1046 {
1047 CredHandle cred;
1048 TimeStamp exp;
1049 ULONG max_token;
1050
1052 auth_data_in->auth_type, &cred, &exp, &max_token);
1053 if (status != RPC_S_OK)
1054 {
1055 ERR("unknown authentication service %u\n", auth_data_in->auth_type);
1056 return status;
1057 }
1058
1059 status = RpcAuthInfo_Create(auth_data_in->auth_level,
1060 auth_data_in->auth_type, cred, exp,
1061 max_token, NULL, &conn->AuthInfo);
1062 if (status != RPC_S_OK)
1063 {
1064 FreeCredentialsHandle(&cred);
1065 return status;
1066 }
1067
1068 /* FIXME: should auth_data_in->auth_context_id be checked in the !start case? */
1069 conn->auth_context_id = auth_data_in->auth_context_id;
1070 }
1071 }
1072
1073 if (auth_length_in < sizeof(RpcAuthVerifier))
1074 return RPC_S_OK;
1075
1076 if (!conn->AuthInfo)
1077 /* should have filled in authentication info by now */
1078 return RPC_S_PROTOCOL_ERROR;
1079
1081 conn, start, (unsigned char *)(auth_data_in + 1),
1082 auth_length_in - sizeof(RpcAuthVerifier), NULL, &out_size);
1083 if (status) return status;
1084
1087
1089 conn, start, (unsigned char *)(auth_data_in + 1),
1090 auth_length_in - sizeof(RpcAuthVerifier), out_buffer, &out_size);
1091 if (status != RPC_S_OK)
1092 {
1094 return status;
1095 }
1096
1097 if (out_size && !auth_length_out)
1098 {
1099 ERR("expected authentication to be complete but SSP returned data of "
1100 "%u bytes to be sent back to client\n", out_size);
1102 return RPC_S_SEC_PKG_ERROR;
1103 }
1104 else
1105 {
1106 *auth_data_out = out_buffer;
1107 *auth_length_out = out_size;
1108 }
1109
1110 return status;
1111}
GLuint start
Definition: gl.h:1545
DWORD exp
Definition: msg.c:16058
#define SecInvalidateHandle(x)
Definition: sspi.h:58
RPC_STATUS RpcAuthInfo_Create(ULONG AuthnLevel, ULONG AuthnSvc, CredHandle cred, TimeStamp exp, ULONG cbMaxToken, RPC_AUTH_IDENTITY_HANDLE identity, RpcAuthInfo **ret)
Definition: rpc_binding.c:1099
ULONG RpcAuthInfo_Release(RpcAuthInfo *AuthInfo)
Definition: rpc_binding.c:1170
RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo(USHORT auth_type, CredHandle *cred, TimeStamp *exp, ULONG *max_token)
Definition: rpc_server.c:1365
SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
Definition: wrapper.c:450
SECURITY_STATUS WINAPI FreeCredentialsHandle(PCredHandle phCredential)
Definition: wrapper.c:151

Referenced by process_auth3_packet(), and process_bind_packet_no_send().

◆ RPCRT4_ValidateCommonHeader()

RPC_STATUS RPCRT4_ValidateCommonHeader ( const RpcPktCommonHdr hdr)

Definition at line 1251 of file rpc_message.c.

1252{
1253 DWORD hdr_length;
1254
1255 /* verify if the header really makes sense */
1256 if (hdr->rpc_ver != RPC_VER_MAJOR ||
1257 hdr->rpc_ver_minor != RPC_VER_MINOR)
1258 {
1259 WARN("unhandled packet version\n");
1260 return RPC_S_PROTOCOL_ERROR;
1261 }
1262
1263 hdr_length = RPCRT4_GetHeaderSize((const RpcPktHdr*)hdr);
1264 if (hdr_length == 0)
1265 {
1266 WARN("header length == 0\n");
1267 return RPC_S_PROTOCOL_ERROR;
1268 }
1269
1270 if (hdr->frag_len < hdr_length)
1271 {
1272 WARN("bad frag length %d\n", hdr->frag_len);
1273 return RPC_S_PROTOCOL_ERROR;
1274 }
1275
1276 return RPC_S_OK;
1277}

Referenced by RPCRT4_default_receive_fragment(), and rpcrt4_ncacn_http_receive_fragment().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( rpc  )