Skip to content

Commit e382b6b

Browse files
committed
Incremented version # to 2.1.1
Updated trace logging to include a category Minor fix to WinPCap to prevent null reference exception under rare conditions Updated FFXIV Message Type IDs to patch 4.4
1 parent 2f744d9 commit e382b6b

File tree

11 files changed

+48
-49
lines changed

11 files changed

+48
-49
lines changed

Machina.FFXIV/FFXIVBundleDecoder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public unsafe void StoreData(byte[] buffer)
7575
header.magic2 != 0 && header.magic3 != 0)
7676
{
7777
if (LastMessageTimestamp != DateTime.MinValue)
78-
Trace.WriteLine("FFXIVBundleDecoder: Invalid magic # in header:" + Utility.ByteArrayToHexString(_bundleBuffer, offset, 36));
78+
Trace.WriteLine("FFXIVBundleDecoder: Invalid magic # in header:" + Utility.ByteArrayToHexString(_bundleBuffer, offset, 36), "DEBUG-MACHINA");
7979

8080
offset = ResetStream(offset);
8181
continue;
@@ -121,7 +121,7 @@ public unsafe void StoreData(byte[] buffer)
121121
if (message_offset > messageBufferSize)
122122
{
123123
Trace.WriteLine("FFXIVBundleDecoder: Bad message offset - offset=" + message_offset.ToString() + ", bufferSize=" + messageBufferSize.ToString() +
124-
", data: " + Utility.ByteArrayToHexString(data, 0, 50));
124+
", data: " + Utility.ByteArrayToHexString(data, 0, 50), "DEBUG-MACHINA");
125125

126126
_allocated = 0;
127127
return;
@@ -165,7 +165,7 @@ private unsafe byte[] DecompressFFXIVMessage(ref FFXIVBundleHeader header, byte[
165165
if (header.encoding != 0x0101 && header.encoding != 0x0100)
166166
{
167167
if (!_encodingError)
168-
Trace.WriteLine("FFXIVBundleDecoder: unknown encoding type: " + header.encoding.ToString("X4"));
168+
Trace.WriteLine("FFXIVBundleDecoder: unknown encoding type: " + header.encoding.ToString("X4"), "DEBUG-MACHINA");
169169
_encodingError = true;
170170
return null;
171171
}
@@ -183,7 +183,7 @@ private unsafe byte[] DecompressFFXIVMessage(ref FFXIVBundleHeader header, byte[
183183
}
184184
catch (Exception ex)
185185
{
186-
Trace.WriteLine("FFXIVBundleDecoder: Decompression error: " + ex.ToString());
186+
Trace.WriteLine("FFXIVBundleDecoder: Decompression error: " + ex.ToString(), "DEBUG-MACHINA");
187187
return null;
188188
}
189189

Machina.FFXIV/Headers/FFXIMessageHeader.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,18 @@ namespace Machina.FFXIV
2424
/// </summary>
2525
public enum ServerMessageType : ushort
2626
{
27-
StatusEffectList = 0x0125,
28-
Ability1 = 0x0128,
29-
Ability8 = 0x012b,
30-
Ability16 = 0x0138,
31-
Ability24 = 0x0139,
32-
Ability32 = 0x013a,
33-
ActorCast = 0x0162,
27+
StatusEffectList = 0x0149,
28+
Ability1 = 0x014c,
29+
Ability8 = 0x014f,
30+
Ability16 = 0x0150,
31+
Ability24 = 0x0151,
32+
Ability32 = 0x0152,
33+
ActorCast = 0x0174,
3434
AddStatusEffect = 0x0141,
3535
ActorControl142 = 0x0142,
3636
ActorControl143 = 0x0143,
3737
ActorControl144 = 0x0144,
38-
//ActorSpawn = 0x0190,
39-
ActorGauge = 0x027d
38+
ActorGauge = 0x0292
4039
}
4140

4241
[StructLayout(LayoutKind.Explicit)]

Machina.FFXIV/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
1212
[assembly: AssemblyProduct("Machina.FFXIV")]
13-
[assembly: AssemblyCopyright("Copyright © 2018 Ravahn")]
13+
[assembly: AssemblyCopyright("Copyright © 2019 Ravahn")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.1.0.0")]
36-
[assembly: AssemblyFileVersion("2.1.0.0")]
35+
[assembly: AssemblyVersion("2.1.1.0")]
36+
[assembly: AssemblyFileVersion("2.1.1.0")]

Machina/FirewallManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void AddFirewallApplicationEntry(string appName, string ExecutablePath)
129129
}
130130
catch (Exception ex)
131131
{
132-
Trace.WriteLine("FirewallWrapper: Exception " + ex.ToString());
132+
Trace.WriteLine("FirewallWrapper: Exception " + ex.ToString(), "FIREWALL");
133133
}
134134
}
135135
}

Machina/IPDecoder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public unsafe void FilterAndStoreData(byte[] buffer, int size)
8686

8787
if (buffer.Length < size)
8888
{
89-
Trace.WriteLine("IPDecoder: Buffer length is less than specified size. Size=[" + size.ToString() + "], Length=[" + buffer.Length + "]");
89+
Trace.WriteLine("IPDecoder: Buffer length is less than specified size. Size=[" + size.ToString() + "], Length=[" + buffer.Length + "]", "DEBUG-MACHINA");
9090
return;
9191
}
9292

@@ -101,7 +101,7 @@ public unsafe void FilterAndStoreData(byte[] buffer, int size)
101101
// TODO: IP6 packets, and mixed IP4/IP6, need to be tested with real-world data.
102102
if (offset + sizeof(IPv6Header) > size)
103103
{
104-
Trace.WriteLine("IPDecoder: IP6 Packet too small for header. offset: " + offset.ToString() + ", size: " + size.ToString());
104+
Trace.WriteLine("IPDecoder: IP6 Packet too small for header. offset: " + offset.ToString() + ", size: " + size.ToString(), "DEBUG-MACHINA");
105105
return;
106106
}
107107

@@ -111,7 +111,7 @@ public unsafe void FilterAndStoreData(byte[] buffer, int size)
111111
if (header6.PayloadLength * 8 > buffer.Length - offset - sizeof(IPv6Header))
112112
{
113113
Trace.WriteLine("IPDecoder: IP6 Packet too small for payload. payload length: " +
114-
(header6.payload_length * 8).ToString() + ", Buffer: " + buffer.Length.ToString() + ", offset: " + offset.ToString());
114+
(header6.payload_length * 8).ToString() + ", Buffer: " + buffer.Length.ToString() + ", offset: " + offset.ToString(), "DEBUG-MACHINA");
115115
return;
116116
}
117117

@@ -121,7 +121,7 @@ public unsafe void FilterAndStoreData(byte[] buffer, int size)
121121
}
122122
else if (version != 4)
123123
{
124-
Trace.WriteLine("IPDecoder: IP protocol version is neither 4 nor 6. Version is " + version.ToString());
124+
Trace.WriteLine("IPDecoder: IP protocol version is neither 4 nor 6. Version is " + version.ToString(), "DEBUG-MACHINA");
125125
return;
126126
}
127127

@@ -136,12 +136,12 @@ public unsafe void FilterAndStoreData(byte[] buffer, int size)
136136
// make sure we have a valid exit condition
137137
if (packetLength <= 0 & packetLength > 65535)
138138
{
139-
Trace.WriteLine("IPDecoder: Invalid packet length [" + packetLength.ToString() + "].");
139+
Trace.WriteLine("IPDecoder: Invalid packet length [" + packetLength.ToString() + "].", "DEBUG-MACHINA");
140140
return;
141141
}
142142
if (packetLength > buffer.Length - offset)
143143
{
144-
Trace.WriteLine("IPDecoder: buffer too small to hold complete packet. Packet length is [" + packetLength.ToString() + "], remaining buffer is [" + (buffer.Length - offset).ToString() + "].");
144+
Trace.WriteLine("IPDecoder: buffer too small to hold complete packet. Packet length is [" + packetLength.ToString() + "], remaining buffer is [" + (buffer.Length - offset).ToString() + "].", "DEBUG-MACHINA");
145145
return;
146146
}
147147

Machina/ProcessTCPInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public unsafe void UpdateTCPIPConnections(List<TCPConnection> connections)
115115
{
116116
if (connections.Count > 0)
117117
{
118-
Trace.WriteLine("ProcessTCPInfo: Process has exited, closing all connections.");
118+
Trace.WriteLine("ProcessTCPInfo: Process has exited, closing all connections.", "DEBUG-MACHINA");
119119

120120
connections.Clear();
121121
}
@@ -185,7 +185,7 @@ public unsafe void UpdateTCPIPConnections(List<TCPConnection> connections)
185185

186186
connections.Add(connection);
187187

188-
Trace.WriteLine("ProcessTCPInfo: New connection detected for Process [" + _currentProcessID.ToString() + "]: " + connection.ToString());
188+
Trace.WriteLine("ProcessTCPInfo: New connection detected for Process [" + _currentProcessID.ToString() + "]: " + connection.ToString(), "DEBUG-MACHINA");
189189
}
190190
}
191191

@@ -220,20 +220,20 @@ public unsafe void UpdateTCPIPConnections(List<TCPConnection> connections)
220220
}
221221
if (!bFound)
222222
{
223-
Trace.WriteLine("ProcessTCPInfo: Removed connection " + connections[i].ToString());
223+
Trace.WriteLine("ProcessTCPInfo: Removed connection " + connections[i].ToString(), "DEBUG-MACHINA");
224224
connections.RemoveAt(i);
225225
}
226226
}
227227
}
228228
else
229229
{
230-
Trace.WriteLine("ProcessTCPInfo: Unable to retrieve TCP table. Return code: " + ret.ToString());
230+
Trace.WriteLine("ProcessTCPInfo: Unable to retrieve TCP table. Return code: " + ret.ToString(), "DEBUG-MACHINA");
231231
throw new System.ComponentModel.Win32Exception(ret);
232232
}
233233
}
234234
catch (Exception ex)
235235
{
236-
Trace.WriteLine("ProcessTCPInfo: Exception updating TCP connection list." + ex.ToString());
236+
Trace.WriteLine("ProcessTCPInfo: Exception updating TCP connection list." + ex.ToString(), "DEBUG-MACHINA");
237237
throw new System.ComponentModel.Win32Exception(ret, ex.Message);
238238
}
239239
finally

Machina/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
[assembly: AssemblyConfiguration("")]
2828
[assembly: AssemblyCompany("")]
2929
[assembly: AssemblyProduct("Machina")]
30-
[assembly: AssemblyCopyright("Copyright © 2018 Ravahn")]
30+
[assembly: AssemblyCopyright("Copyright © 2019 Ravahn")]
3131
[assembly: AssemblyTrademark("")]
3232
[assembly: AssemblyCulture("")]
3333

@@ -51,7 +51,7 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("2.1.0.0")]
54+
[assembly: AssemblyVersion("2.1.1.0")]
5555
[assembly: AssemblyInformationalVersion("1.0.0.0")]
56-
[assembly: AssemblyFileVersion("2.1.0.0")]
56+
[assembly: AssemblyFileVersion("2.1.1.0")]
5757

Machina/RawPCap.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ public void Create(uint localAddress, uint remoteAddress = 0)
222222
Device device = GetAllDevices().FirstOrDefault(x =>
223223
x.Addresses.Contains(localAddress));
224224

225-
if (!string.IsNullOrWhiteSpace(device.Name))
225+
if (!string.IsNullOrWhiteSpace(device?.Name))
226226
StartCapture(device, remoteAddress);
227227
else
228-
Trace.WriteLine("RawPCap: IP [" + new System.Net.IPAddress(localAddress).ToString() + " selected but unable to find corresponding WinPCap device.");
228+
Trace.WriteLine("RawPCap: IP [" + new System.Net.IPAddress(localAddress).ToString() + " selected but unable to find corresponding WinPCap device.", "DEBUG-MACHINA");
229229

230230
}
231231

@@ -264,7 +264,7 @@ public void Destroy()
264264
}
265265
catch (Exception ex)
266266
{
267-
Trace.WriteLine("RawPCap: Exception cleaning up RawPCap class. " + ex.ToString());
267+
Trace.WriteLine("RawPCap: Exception cleaning up RawPCap class. " + ex.ToString(), "DEBUG-MACHINA");
268268
}
269269
}
270270

@@ -433,7 +433,7 @@ private unsafe void RunCaptureLoop()
433433
{
434434
string error = Marshal.PtrToStringAnsi(pcap_geterr(_activeDevice.Handle));
435435
if (!bExceptionLogged)
436-
Trace.WriteLine("RawPCap: Error during pcap_loop. " + error);
436+
Trace.WriteLine("RawPCap: Error during pcap_loop. " + error, "DEBUG-MACHINA");
437437

438438
bExceptionLogged = true;
439439

@@ -442,7 +442,7 @@ private unsafe void RunCaptureLoop()
442442
else if (status != 1) // anything else besides success
443443
{
444444
if (!bExceptionLogged)
445-
Trace.WriteLine("RawPCap: Unknown response code [" + status.ToString() + "] from pcap_next_ex.);");
445+
Trace.WriteLine("RawPCap: Unknown response code [" + status.ToString() + "] from pcap_next_ex.", "DEBUG-MACHINA");
446446

447447
bExceptionLogged = true;
448448

@@ -459,7 +459,7 @@ private unsafe void RunCaptureLoop()
459459
// prepare data - skip the 14-byte ethernet header
460460
buffer.AllocatedSize = (int)packetHeader.caplen - layer2Length;
461461
if (buffer.AllocatedSize > buffer.Data.Length)
462-
Trace.WriteLine("RawPCap: packet length too large: " + buffer.AllocatedSize.ToString());
462+
Trace.WriteLine("RawPCap: packet length too large: " + buffer.AllocatedSize.ToString(), "DEBUG-MACHINA");
463463
else
464464
{
465465

@@ -477,7 +477,7 @@ private unsafe void RunCaptureLoop()
477477
catch (Exception ex)
478478
{
479479
if (!bExceptionLogged)
480-
Trace.WriteLine("WinPCap: Exception during RunCaptureLoop. " + ex.ToString());
480+
Trace.WriteLine("WinPCap: Exception during RunCaptureLoop. " + ex.ToString(), "DEBUG-MACHINA");
481481

482482
bExceptionLogged = true;
483483

Machina/RawSocket.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private static void OnReceive(IAsyncResult ar)
143143
}
144144
catch (Exception ex)
145145
{
146-
Trace.WriteLine("RawSocket: Error while receiving socket data. Network capture aborted, please restart application." + ex.ToString());
146+
Trace.WriteLine("RawSocket: Error while receiving socket data. Network capture aborted, please restart application." + ex.ToString(), "DEBUG-MACHINA");
147147
}
148148
}
149149
}

Machina/TCPDecoder.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public unsafe void FilterAndStoreData(byte[] buffer)
7272
// There is one TCP packet per buffer.
7373
if (buffer?.Length < sizeof(TCPHeader))
7474
{
75-
Trace.WriteLine("TCPDecoder: Buffer length smaller than TCP header: Length=[" + (buffer?.Length ?? 0).ToString() + "].");
75+
Trace.WriteLine("TCPDecoder: Buffer length smaller than TCP header: Length=[" + (buffer?.Length ?? 0).ToString() + "].", "DEBUG-MACHINA");
7676
return;
7777
}
7878

@@ -137,11 +137,11 @@ public unsafe byte[] GetNextTCPDatagram()
137137
_NextSequence = header.SequenceNumber + 1;
138138
else if (Math.Abs(_NextSequence - header.SequenceNumber) > 100000)
139139
{
140-
Trace.WriteLine("TCPDecoder: Updating sequence number from SYN packet. Current Sequence: [" + _NextSequence.ToString() + ", sent sequence: [" + header.SequenceNumber.ToString() + "].");
140+
Trace.WriteLine("TCPDecoder: Updating sequence number from SYN packet. Current Sequence: [" + _NextSequence.ToString() + ", sent sequence: [" + header.SequenceNumber.ToString() + "].", "DEBUG-MACHINA");
141141
_NextSequence = header.SequenceNumber + 1;
142142
}
143143
else
144-
Trace.WriteLine("TCPDecoder: Ignoring SYN packet new sequence number. Current Sequence: [" + _NextSequence.ToString() + ", sent sequence: [" + header.SequenceNumber.ToString() + "].");
144+
Trace.WriteLine("TCPDecoder: Ignoring SYN packet new sequence number. Current Sequence: [" + _NextSequence.ToString() + ", sent sequence: [" + header.SequenceNumber.ToString() + "].", "DEBUG-MACHINA");
145145

146146
continue; // do not process SYN packet, but set next sequence #.
147147
}
@@ -155,7 +155,7 @@ public unsafe byte[] GetNextTCPDatagram()
155155
if (packetOffset >= packet.Length - header.DataOffset)
156156
{
157157
// this packet will get removed once we exit the loop.
158-
Trace.WriteLine("TCPDecoder: packet data already processed, expected sequence [" + _NextSequence.ToString() + "], received [" + header.SequenceNumber + "], size [" + (packet.Length - header.DataOffset) + "]. Data: " + Utility.ByteArrayToHexString(packet, 0, 50));
158+
Trace.WriteLine("TCPDecoder: packet data already processed, expected sequence [" + _NextSequence.ToString() + "], received [" + header.SequenceNumber + "], size [" + (packet.Length - header.DataOffset) + "]. Data: " + Utility.ByteArrayToHexString(packet, 0, 50), "DEBUG-MACHINA");
159159
continue;
160160
}
161161

@@ -195,13 +195,13 @@ public unsafe byte[] GetNextTCPDatagram()
195195
{
196196
if (LastPacketTimestamp.AddMilliseconds(2000) < DateTime.UtcNow)
197197
{
198-
Trace.WriteLine("TCPDecoder: >2 sec since last processed packet, resetting stream.");
198+
Trace.WriteLine("TCPDecoder: >2 sec since last processed packet, resetting stream.", "DEBUG-MACHINA");
199199

200200
for (int i = Packets.Count - 1; i >= 0; i--)
201201
{
202202
// todo: need to explore this logic, can we recover and get next highest sequence?
203203
Trace.WriteLine("TCPDecoder: Missing Sequence # [" + _NextSequence.ToString() + "], Dropping packet with sequence # [" +
204-
Utility.ntohl(BitConverter.ToUInt32(Packets[i], 4)).ToString() + "].");
204+
Utility.ntohl(BitConverter.ToUInt32(Packets[i], 4)).ToString() + "].", "DEBUG-MACHINA");
205205
Packets.RemoveAt(i);
206206
}
207207
_NextSequence = 0;

0 commit comments

Comments
 (0)