bed time c:

This commit is contained in:
lhodges1 2023-09-09 05:06:13 +10:00
parent 3c401a108d
commit 9e7fdb19f6
4 changed files with 69 additions and 16 deletions

View file

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace server.Database
{
public class Report : DatabaseConnection
public class ClientReport : DatabaseConnection
{
private ILogger _logger;
@ -23,7 +23,7 @@ namespace server.Database
MODULE_VERIFICATION_SUCCESS = 70
}
public Report(ILogger<Report> logger)
public ClientReport(ILogger<ClientReport> logger)
{
_logger = logger;
}

View file

@ -0,0 +1,49 @@
using Microsoft.Extensions.Logging;
using server.Types.ClientReport;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace server.Database
{
public class ClientSend : DatabaseConnection
{
private ILogger _logger;
private enum ClientSendCodes
{
MODULE_VERIFICATION_CHECKSUM_FAILURE = 10,
}
public ClientSend(ILogger<ClientSend> logger)
{
_logger = logger;
}
public void InsertReport<T>(T report, int reportCode)
{
if (report == null)
{
_logger.LogError("Report is null");
return;
}
switch (reportCode)
{
case (int)ReportCodes.MODULE_VERIFICATION_CHECKSUM_FAILURE:
InsertReportWithCode10((MODULE_VERIFICATION_CHECKSUM_FAILURE)Convert.ChangeType(report, typeof(MODULE_VERIFICATION_CHECKSUM_FAILURE)));
break;
default:
_logger.LogError("Unknown report code: {0}", reportCode);
break;
}
}
private void InsertReportWithCode10(MODULE_VERIFICATION_CHECKSUM_FAILURE report)
{
}
}
}

View file

@ -86,9 +86,7 @@ namespace server
}
unsafe private void HandleReportMessage(int reportId)
{
_logger.Information("Report id: {0}", reportId);
{
OPEN_HANDLE_FAILURE_REPORT openHandleFailure =
Helper.BytesToStructure<OPEN_HANDLE_FAILURE_REPORT>(ref _buffer, sizeof(PACKET_HEADER));
@ -97,35 +95,40 @@ namespace server
openHandleFailure.ProcessId,
openHandleFailure.ThreadId,
openHandleFailure.DesiredAccess);
}
private void HandleClientSendMessage(int clientSendId)
{
CLIENT_SEND_PACKET_HEADER header = GetClientSendPacketHeader();
_logger.Information("RequestId: {0}, PacketSize: {1}", header.RequestId, header.PacketSize);
switch (header.RequestId)
{
case (int)CLIENT_SEND_REQUEST_ID.SYSTEM_INFORMATION:
this.HandleClientSendHardwareInformation();
this.HandleClientSendHardwareInformation(header);
break;
}
}
unsafe private void HandleClientSendHardwareInformation()
unsafe private void HandleClientSendHardwareInformation(CLIENT_SEND_PACKET_HEADER sendPacketHeader)
{
_logger.Information("Handling client send hardware information");
string moboSerial = Helper.FixedUnsafeBufferToSafeString(
ref _buffer, _bufferSize, sizeof(PACKET_HEADER) + sizeof(CLIENT_SEND_PACKET_HEADER), 32);
if (moboSerial == null)
return;
string driveSerial = Helper.FixedUnsafeBufferToSafeString(
ref _buffer, _bufferSize, sizeof(PACKET_HEADER) + sizeof(CLIENT_SEND_PACKET_HEADER) + 32, 32);
_logger.Information("Mobo Serial: {0}, drive serial: {1}", moboSerial, driveSerial);
if (driveSerial == null)
return;
_logger.Information("SteamId: {0}, Mobo Serial: {1}, drive serial: {2}", _header.steam64_id, moboSerial, driveSerial);
}
}
}

View file

@ -26,11 +26,9 @@ void global::Client::ServerReceive()
void global::Client::ServerSend(PVOID Buffer, SIZE_T Size, INT RequestId )
{
mutex.lock();
global::headers::PIPE_PACKET_HEADER header;
header.message_type = MESSAGE_TYPE_CLIENT_SEND;
header.steam64_id = TEST_STEAM_64_ID;
SIZE_T total_header_size = sizeof( global::headers::CLIENT_SEND_PACKET_HEADER ) + sizeof( global::headers::PIPE_PACKET_HEADER );
SIZE_T total_header_size = sizeof( global::headers::CLIENT_SEND_PACKET_HEADER ) +
sizeof( global::headers::PIPE_PACKET_HEADER );
if ( Size + total_header_size > MAX_CLIENT_SEND_PACKET_SIZE )
{
@ -49,6 +47,10 @@ void global::Client::ServerSend(PVOID Buffer, SIZE_T Size, INT RequestId )
RtlZeroMemory( send_buffer, total_header_size + Size );
global::headers::PIPE_PACKET_HEADER header;
header.message_type = MESSAGE_TYPE_CLIENT_SEND;
header.steam64_id = TEST_STEAM_64_ID;
memcpy( send_buffer, &header, sizeof( global::headers::PIPE_PACKET_HEADER ) );
global::headers::CLIENT_SEND_PACKET_HEADER header_extension;
@ -63,6 +65,5 @@ void global::Client::ServerSend(PVOID Buffer, SIZE_T Size, INT RequestId )
this->pipe->WriteToPipe( send_buffer, header_extension.packet_size );
mutex.unlock();
free( send_buffer );
}