2023-08-24 09:29:16 +02:00
|
|
|
|
using Serilog;
|
|
|
|
|
using System;
|
2023-08-23 17:16:13 +02:00
|
|
|
|
using System.Collections.Generic;
|
2023-08-24 09:29:16 +02:00
|
|
|
|
using System.IO.Pipes;
|
2023-08-23 17:16:13 +02:00
|
|
|
|
using System.Linq;
|
2023-08-24 15:12:49 +02:00
|
|
|
|
using System.Reflection.PortableExecutable;
|
2023-08-24 09:29:16 +02:00
|
|
|
|
using System.Runtime.InteropServices;
|
2023-08-23 17:16:13 +02:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace service.messages
|
|
|
|
|
{
|
2023-08-24 09:29:16 +02:00
|
|
|
|
public class Receive : Message
|
2023-08-23 17:16:13 +02:00
|
|
|
|
{
|
2023-08-24 09:29:16 +02:00
|
|
|
|
private byte[] _buffer;
|
|
|
|
|
private static int RECEIVE_BUFFER_SIZE = 8192;
|
|
|
|
|
|
|
|
|
|
private enum RECEIVE_TYPE
|
|
|
|
|
{
|
|
|
|
|
SERVER_SEND_MODULE_INTEGRITY_CHECK = 10
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Receive(NamedPipeServerStream pipeServer, int pipePacketHeaderSize)
|
|
|
|
|
: base(pipeServer, pipePacketHeaderSize)
|
|
|
|
|
{
|
|
|
|
|
_buffer = new byte[RECEIVE_BUFFER_SIZE];
|
2023-08-24 15:12:49 +02:00
|
|
|
|
|
|
|
|
|
StoreMessage();
|
2023-08-24 09:29:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StoreMessage()
|
|
|
|
|
{
|
|
|
|
|
ReadPipeBuffer(ref _buffer, RECEIVE_BUFFER_SIZE);
|
|
|
|
|
|
2023-08-24 15:12:49 +02:00
|
|
|
|
Types.Receive.PIPE_PACKET_SEND_EXTENSION_HEADER header =
|
|
|
|
|
GetPacketHeader<Types.Receive.PIPE_PACKET_SEND_EXTENSION_HEADER>(ref _buffer);
|
2023-08-24 09:29:16 +02:00
|
|
|
|
|
2023-08-24 15:12:49 +02:00
|
|
|
|
PrintPacketInformation(header);
|
2023-08-24 09:29:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-24 15:12:49 +02:00
|
|
|
|
private void PrintPacketInformation(Types.Receive.PIPE_PACKET_SEND_EXTENSION_HEADER header)
|
2023-08-24 09:29:16 +02:00
|
|
|
|
{
|
2023-08-24 15:12:49 +02:00
|
|
|
|
Log.Information("Incoming packet count: {0:x}, current packet num: {1:x}, current packet size: {2:x}, total packet size: {3:x}",
|
|
|
|
|
header.total_incoming_packet_count,
|
|
|
|
|
header.current_packet_number,
|
|
|
|
|
header.packet_size,
|
|
|
|
|
header.total_incoming_packet_size);
|
2023-08-24 09:29:16 +02:00
|
|
|
|
}
|
2023-08-23 17:16:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|