Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Build App

on:
push:
tags:
Expand Down Expand Up @@ -36,6 +36,7 @@ jobs:
run: msbuild LostArkLogger.sln /p:Configuration=Release

- name: Import PFX
continue-on-error: true
shell: powershell
run: |
$pfxCertFilePath = Join-Path -Path $PSScriptRoot -ChildPath "CodeSigningCertificate.pfx"
Expand All @@ -46,6 +47,7 @@ jobs:
PFX_PASSWORD: ${{ secrets.PASSWORD }}

- name: Sign exe
continue-on-error: true
shell: powershell
run: |
$codeSigningCert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
Expand All @@ -62,4 +64,4 @@ jobs:
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
bin\Release\DpsMeter.exe
bin\Release\DpsMeter.exe
Binary file added Capture.rar
Binary file not shown.
24 changes: 19 additions & 5 deletions LostArkLogger/GUI/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions LostArkLogger/GUI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,19 @@ private void autoUpload_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.AutoUpload = autoUpload.Checked;
Properties.Settings.Default.Save();
}

private void ReadPCapButton_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = "Open pcap File";
dialog.Filter = "PCAP files|*.pcap";
if (dialog.ShowDialog() == DialogResult.OK)
{
this.sniffer.fileName = dialog.FileName.ToString();
this.sniffer.use_npcap = true;
this.sniffer.InstallListener();
}
}
}
}
7 changes: 7 additions & 0 deletions LostArkLogger/LostArkLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
Expand Down
114 changes: 110 additions & 4 deletions LostArkLogger/Parser.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using K4os.Compression.LZ4;
using LostArkLogger.Utilities;
using SharpPcap;
using SharpPcap.LibPcap;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LostArkLogger
{
Expand All @@ -22,7 +25,7 @@ internal class Parser : IDisposable
public event Action onNewZone;
public event Action beforeNewZone;
public event Action<int> onPacketTotalCount;
public bool use_npcap = false;
public bool use_npcap = false;
private object lockPacketProcessing = new object(); // needed to synchronize UI swapping devices
public Machina.Infrastructure.NetworkMonitorType? monitorType = null;
public List<Encounter> Encounters = new List<Encounter>();
Expand All @@ -34,7 +37,7 @@ internal class Parser : IDisposable
public bool WasKill = false;
public bool DisplayNames = true;
public StatusEffectTracker statusEffectTracker;

public string fileName = "";
public Parser()
{
Encounters.Add(currentEncounter);
Expand All @@ -47,7 +50,7 @@ public Parser()
}

// UI needs to be able to ask us to reload our listener based on the current user settings
public void InstallListener()
/*public void InstallListener()
{
lock (lockPacketProcessing)
{
Expand Down Expand Up @@ -107,6 +110,109 @@ public void InstallListener()
}
}

if (use_npcap == false)
{
// Always fall back to rawsockets
tcp = new Machina.TCPNetworkMonitor();
tcp.Config.WindowClass = "EFLaunchUnrealUWindowsClient";
monitorType = tcp.Config.MonitorType = Machina.Infrastructure.NetworkMonitorType.RawSocket;
tcp.DataReceivedEventHandler += (Machina.Infrastructure.TCPConnection connection, byte[] data) => Device_OnPacketArrival_machina(connection, data);
tcp.Start();
}
}
}*/
public void InstallListener()
{
lock (lockPacketProcessing)
{
// If we have an installed listener, that needs to go away or we duplicate traffic
UninstallListeners();

// Reset all state related to current packet processing here that won't be valid when creating a new listener.
fragmentedPacket = new Byte[0];

// We default to using npcap and online mode, but the UI can also set this to false.
if (use_npcap)
{
monitorType = Machina.Infrastructure.NetworkMonitorType.WinPCap;
string filter = "ip and tcp port 6040";
bool foundAdapter = false;
NetworkInterface gameInterface;
if (fileName != "")
{
try
{

var device = new CaptureFileReaderDevice(fileName);
foundAdapter = true;
device.Open();
//device.Filter = filter;
// Register our handler function to the 'packet arrival' event
device.OnPacketArrival += new PacketArrivalEventHandler(Device_OnPacketArrival_pcap);
// Start capture 'INFINTE' number of packets
// This method will return when EOF reached.
device.Capture();

// Close the pcap device
device.Close();

}
catch (Exception ex)
{
var exceptionMessage = $"Exception while trying to read file {fileName} \n{ex}";
Console.WriteLine(exceptionMessage);
Logger.AppendLog(0, exceptionMessage);
}
}
else
{
// listening on every device results in duplicate traffic, unfortunately, so we'll find the adapter used by the game here
try
{
pcap_strerror(1); // verify winpcap works at all
if (Process.GetProcessesByName("LostArk").Count() > 0) Application.Exit();

gameInterface = NetworkUtil.GetAdapterUsedByProcess("LostArk");

foreach (var device in CaptureDeviceList.Instance)
{
if (device.MacAddress == null) continue; // SharpPcap.IPCapDevice.MacAddress is null in some cases
if (gameInterface.GetPhysicalAddress().ToString() == device.MacAddress.ToString())
{
try
{
device.Open(DeviceModes.None, 1000); // todo: 1sec timeout ok?
device.Filter = filter;
device.OnPacketArrival += new PacketArrivalEventHandler(Device_OnPacketArrival_pcap);
device.StartCapture();
pcap = device;
foundAdapter = true;
break;
}
catch (Exception ex)
{
var exceptionMessage = "Exception while trying to listen to NIC " + device.Name + "\n" + ex.ToString();
Console.WriteLine(exceptionMessage);
Logger.AppendLog(0, exceptionMessage);
}
}
}
}
catch (Exception ex)
{
var exceptionMessage = "Sharppcap init failed, using rawsockets instead, exception:\n" + ex.ToString();
Console.WriteLine(exceptionMessage);
Logger.AppendLog(0, exceptionMessage);
}
// If we failed to find a pcap device, fall back to rawsockets.
if (!foundAdapter)
{
use_npcap = false;
pcap = null;
}
}
}

if (use_npcap == false)
{
// Always fall back to rawsockets
Expand Down Expand Up @@ -652,7 +758,7 @@ void Device_OnPacketArrival_machina(Machina.Infrastructure.TCPConnection connect
}
void Device_OnPacketArrival_pcap(object sender, PacketCapture evt)
{
if (pcap == null) return;
if (pcap == null && fileName == "") return;
lock (lockPacketProcessing)
{
var rawpkt = evt.GetPacket();
Expand Down
2 changes: 0 additions & 2 deletions LostArkLogger/Utilities/VersionCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public static (Region, Version) GetLostArkVersion()
else if (version == SupportedKoreaVersion) return (Region.Korea, version);
else return (Region.Unknown, version);
}
return (Region.Unknown, null);
var fileName = @"C:\Program Files (x86)\Steam\steamapps\common\Lost Ark\Binaries\Win64\LOSTARK.exe";
if (!File.Exists(fileName))
{
Expand All @@ -41,7 +40,6 @@ public static (Region, Version) GetLostArkVersion()
}
if (File.Exists(fileName)) return (Region.Steam, new Version(FileVersionInfo.GetVersionInfo(fileName).ProductVersion.Split(' ')[0]));
else return (Region.Steam, new Version("0.0.0.0"));

}
}
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Lost Ark Logger
# Lost Ark Logger offline version.
This project enables you to research and analyze combat actions by parsing packets
This can be done by reading a pcap or live

# In-game Overlay
![Imgur Image](https://i.imgur.com/jjXwnOr.gif)
Expand All @@ -14,10 +15,12 @@
Please submit an issue on the github repo, or join the discord @ https://discord.gg/MedRDjEwHZ

# Setup
1. Download the "Lost Ark Logger" packet logger @ https://github.com/shalzuth/LostArkLogger/releases/latest/download/DpsMeter.exe
1. Download the "Lost Ark Logger" packet logger @ https://github.com/shalzuth/LostArkLogger/releases/latest/download/DpsMeter.exe
2. To record the pcap for offline mode download @ https://github.com/Xairooo/LostArkLogger/blob/main/Capture.rar
and extract Capture.rar

# Guide
1. Before entering a dungeon, launch "Lost Ark Logger".
1. Before entering a dungeon, launch "Lost Ark Logger" or launch "Capture\startCapture.bat" to capture a pcap file and parse it later.
2. While in the dungeon, "Lost Ark Logger" will log packets - there's a packet log counter, ensure that it is increasing. The log file will be in the same location as "Lost Ark Logger". If the overlay shows weird names that are 8 characters long, you didn't open LostArkLogger.exe before a load screen.

# Todo
Expand Down