rpc_client_new(rpc);
rpc->client->SynchronousSend = TRUE;
+ rpc->client->SynchronousReceive = TRUE;
}
return rpc;
BOOL rpc_get_stub_data_info(rdpRpc* rpc, BYTE* header, UINT32* offset, UINT32* length);
int rpc_recv_pdu_header(rdpRpc* rpc, BYTE* header);
-int rpc_recv_pdu_fragment(rdpRpc* rpc);
RPC_PDU* rpc_recv_pdu(rdpRpc* rpc);
int rpc_write(rdpRpc* rpc, BYTE* data, int length, UINT16 opnum);
#include <winpr/crt.h>
+#include "rpc_client.h"
+
#include "rpc_bind.h"
/**
BYTE* auth_data;
rpcconn_hdr_t* header;
- pdu = rpc_recv_pdu(rpc);
+ pdu = rpc_recv_dequeue_pdu(rpc);
if (!pdu)
return -1;
InterlockedPushEntrySList(rpc->ReceiveQueue, &(pdu->ItemEntry));
ReleaseSemaphore(rpc->client->ReceiveSemaphore, 1, NULL);
- if (rpc->client->SynchronousReceive)
- {
- WaitForSingleObject(rpc->client->PduReceivedEvent, INFINITE);
- ResetEvent(rpc->client->PduReceivedEvent);
- }
-
return 0;
}
-int rpc_recv_dequeue_pdu(rdpRpc* rpc)
+RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc)
{
+ RPC_PDU* pdu;
+ DWORD dwMilliseconds;
+
+ pdu = NULL;
+ dwMilliseconds = rpc->client->SynchronousReceive ? INFINITE : 0;
+
if (rpc->client->SynchronousReceive)
- SetEvent(rpc->client->PduReceivedEvent);
+ rpc_recv_enqueue_pdu(rpc);
- return 0;
+ if (WaitForSingleObject(rpc->client->ReceiveSemaphore, dwMilliseconds) == WAIT_OBJECT_0)
+ {
+ pdu = (RPC_PDU*) InterlockedPopEntrySList(rpc->ReceiveQueue);
+ return pdu;
+ }
+
+ return pdu;
}
static void* rpc_client_thread(void* arg)
if (WaitForSingleObject(ReadEvent, 0) == WAIT_OBJECT_0)
{
-
+ if (!rpc->client->SynchronousReceive)
+ rpc_recv_enqueue_pdu(rpc);
}
rpc_send_dequeue_pdu(rpc);
int rpc_send_enqueue_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length);
int rpc_send_dequeue_pdu(rdpRpc* rpc);
+int rpc_recv_enqueue_pdu(rdpRpc* rpc);
+RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc);
+
int rpc_client_new(rdpRpc* rpc);
int rpc_client_start(rdpRpc* rpc);
#include <winpr/crt.h>
#include "ncacn_http.h"
+#include "rpc_client.h"
#include "rts.h"
BOOL rts_connect(rdpRpc* rpc)
{
- int status;
RPC_PDU* pdu;
rpcconn_rts_hdr_t* rts;
HttpResponse* http_response;
*
*/
- pdu = rpc_recv_pdu(rpc);
+ pdu = rpc_recv_dequeue_pdu(rpc);
if (!pdu)
return FALSE;
*
*/
- pdu = rpc_recv_pdu(rpc);
+ pdu = rpc_recv_dequeue_pdu(rpc);
if (!pdu)
return FALSE;
#include <winpr/ndr.h>
#include <winpr/error.h>
+#include "rpc_client.h"
+
#include "tsg.h"
/**
PTSG_PACKET_CAPS_RESPONSE packetCapsResponse;
PTSG_PACKET_QUARENC_RESPONSE packetQuarEncResponse;
- pdu = rpc_recv_pdu(rpc);
+ pdu = rpc_recv_dequeue_pdu(rpc);
if (!pdu)
return FALSE;
rdpRpc* rpc = tsg->rpc;
PTSG_PACKET_RESPONSE packetResponse;
- pdu = rpc_recv_pdu(rpc);
+ pdu = rpc_recv_dequeue_pdu(rpc);
if (!pdu)
return FALSE;
UINT32 length;
rdpRpc* rpc = tsg->rpc;
- pdu = rpc_recv_pdu(rpc);
+ pdu = rpc_recv_dequeue_pdu(rpc);
if (!pdu)
return FALSE;
}
else
{
- tsg->pdu = rpc_recv_pdu(rpc);
+ tsg->pdu = rpc_recv_dequeue_pdu(rpc);
if ((tsg->pdu->Flags & RPC_PDU_FLAG_STUB) && (tsg->pdu->Length == 4))
{
}
tsg->PendingPdu = TRUE;
- tsg->BytesAvailable = rpc->pdu->Length;
+ tsg->BytesAvailable = tsg->pdu->Length;
tsg->BytesRead = 0;
CopyLength = (tsg->BytesAvailable > length) ? length : tsg->BytesAvailable;