static void Main(string[] args) { FFProcess process = new FFProcess(FFProcess.DX11_DEFAULT_NAME, true); DiscordPresence presence = new DiscordPresence(DISCORD_CLIENT_ID); bool shutdown = false; new Thread(x => { while (!shutdown) { if (Console.ReadKey(true).Key == ConsoleKey.Escape) { shutdown = true; Console.WriteLine("Stopping application..."); } } }).Start(); Console.WriteLine("Press ESC to stop"); do { while (Scanner.Instance.IsScanning) { Thread.Sleep(1000); Console.WriteLine("Scanning..."); } CurrentPlayer currentPlayer = Reader.GetCurrentPlayer().CurrentPlayer; ActorItem player = null /*ActorItem.CurrentUser*/; if (player == null) { ActorResult aResult = Reader.GetActors(); KeyValuePair <uint, ActorItem> playerKeyValue = aResult.CurrentPCs.ToList().Find(x => x.Value.Name == currentPlayer.Name); ActorItem playerItem = playerKeyValue.Value; player = playerItem; } if (player != null) { presence.playerName = player.Name; presence.lvl = player.Level.ToString(); presence.job = player.Job.ToString(); uint mapID = player.MapTerritory; MapItem zone = ZoneLookup.GetZoneInfo(mapID); presence.place = zone.Name.English; presence.UpdatePresence(); } Thread.Sleep(5000); } while (!shutdown); presence.Deinitialize(); }
static void Main(string[] args) { var stringReader = new StringReader(XElement.Load("./Bootstrapper.exe.nlog").ToString()); using (XmlReader xmlReader = XmlReader.Create(stringReader)) { LogManager.Configuration = new XmlLoggingConfiguration(xmlReader, null); } ActionLookup.GetActionInfo(2); StatusEffectLookup.GetStatusInfo(2); ZoneLookup.GetZoneInfo(138); ActionItem action = ActionLookup.GetActionInfo(2); StatusItem status = StatusEffectLookup.GetStatusInfo(2); MapItem zone = ZoneLookup.GetZoneInfo(138); Process process = Process.GetProcessesByName("ffxiv_dx11").FirstOrDefault(); if (process != null) { MemoryHandler.Instance.SetProcess( new ProcessModel { IsWin64 = true, Process = process, }); while (Scanner.Instance.IsScanning) { Thread.Sleep(1000); Console.WriteLine("Scanning..."); } MemoryHandler.Instance.SignaturesFoundEvent += delegate(object sender, SignaturesFoundEvent e) { foreach (KeyValuePair <string, Signature> kvp in e.Signatures) { Console.WriteLine($"{kvp.Key} => {kvp.Value.GetAddress():X}"); } }; } Console.WriteLine("To exit this application press \"Enter\"."); Console.ReadLine(); }
public void SetProcess(ProcessModel processModel, string gameLanguage = "English", string patchVersion = "latest", bool useLocalCache = true, bool scanAllMemoryRegions = false) { this.ProcessModel = processModel; this.GameLanguage = gameLanguage; this.UseLocalCache = useLocalCache; this.UnsetProcess(); try { this.ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)this.ProcessModel.ProcessID); } catch (Exception) { this.ProcessHandle = processModel.Process.Handle; } finally { Constants.ProcessHandle = this.ProcessHandle; this.IsAttached = true; } if (this.IsNewInstance) { this.IsNewInstance = false; ActionLookup.Resolve(); StatusEffectLookup.Resolve(); ZoneLookup.Resolve(); this.ResolveMemoryStructures(processModel, patchVersion); } this.AttachmentWorker = new AttachmentWorker(); this.AttachmentWorker.StartScanning(processModel); this.SystemModules.Clear(); this.GetProcessModules(); Scanner.Instance.Locations.Clear(); Scanner.Instance.LoadOffsets(Signatures.Resolve(processModel, patchVersion), scanAllMemoryRegions); }
public MemoryHandler(SharlayanConfiguration configuration) { this.Configuration = configuration; try { this.ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)this.Configuration.ProcessModel.ProcessID); } catch (Exception) { this.ProcessHandle = this.Configuration.ProcessModel.Process.Handle; } finally { this.IsAttached = true; } this.Configuration.ProcessModel.Process.EnableRaisingEvents = true; this.Configuration.ProcessModel.Process.Exited += this.Process_OnExited; this.GetProcessModules(); this.Scanner = new Scanner(this); this.Reader = new Reader(this); if (this._isNewInstance) { this._isNewInstance = false; Task.Run( async() => { await this.ResolveMemoryStructures(); await ActionLookup.Resolve(this.Configuration); await StatusEffectLookup.Resolve(this.Configuration); await ZoneLookup.Resolve(this.Configuration); }); } Task.Run( async() => { Signature[] signatures = await Signatures.Resolve(this.Configuration); this.Scanner.LoadOffsets(signatures, this.Configuration.ScanAllRegions); }); }
private void InitializeHistory() { var hasDamage = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallDamage") > 0; var hasHealing = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallHealing") > 0; var hasDamageTaken = this.ParseControl.Timeline.Overall.Stats.GetStatValue("TotalOverallDamageTaken") > 0; if (hasDamage || hasHealing || hasDamageTaken) { StatContainer currentOverallStats = this.ParseControl.Timeline.Overall.Stats; var historyItem = new ParseHistoryItem(); HistoryControl historyController = historyItem.HistoryControl = new HistoryControl(); foreach (Stat <double> stat in currentOverallStats) { historyController.Timeline.Overall.Stats.EnsureStatValue(stat.Name, stat.Value); } historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDPS", currentOverallStats.GetStatValue("DPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDOTPS", currentOverallStats.GetStatValue("DOTPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHPS", currentOverallStats.GetStatValue("HPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHOHPS", currentOverallStats.GetStatValue("HOHPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHOTPS", currentOverallStats.GetStatValue("HOTPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerHMPS", currentOverallStats.GetStatValue("HMPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDTPS", currentOverallStats.GetStatValue("DTPS")); historyController.Timeline.Overall.Stats.EnsureStatValue("StaticPlayerDTOTPS", currentOverallStats.GetStatValue("DTOTPS")); StatGroup[] playerList = this.ParseControl.Timeline.Party.ToArray(); foreach (StatGroup player in playerList) { HistoryGroup playerInstance = historyController.Timeline.GetSetPlayer(player.Name); playerInstance.Last20DamageActions = ((Player)player).Last20DamageActions.ToList(); playerInstance.Last20DamageTakenActions = ((Player)player).Last20DamageTakenActions.ToList(); playerInstance.Last20HealingActions = ((Player)player).Last20HealingActions.ToList(); playerInstance.Last20Items = ((Player)player).Last20Items.ToList(); foreach (Stat <double> stat in player.Stats) { playerInstance.Stats.EnsureStatValue(stat.Name, stat.Value); } this.RabbitHoleCopy(ref playerInstance, player); } StatGroup[] monsterList = this.ParseControl.Timeline.Monster.ToArray(); foreach (StatGroup monster in monsterList) { HistoryGroup monsterInstance = historyController.Timeline.GetSetMonster(monster.Name); monsterInstance.Last20DamageActions = ((Monster)monster).Last20DamageActions.ToList(); monsterInstance.Last20DamageTakenActions = ((Monster)monster).Last20DamageTakenActions.ToList(); monsterInstance.Last20HealingActions = ((Monster)monster).Last20HealingActions.ToList(); monsterInstance.Last20Items = ((Monster)monster).Last20Items.ToList(); foreach (Stat <double> stat in monster.Stats) { monsterInstance.Stats.EnsureStatValue(stat.Name, stat.Value); } this.RabbitHoleCopy(ref monsterInstance, monster); } historyItem.Start = this.ParseControl.StartTime; historyItem.End = DateTime.Now; historyItem.ParseLength = historyItem.End - historyItem.Start; var parseTimeDetails = $"{historyItem.Start} -> {historyItem.End} [{historyItem.ParseLength}]"; var zone = "UNKNOWN"; if (XIVInfoViewModel.Instance.CurrentUser != null) { var mapIndex = XIVInfoViewModel.Instance.CurrentUser.MapIndex; MapItem mapItem = ZoneLookup.GetZoneInfo(mapIndex); switch (Constants.GameLanguage) { case "French": zone = mapItem.Name.French; break; case "Japanese": zone = mapItem.Name.Japanese; break; case "German": zone = mapItem.Name.German; break; case "Chinese": zone = mapItem.Name.Chinese; break; case "Korean": zone = mapItem.Name.Korean; break; default: zone = mapItem.Name.English; break; } } var monsterName = "NULL"; try { StatGroup biggestMonster = null; foreach (StatGroup monster in this.ParseControl.Timeline.Monster) { if (biggestMonster == null) { biggestMonster = monster; } else { if (monster.Stats.GetStatValue("TotalOverallDamage") > biggestMonster.Stats.GetStatValue("TotalOverallDamage")) { biggestMonster = monster; } } } if (biggestMonster != null) { monsterName = biggestMonster.Name; } } catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } foreach (Stat <double> oStat in currentOverallStats) { historyController.Timeline.Overall.Stats.EnsureStatValue(oStat.Name, oStat.Value); } historyItem.Name = $"{zone} [{monsterName}] {parseTimeDetails}"; DispatcherHelper.Invoke(() => MainViewModel.Instance.ParseHistory.Insert(1, historyItem)); } }
public async Task SetProcess(ProcessModel processModel, string gameLanguage = "English", string patchVersion = "latest", bool useLocalCache = true, bool scanAllMemoryRegions = false) { this.ProcessModel = processModel; this.GameLanguage = gameLanguage; this.UseLocalCache = useLocalCache; this.UnsetProcess(); try { this.ProcessHandle = UnsafeNativeMethods.OpenProcess(UnsafeNativeMethods.ProcessAccessFlags.PROCESS_VM_ALL, false, (uint)this.ProcessModel.ProcessID); } catch (Exception) { this.ProcessHandle = processModel.Process.Handle; } finally { Constants.ProcessHandle = this.ProcessHandle; this.IsAttached = true; } if (this.IsNewInstance) { this.IsNewInstance = false; //Parallel.Invoke(async () => await ActionLookup.Resolve(), async () => await StatusEffectLookup.Resolve(), async () => await ZoneLookup.Resolve()); Task[] taskArray = new Task[3]; taskArray[0] = Task.Factory.StartNew(async() => await ActionLookup.Resolve()); taskArray[1] = Task.Factory.StartNew(async() => await StatusEffectLookup.Resolve()); taskArray[2] = Task.Factory.StartNew(async() => await ZoneLookup.Resolve()); Task.WaitAll(taskArray); //await ActionLookup.Resolve(); //await StatusEffectLookup.Resolve(); //await ZoneLookup.Resolve(); await this.ResolveMemoryStructures(processModel, patchVersion); } this.AttachmentWorker = new AttachmentWorker(); this.AttachmentWorker.StartScanning(processModel); this.SystemModules.Clear(); this.GetProcessModules(); Scanner.Instance.Locations.Clear(); var signatures = await Signatures.Resolve(processModel, patchVersion); List <Signature> sigs = signatures as List <Signature>; sigs.Add(new Signature { Key = "INVENTORYBAGS", PointerPath = new List <long> { 0x15786f0 } }); sigs.Add(new Signature { Key = "INVENTORYSTART", PointerPath = new List <long> { 0x1c1de30 } }); Scanner.Instance.LoadOffsets(sigs, scanAllMemoryRegions); }
public static JsonParse ConvertParse() { var hasDamage = ParseControl.Instance.Timeline.Overall.Stats.GetStatValue("TotalOverallDamage") > 0; var hasHealing = ParseControl.Instance.Timeline.Overall.Stats.GetStatValue("TotalOverallHealing") > 0; var hasDamageTaken = ParseControl.Instance.Timeline.Overall.Stats.GetStatValue("TotalOverallDamageTaken") > 0; if (!hasDamage && !hasHealing && !hasDamageTaken) { return(new JsonParse()); } StatContainer currentOverallStats = ParseControl.Instance.Timeline.Overall.Stats; Dictionary <string, object> historyItem = new Dictionary <string, object>(); Dictionary <string, object> timeline = new Dictionary <string, object>(); Dictionary <string, object> overall = new Dictionary <string, object> { { "Stats", new Dictionary <string, object>() } }; foreach (Stat <double> stat in currentOverallStats) { ((Dictionary <string, object>)overall["Stats"]).Add(stat.Name, stat.Value); } timeline.Add("Overall", overall); StatGroup[] playerList = ParseControl.Instance.Timeline.Party.ToArray(); Dictionary <string, object> players = new Dictionary <string, object>(); foreach (StatGroup player in playerList) { Dictionary <string, object> playerItem = new Dictionary <string, object> { { "Stats", new Dictionary <string, object>() }, { "Last20DamageActions", ((Player)player).Last20DamageActions.ToList() }, { "Last20DamageTakenActions", ((Player)player).Last20DamageTakenActions.ToList() }, { "Last20HealingActions", ((Player)player).Last20HealingActions.ToList() }, { "Last20Items", ((Player)player).Last20Items.ToList() } }; foreach (Stat <double> stat in player.Stats) { ((Dictionary <string, object>)playerItem["Stats"]).Add(stat.Name, stat.Value); } players.Add(player.Name, playerItem); RabbitHoleCopy(ref playerItem, player); } timeline.Add("Party", players); StatGroup[] monsterList = ParseControl.Instance.Timeline.Monster.ToArray(); Dictionary <string, object> monsters = new Dictionary <string, object>(); foreach (StatGroup monster in monsterList) { Dictionary <string, object> monsterItem = new Dictionary <string, object> { { "Stats", new Dictionary <string, object>() }, { "Last20DamageActions", ((Monster)monster).Last20DamageActions.ToList() }, { "Last20DamageTakenActions", ((Monster)monster).Last20DamageTakenActions.ToList() }, { "Last20HealingActions", ((Monster)monster).Last20HealingActions.ToList() }, { "Last20Items", ((Monster)monster).Last20Items.ToList() } }; foreach (Stat <double> stat in monster.Stats) { ((Dictionary <string, object>)monsterItem["Stats"]).Add(stat.Name, stat.Value); } monsters.Add(monster.Name, monsterItem); RabbitHoleCopy(ref monsterItem, monster); } timeline.Add("Monster", monsters); historyItem.Add("Timeline", timeline); DateTime start = ParseControl.Instance.StartTime; DateTime end = DateTime.Now; TimeSpan parseLength = end - start; var parseTimeDetails = $"{start} -> {end} [{parseLength}]"; var zone = "UNKNOWN"; if (XIVInfoViewModel.Instance.CurrentUser != null) { var mapIndex = XIVInfoViewModel.Instance.CurrentUser.MapIndex; MapItem mapItem = ZoneLookup.GetZoneInfo(mapIndex); switch (Constants.GameLanguage) { case "French": zone = mapItem.Name.French; break; case "Japanese": zone = mapItem.Name.Japanese; break; case "German": zone = mapItem.Name.German; break; case "Chinese": zone = mapItem.Name.Chinese; break; case "Korean": zone = mapItem.Name.Korean; break; default: zone = mapItem.Name.English; break; } } var monsterName = "NULL"; try { StatGroup biggestMonster = null; foreach (StatGroup monster in ParseControl.Instance.Timeline.Monster) { if (biggestMonster == null) { biggestMonster = monster; } else { if (monster.Stats.GetStatValue("TotalOverallDamage") > biggestMonster.Stats.GetStatValue("TotalOverallDamage")) { biggestMonster = monster; } } } if (biggestMonster != null) { monsterName = biggestMonster.Name; } } catch (Exception ex) { Logging.Log(Logger, new LogItem(ex, true)); } return(new JsonParse { Name = $"{zone} [{monsterName}] {parseTimeDetails}", Parse = JsonConvert.SerializeObject( historyItem, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }) }); }
public static DateTime ConvertToTimeZone(this DateTime?dt, long?timezone) { ZoneLookup objZoneLookup = new ZoneLookup(); //find time zone offset var zoneStd = ZoneLookupUI.lstZoneLookup.Where(x => x.ZoneLookupId == timezone).FirstOrDefault(); long?zoneStdLkup = timezone; if (zoneStd.isDayLight.ToBoolean()) { zoneStdLkup = zoneStd.alternateLkup.ToLong(); zoneStd = ZoneLookupUI.lstZoneLookup.Where(x => x.ZoneLookupId == zoneStdLkup).FirstOrDefault(); } //time without day light saving // DateTime localTime1 = new DateTime(dt.ToDateTime().Ticks); // DateTime localTime1 = DateTime; DateTime dt2 = dt ?? DateTime.MinValue; DateTime localTime1 = new DateTime(DateTime.SpecifyKind(dt2, DateTimeKind.Utc).Ticks); double min = (zoneStd.timeZoneOffset * 60); DateTime dt3 = localTime1.AddMinutes(min); if (zoneStd.isDayLight == null) { //day light savings are not applicable in this time zone //result.time = localTime1; //result.isDayLight = null; //result.timeZoneLkup = timeZone; return(dt3); } //is day light saving? //find date of second Sunday in March 2:00 AM //var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; //calculate day light start time DateTime dayLighStart = new DateTime(dt3.Year, 3, 8, 2, 0, 0); //search for second sunday in march var dayOfWeek = (int)dayLighStart.DayOfWeek; while (dayOfWeek != 0) { double dayLighStartMin = dayLighStart.ToDateTime().Minute + 1440; //move to next day DateTime dayLighStartdt = dayLighStart.AddMinutes(dayLighStartMin); dayOfWeek = (int)dayLighStartdt.DayOfWeek; dayLighStart = dayLighStartdt; } //calculate day light end time //DateTime dayLightEnd = new DateTime(dt3.Year, 11, 1); //int firstSunDayInNov = (8 - (int)dayLightEnd.DayOfWeek); DateTime dayLightEnd = new DateTime(dt3.Year, 11, 1, 2, 0, 0); //search for first sunday of november dayOfWeek = (int)dayLightEnd.DayOfWeek; while (dayOfWeek != 0) { double dayLightEndMin = dayLightEnd.ToDateTime().Minute + 1440; //move to next day DateTime dayLightEnddt = dayLightEnd.AddMinutes(dayLightEndMin); dayOfWeek = (int)dayLightEnddt.DayOfWeek; dayLightEnd = dayLightEnddt; } if (localTime1 < dayLighStart) { //result.time = localTime1; //result.isDayLight = false; //result.timeZoneLkup = zoneStdLkup; return(dt3); } else if (localTime1 < dayLightEnd) { //add one hour localTime1.AddMinutes(dt3.ToDateTime().Minute + 60); //result.time = localTime1; //result.isDayLight = true; //result.timeZoneLkup = zoneStd.alternateLkup; return(dt3.AddHours(1)); } else { //result.time = localTime1; //result.isDayLight = false; //result.timeZoneLkup = zoneStdLkup; return(dt3); } //return Convert.ToDateTime(obj); }
static void Main(string[] args) { var stringReader = new StringReader(XElement.Load("./Bootstrapper.exe.nlog").ToString()); using (XmlReader xmlReader = XmlReader.Create(stringReader)) { LogManager.Configuration = new XmlLoggingConfiguration(xmlReader, null); } ActionLookup.GetActionInfo(2); StatusEffectLookup.GetStatusInfo(2); ZoneLookup.GetZoneInfo(138); ActionItem action = ActionLookup.GetActionInfo(2); StatusItem status = StatusEffectLookup.GetStatusInfo(2); MapItem zone = ZoneLookup.GetZoneInfo(138); var processName = "ffxiv_dx11"; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { processName = "ffxiv_dx11.exe"; } Process process = Process.GetProcessesByName(processName).FirstOrDefault(); if (process == null && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { var ps = new Process(); ps.StartInfo = new ProcessStartInfo("ps", "-Ao pid,command"); ps.StartInfo.RedirectStandardOutput = true; ps.Start(); var content = ps.StandardOutput.ReadToEnd(); ps.WaitForExit(2000); var pid = content.Split(Environment.NewLine).Where(x => x.Contains(processName)).Select(x => Enumerable.FirstOrDefault(x.Split(' '))).FirstOrDefault(x => x != null); if (!string.IsNullOrEmpty(pid)) { process = Process.GetProcessById(int.Parse(pid)); } } if (process != null) { MemoryHandler.Instance.SetProcess( new ProcessModel { IsWin64 = true, Process = process, }); MemoryHandler.Instance.SignaturesFoundEvent += delegate(object sender, SignaturesFoundEvent e) { foreach (KeyValuePair <string, Signature> kvp in e.Signatures) { Console.WriteLine($"{kvp.Key} => {kvp.Value.GetAddress():X}"); } }; while (Scanner.Instance.IsScanning) { Thread.Sleep(1000); Console.WriteLine("Scanning..."); } } Console.WriteLine("To exit this application press \"Enter\"."); Console.ReadLine(); }