Implemented item packets, did some fixes with one of the conns going null.

This commit is contained in:
Filip Maj 2015-10-04 22:43:22 -04:00
parent 3cacedf6ab
commit 8f7e7d4c0d
8 changed files with 353 additions and 28 deletions

View file

@ -28,6 +28,7 @@ namespace FFXIVClassic_Lobby_Server.packets
public BasePacketHeader header;
public byte[] data;
//Loads a sniffed packet from a file
public unsafe BasePacket(String path)
{
byte[] bytes = File.ReadAllBytes(path);
@ -49,6 +50,7 @@ namespace FFXIVClassic_Lobby_Server.packets
Array.Copy(bytes, BASEPACKET_SIZE, data, 0, packetSize - BASEPACKET_SIZE);
}
//Loads a sniffed packet from a byte array
public unsafe BasePacket(byte[] bytes)
{
if (bytes.Length < BASEPACKET_SIZE)
@ -141,6 +143,29 @@ namespace FFXIVClassic_Lobby_Server.packets
return outBytes;
}
//Replaces all instances of the sniffed actorID with the given one
public void replaceActorID(uint actorID)
{
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
using (BinaryReader binreader = new BinaryReader(mem))
{
while (binreader.BaseStream.Position + 4 < data.Length)
{
uint read = binreader.ReadUInt32();
if (read == 0x029B2941) //Original ID
{
binWriter.BaseStream.Seek(binreader.BaseStream.Position - 0x4, SeekOrigin.Begin);
binWriter.Write(actorID);
}
}
}
}
}
}
#region Utility Functions
public static BasePacket createPacket(List<SubPacket> subpackets, bool isAuthed, bool isEncrypted)
{