diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 9081cb638..00ce4c63a 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1298,6 +1298,20 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin if (settings->DisableThemes) settings->PerformanceFlags |= PERF_DISABLE_THEMING; + arg = CommandLineFindArgumentA(args, "p"); + + if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) + { + FillMemory(arg->Value, strlen(arg->Value), '*'); + } + + arg = CommandLineFindArgumentA(args, "gp"); + + if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) + { + FillMemory(arg->Value, strlen(arg->Value), '*'); + } + return 1; } diff --git a/libfreerdp/core/gateway/rpc.c b/libfreerdp/core/gateway/rpc.c index 3fb55b119..817595bb0 100644 --- a/libfreerdp/core/gateway/rpc.c +++ b/libfreerdp/core/gateway/rpc.c @@ -718,13 +718,10 @@ rdpRpc* rpc_new(rdpTransport* transport) rpc->max_xmit_frag = 0x0FF8; rpc->max_recv_frag = 0x0FF8; - rpc->pdu = (RPC_PDU*) _aligned_malloc(sizeof(RPC_PDU), MEMORY_ALLOCATION_ALIGNMENT); + rpc->pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU)); - rpc->SendQueue = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); - InitializeSListHead(rpc->SendQueue); - - rpc->ReceiveQueue = (PSLIST_HEADER) _aligned_malloc(sizeof(SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT); - InitializeSListHead(rpc->ReceiveQueue); + rpc->SendQueue = Queue_New(TRUE, -1, -1); + rpc->ReceiveQueue = Queue_New(TRUE, -1, -1); rpc->ReceiveWindow = 0x00010000; @@ -753,20 +750,16 @@ void rpc_free(rdpRpc* rpc) { if (rpc != NULL) { - RPC_PDU* PduEntry; - ntlm_http_free(rpc->NtlmHttpIn); ntlm_http_free(rpc->NtlmHttpOut); - _aligned_free(rpc->pdu); + free(rpc->pdu); - while ((PduEntry = (RPC_PDU*) InterlockedPopEntrySList(rpc->SendQueue)) != NULL) - _aligned_free(PduEntry); - _aligned_free(rpc->SendQueue); + Queue_Clear(rpc->SendQueue); + Queue_Free(rpc->SendQueue); - while ((PduEntry = (RPC_PDU*) InterlockedPopEntrySList(rpc->ReceiveQueue)) != NULL) - _aligned_free(PduEntry); - _aligned_free(rpc->ReceiveQueue); + Queue_Clear(rpc->ReceiveQueue); + Queue_Free(rpc->ReceiveQueue); rpc_client_virtual_connection_free(rpc->VirtualConnection); rpc_virtual_connection_cookie_table_free(rpc->VirtualConnectionCookieTable); diff --git a/libfreerdp/core/gateway/rpc.h b/libfreerdp/core/gateway/rpc.h index d2d23a14d..4836dd85e 100644 --- a/libfreerdp/core/gateway/rpc.h +++ b/libfreerdp/core/gateway/rpc.h @@ -23,6 +23,7 @@ #define FREERDP_CORE_RPC_H #include +#include #include typedef struct rdp_rpc rdpRpc; @@ -763,8 +764,8 @@ struct rdp_rpc UINT16 max_xmit_frag; UINT16 max_recv_frag; - PSLIST_HEADER SendQueue; - PSLIST_HEADER ReceiveQueue; + wQueue* SendQueue; + wQueue* ReceiveQueue; UINT32 ReceiveWindow; diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index d5f64b661..960b978bc 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -35,11 +35,11 @@ int rpc_send_enqueue_pdu(rdpRpc* rpc, BYTE* buffer, UINT32 length) { RPC_PDU* pdu; - pdu = (RPC_PDU*) _aligned_malloc(sizeof(RPC_PDU), MEMORY_ALLOCATION_ALIGNMENT); + pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU)); pdu->Buffer = buffer; pdu->Length = length; - InterlockedPushEntrySList(rpc->SendQueue, &(pdu->ItemEntry)); + Queue_Enqueue(rpc->SendQueue, pdu); ReleaseSemaphore(rpc->client->SendSemaphore, 1, NULL); if (rpc->client->SynchronousSend) @@ -56,7 +56,7 @@ int rpc_send_dequeue_pdu(rdpRpc* rpc) int status; RPC_PDU* pdu; - pdu = (RPC_PDU*) InterlockedPopEntrySList(rpc->SendQueue); + pdu = (RPC_PDU*) Queue_Dequeue(rpc->SendQueue); if (!pdu) return 0; @@ -77,7 +77,7 @@ int rpc_send_dequeue_pdu(rdpRpc* rpc) rpc->VirtualConnection->DefaultInChannel->SenderAvailableWindow -= status; free(pdu->Buffer); - _aligned_free(pdu); + free(pdu); if (rpc->client->SynchronousSend) SetEvent(rpc->client->PduSentEvent); @@ -97,7 +97,7 @@ int rpc_recv_enqueue_pdu(rdpRpc* rpc) return -1; } - rpc->pdu = (RPC_PDU*) _aligned_malloc(sizeof(RPC_PDU), MEMORY_ALLOCATION_ALIGNMENT); + rpc->pdu = (RPC_PDU*) malloc(sizeof(RPC_PDU)); if (pdu->Flags & RPC_PDU_FLAG_STUB) { @@ -110,7 +110,7 @@ int rpc_recv_enqueue_pdu(rdpRpc* rpc) rpc->FragBuffer = (BYTE*) malloc(rpc->FragBufferSize); } - InterlockedPushEntrySList(rpc->ReceiveQueue, &(pdu->ItemEntry)); + Queue_Enqueue(rpc->ReceiveQueue, pdu); ReleaseSemaphore(rpc->client->ReceiveSemaphore, 1, NULL); return 0; @@ -129,7 +129,7 @@ RPC_PDU* rpc_recv_dequeue_pdu(rdpRpc* rpc) if (WaitForSingleObject(rpc->client->ReceiveSemaphore, dwMilliseconds) == WAIT_OBJECT_0) { - pdu = (RPC_PDU*) InterlockedPopEntrySList(rpc->ReceiveQueue); + pdu = (RPC_PDU*) Queue_Dequeue(rpc->ReceiveQueue); return pdu; } diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h index 634ae85b2..95b4d6ee8 100644 --- a/winpr/include/winpr/collections.h +++ b/winpr/include/winpr/collections.h @@ -47,6 +47,7 @@ typedef struct _wQueue wQueue; WINPR_API int Queue_Count(wQueue* queue); WINPR_API BOOL Queue_IsSynchronized(wQueue* queue); +WINPR_API HANDLE Queue_SyncRoot(wQueue* queue); WINPR_API void Queue_Clear(wQueue* queue); WINPR_API BOOL Queue_Contains(wQueue* queue, void* obj); diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c index ba4287841..211f73802 100644 --- a/winpr/libwinpr/utils/collections/Queue.c +++ b/winpr/libwinpr/utils/collections/Queue.c @@ -52,6 +52,15 @@ BOOL Queue_IsSynchronized(wQueue* queue) return queue->synchronized; } +/** + * Gets an object that can be used to synchronize access to the Queue. + */ + +HANDLE Queue_SyncRoot(wQueue* queue) +{ + return queue->mutex; +} + /** * Methods */ @@ -144,7 +153,7 @@ void* Queue_Dequeue(wQueue* queue) { obj = queue->array[queue->head]; queue->array[queue->head] = NULL; - queue->head = (queue->head + 1) % queue->size; + queue->head = (queue->head + 1) % queue->capacity; queue->size--; } diff --git a/winpr/libwinpr/utils/test/CMakeLists.txt b/winpr/libwinpr/utils/test/CMakeLists.txt index 5c184e1f3..d34853252 100644 --- a/winpr/libwinpr/utils/test/CMakeLists.txt +++ b/winpr/libwinpr/utils/test/CMakeLists.txt @@ -5,6 +5,7 @@ set(MODULE_PREFIX "TEST_WINPR_UTILS") set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c) set(${MODULE_PREFIX}_TESTS + TestQueue.c TestCmdLine.c) create_test_sourcelist(${MODULE_PREFIX}_SRCS diff --git a/winpr/libwinpr/utils/test/TestQueue.c b/winpr/libwinpr/utils/test/TestQueue.c new file mode 100644 index 000000000..8f9d6c014 --- /dev/null +++ b/winpr/libwinpr/utils/test/TestQueue.c @@ -0,0 +1,36 @@ + +#include +#include +#include + +int TestQueue(int argc, char* argv[]) +{ + int item; + int index; + int count; + wQueue* queue; + + queue = Queue_New(TRUE, -1, -1); + + for (index = 1; index <= 10; index++) + { + Queue_Enqueue(queue, (void*) (size_t) index); + } + + count = Queue_Count(queue); + + printf("queue count: %d\n", count); + + for (index = 1; index <= 10; index++) + { + item = (int) (size_t) Queue_Dequeue(queue); + + if (item != index) + return -1; + } + + Queue_Clear(queue); + Queue_Free(queue); + + return 0; +}