Skip to content

Commit

Permalink
3.0.5590.24659
Browse files Browse the repository at this point in the history
  • Loading branch information
Icehunter committed Apr 22, 2015
1 parent c23283c commit b7fd315
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 98 deletions.
19 changes: 15 additions & 4 deletions FFXIVAPP.Client/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,28 @@ private static void CheckSettings()
/// </summary>
private static void ConfigureNLog()
{
if (File.Exists("./FFXIVAPP.Client.exe.nlog"))
var hasLocal = false;
const string fileName = "./FFXIVAPP.Client.exe.nlog";
if (File.Exists(fileName))
{
return;
hasLocal = true;
}
var resource = ResourceHelper.StreamResource(Common.Constants.AppPack + "Resources/FFXIVAPP.Client.exe.nlog");
if (resource == null)
{
return;
}
var stringReader = new StringReader(XElement.Load(resource.Stream)
.ToString());
StringReader stringReader;
if (hasLocal)
{
stringReader = new StringReader(XElement.Load(fileName)
.ToString());
}
else
{
stringReader = new StringReader(XElement.Load(resource.Stream)
.ToString());
}
using (var xmlReader = XmlReader.Create(stringReader))
{
LogManager.Configuration = new XmlLoggingConfiguration(xmlReader, null);
Expand Down
191 changes: 97 additions & 94 deletions FFXIVAPP.Client/Network/NetworkWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,117 +336,120 @@ private void ParseData(SocketObject asyncState, byte[] byteData, int nReceived)

private void ProcessNetworkBuffer(NetworkConnection connection)
{
int messageLength;
InitialProcess:
if (connection.NetworkBufferPosition < 0x1C)
while (true)
{
return;
}
uint bufferSize;
byte[] destinationArray;
lock (connection.NetworkBufferLock)
{
var indexes = new List<uint>
{
BitConverter.ToUInt32(connection.NetworkBuffer, 0),
BitConverter.ToUInt32(connection.NetworkBuffer, 4),
BitConverter.ToUInt32(connection.NetworkBuffer, 8),
BitConverter.ToUInt32(connection.NetworkBuffer, 12)
};
if ((indexes[0] != 0x41A05252) && ((indexes.Any(x => x != 0))))
{
AdjustNetworkBuffer(connection);
return;
}
bufferSize = BitConverter.ToUInt32(connection.NetworkBuffer, 0x18);
if ((bufferSize == 0) || (bufferSize > 0x10000))
if (connection.NetworkBufferPosition < 0x1C)
{
AdjustNetworkBuffer(connection);
return;
break;
}
if (connection.NetworkBufferPosition < bufferSize)
uint bufferSize;
byte[] destinationArray;
lock (connection.NetworkBufferLock)
{
if (DateTime.Now.Subtract(connection.LastNetworkBufferUpdate)
.Seconds <= 5)
var indexes = new List<uint>
{
BitConverter.ToUInt32(connection.NetworkBuffer, 0),
BitConverter.ToUInt32(connection.NetworkBuffer, 4),
BitConverter.ToUInt32(connection.NetworkBuffer, 8),
BitConverter.ToUInt32(connection.NetworkBuffer, 12)
};
if ((indexes[0] != 0x41A05252) && ((indexes.Any(x => x != 0))))
{
AdjustNetworkBuffer(connection);
return;
}
AdjustNetworkBuffer(connection);
return;
}
destinationArray = new byte[bufferSize];
Array.Copy(connection.NetworkBuffer, destinationArray, bufferSize);
Array.Copy(connection.NetworkBuffer, bufferSize, connection.NetworkBuffer, 0L, connection.NetworkBufferPosition - bufferSize);
connection.NetworkBufferPosition -= (int) bufferSize;
connection.LastNetworkBufferUpdate = DateTime.Now;
}
if (bufferSize <= 40)
{
return;
}
var timeDifference = BitConverter.ToUInt64(destinationArray, 0x10);
var time = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(timeDifference)
.ToLocalTime();
int limiter = BitConverter.ToInt16(destinationArray, 30);
int code = BitConverter.ToInt16(destinationArray, 0x20);
var bytes = new byte[0x10000];
switch (code)
{
case 0:
case 1:
messageLength = ((int) bufferSize) - 40;
for (var i = 0; i < ((bufferSize / 4) - 10); i++)
bufferSize = BitConverter.ToUInt32(connection.NetworkBuffer, 0x18);
if ((bufferSize == 0) || (bufferSize > 0x10000))
{
Array.Copy(BitConverter.GetBytes(BitConverter.ToUInt32(destinationArray, (i * 4) + 40)), 0, bytes, i * 4, 4);
AdjustNetworkBuffer(connection);
return;
}
goto SubProcess;
}
try
{
using (var destinationStream = new MemoryStream(destinationArray, 0x2A, destinationArray.Length - 0x2A))
{
using (var decompressedStream = new DeflateStream(destinationStream, CompressionMode.Decompress))
if (connection.NetworkBufferPosition < bufferSize)
{
messageLength = decompressedStream.Read(bytes, 0, bytes.Length);
if (DateTime.Now.Subtract(connection.LastNetworkBufferUpdate)
.Seconds > 5)
{
AdjustNetworkBuffer(connection);
}
break;
}
destinationArray = new byte[bufferSize];
Array.Copy(connection.NetworkBuffer, destinationArray, bufferSize);
Array.Copy(connection.NetworkBuffer, bufferSize, connection.NetworkBuffer, 0L, connection.NetworkBufferPosition - bufferSize);
connection.NetworkBufferPosition -= (int) bufferSize;
connection.LastNetworkBufferUpdate = DateTime.Now;
}
}
catch (Exception ex)
{
return;
}
SubProcess:
var position = 0;
try
{
for (var i = 0; i < limiter; i++)
if (bufferSize <= 40)
{
if ((position + 4) > messageLength)
{
return;
}
var messageSize = BitConverter.ToUInt32(bytes, position);
if ((position + messageSize) > messageLength)
{
return;
}
if (messageSize > 0x18)
return;
}
var timeDifference = BitConverter.ToUInt64(destinationArray, 0x10);
var time = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(timeDifference)
.ToLocalTime();
int limiter = BitConverter.ToInt16(destinationArray, 30);
int encoding = BitConverter.ToInt16(destinationArray, 0x20);
var bytes = new byte[0x10000];
int messageLength;
switch (encoding)
{
case 0:
case 1:
messageLength = ((int)bufferSize) - 40;
for (var i = 0; i < ((bufferSize / 4) - 10); i++)
{
Array.Copy(BitConverter.GetBytes(BitConverter.ToUInt32(destinationArray, (i * 4) + 40)), 0, bytes, i * 4, 4);
}
break;
default:
try
{
using (var destinationStream = new MemoryStream(destinationArray, 0x2A, destinationArray.Length - 0x2A))
{
using (var decompressedStream = new DeflateStream(destinationStream, CompressionMode.Decompress))
{
messageLength = decompressedStream.Read(bytes, 0, bytes.Length);
}
}
}
catch (Exception ex)
{
return;
}
break;
}
var position = 0;
try
{
for (var i = 0; i < limiter; i++)
{
AppContextHelper.Instance.RaiseNewPacket(new Common.Core.Network.NetworkPacket
if ((position + 4) > messageLength)
{
return;
}
var messageSize = BitConverter.ToUInt32(bytes, position);
if ((position + messageSize) > messageLength)
{
return;
}
if (messageSize > 0x18)
{
Key = BitConverter.ToUInt32(bytes, position + 0x10),
Buffer = bytes,
CurrentPosition = position,
MessageSize = (int) messageSize,
PacketDate = time
});
var networkPacket = new Common.Core.Network.NetworkPacket
{
Key = BitConverter.ToUInt32(bytes, position + 0x10),
Buffer = bytes,
CurrentPosition = position,
MessageSize = (int) messageSize,
PacketDate = time
};
AppContextHelper.Instance.RaiseNewPacket(networkPacket);
}
position += (int)messageSize;
}
position += (int) messageSize;
}
goto InitialProcess;
}
catch (Exception ex)
{
catch (Exception ex)
{
return;
}
}
}

Expand Down
Binary file modified distribution/FFXIVAPP.Client.exe
Binary file not shown.

0 comments on commit b7fd315

Please sign in to comment.