mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-06 14:40:28 -04:00
Removed NioTSO client and server
- NioTSO client isn't needed because we're using RayLib - Added FreeSO's API server to handle most backend operations
This commit is contained in:
parent
f12ba1502b
commit
22191ce648
591 changed files with 53264 additions and 3362 deletions
66
server/FSO.Server.Debug/PacketAnalyzer/PascalStringPacketAnalyzer.cs
Executable file
66
server/FSO.Server.Debug/PacketAnalyzer/PascalStringPacketAnalyzer.cs
Executable file
|
@ -0,0 +1,66 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace FSO.Server.Debug.PacketAnalyzer
|
||||
{
|
||||
public class PascalStringPacketAnalyzer : IPacketAnalyzer
|
||||
{
|
||||
#region IPacketAnalyzer Members
|
||||
|
||||
public List<PacketAnalyzerResult> Analyze(byte[] data)
|
||||
{
|
||||
var result = new List<PacketAnalyzerResult>();
|
||||
|
||||
/**
|
||||
* We are looking for a uint32 with the msb flipped for length followed by that many chars within a reasonable ascii range
|
||||
*/
|
||||
for (var i = 0; i < data.Length; i++)
|
||||
{
|
||||
var stringValue = GetString(data, i);
|
||||
if (stringValue != null)
|
||||
{
|
||||
result.Add(new PacketAnalyzerResult {
|
||||
Offset = i,
|
||||
Length = stringValue.Length + 4,
|
||||
Description = "pascal-string(" + stringValue + ")"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string GetString(byte[] data, int index)
|
||||
{
|
||||
if (index + 4 <= data.Length)
|
||||
{
|
||||
byte len1 = data[index];
|
||||
byte len2 = data[index + 1];
|
||||
byte len3 = data[index + 2];
|
||||
byte len4 = data[index + 3];
|
||||
|
||||
//Is msb set?
|
||||
if ((len1 >> 7) != 1) { return null; }
|
||||
len1 &= 0x7F;
|
||||
|
||||
long len = len1 << 24 | len2 << 16 | len3 << 8 | len4;
|
||||
if (len < 0) { return null; }
|
||||
|
||||
if (index + 4 + len <= data.Length)
|
||||
{
|
||||
/** Could be! **/
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
byte charValue = data[index + 4 + i];
|
||||
str.Append((char)charValue);
|
||||
}
|
||||
return str.ToString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue