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

View file

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