From 5a4870515a4d7e7b17128a793bc7978cc855ef70 Mon Sep 17 00:00:00 2001 From: lhodges1 Date: Wed, 23 Aug 2023 22:40:44 +1000 Subject: [PATCH] fix send buffer issue --- user/client.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/user/client.cpp b/user/client.cpp index 9c9611c..3387015 100644 --- a/user/client.cpp +++ b/user/client.cpp @@ -33,16 +33,16 @@ void global::Client::ServerSend(PVOID Buffer, SIZE_T Size, INT RequestId) if ( Size > ( SEND_BUFFER_SIZE - total_size_of_headers ) ) { INT total_packets = std::ceil( Size / ( SEND_BUFFER_SIZE - total_size_of_headers ) ); - LONG remaining_bytes = Size; + LONG remaining_bytes = Size + total_packets * total_size_of_headers; - for ( INT count = 0; count < total_packets; count++ ) + for ( INT count = 0; count < total_packets + 1; count++ ) { global::headers::PIPE_PACKET_SEND_EXTENSION_HEADER header_extension; header_extension.request_id = RequestId; header_extension.total_incoming_packet_count = total_packets; header_extension.total_incoming_packet_size = Size; header_extension.current_packet_number = count; - header_extension.packet_size = ( count + 1 ) == total_packets ? remaining_bytes : SEND_BUFFER_SIZE; + header_extension.packet_size = count == total_packets ? remaining_bytes : SEND_BUFFER_SIZE; LOG_INFO( "current packet number: %lx, packet size: %lx", header_extension.current_packet_number, header_extension.packet_size ); @@ -56,6 +56,7 @@ void global::Client::ServerSend(PVOID Buffer, SIZE_T Size, INT RequestId) this->pipe->WriteToPipe( this->send_buffer, header_extension.packet_size ); + LOG_INFO( "remainiong bytes: %lx", remaining_bytes ); remaining_bytes = remaining_bytes - header_extension.packet_size; } }