NOP and ACK shit

This commit is contained in:
Elijah R 2023-12-10 15:21:13 -05:00
parent 3716ba482f
commit b2646e7340
3 changed files with 30 additions and 2 deletions

View file

@ -17,6 +17,7 @@ namespace CollabVMAgent
static readonly string UploadsFolder = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Desktop";
static MessagePackSerializer serializer = MessagePackSerializer.Get<ProtocolMessage>();
static VirtIOSerial vio;
static void Main(string[] args)
{
if (!IsAdmin())
@ -31,8 +32,16 @@ namespace CollabVMAgent
#if DEBUG
Console.WriteLine("Starting CollabVM Agent in Debug mode");
#endif
VirtIOSerial vio = new VirtIOSerial();
vio = new VirtIOSerial();
vio.Data += OnData;
if (vio.WriteMsg(new ProtocolMessage{
Operation = ProtocolOperation.NOP
}))
{
#if DEBUG
Console.WriteLine("Wrote NOP");
#endif
}
Thread.Sleep(-1);
}
@ -79,6 +88,20 @@ namespace CollabVMAgent
}
break;
}
case ProtocolOperation.NOP:
{
if (vio.WriteMsg(new ProtocolMessage
{
Operation = ProtocolOperation.NOP
}))
{
#if DEBUG
Console.WriteLine("Wrote NOP");
#endif
}
break;
}
}
}

View file

@ -11,6 +11,7 @@ namespace CollabVMAgent.Protocol
public enum ProtocolOperation : ushort
{
UploadFile = 0,
ACK = 1
ACK = 1,
NOP = 2,
}
}

View file

@ -89,6 +89,10 @@ namespace CollabVMAgent
#if DEBUG
Console.WriteLine($"Reported payload size: {size}");
#endif
if (size == 0)
{
continue;
}
// Read the message
uint position = 0;
byte[] buf = new byte[COPY_BUFFER_SIZE];