diff --git a/Artemis/Artemis/App.config b/Artemis/Artemis/App.config index 3ae824369..152e20a95 100644 --- a/Artemis/Artemis/App.config +++ b/Artemis/Artemis/App.config @@ -210,7 +210,7 @@ - + diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index baec03fe0..246fecf0c 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -107,11 +107,6 @@ False - - False - .\MyMemory-x64.dll - False - ..\packages\NAudio.1.7.3\lib\net35\NAudio.dll True @@ -363,7 +358,6 @@ SettingsSingleFileGenerator VolumeDisplay.Designer.cs - diff --git a/Artemis/Artemis/Models/MainModel.cs b/Artemis/Artemis/Models/MainModel.cs index f1760c8f7..56503a858 100644 --- a/Artemis/Artemis/Models/MainModel.cs +++ b/Artemis/Artemis/Models/MainModel.cs @@ -197,6 +197,8 @@ namespace Artemis.Models var process = MemoryHelpers.GetProcessIfRunning(effectModel.ProcessName); if (process == null) continue; + if (process.HasExited) + continue; ChangeEffect(effectModel); foundProcess = true; diff --git a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs index 516f07555..f604f0236 100644 --- a/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs +++ b/Artemis/Artemis/Modules/Effects/AudioVisualizer/AudioVisualizerModel.cs @@ -92,7 +92,9 @@ namespace Artemis.Modules.Effects.AudioVisualizer if (device == null || SpectrumData == null) return; - + if (!SpectrumData.Any()) + return; + // Start filling the model _generating = true; diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs index 257392c74..74a6d2e97 100644 --- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs +++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3Model.cs @@ -1,44 +1,45 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; -using System.Linq; +using System.IO; +using System.Text.RegularExpressions; using Artemis.Models; using Artemis.Modules.Games.RocketLeague; -using Artemis.Settings; using Artemis.Utilities.Keyboard; -using Artemis.Utilities.Memory; -using Binarysharp.MemoryManagement; -using MyMemory; -using Newtonsoft.Json; namespace Artemis.Modules.Games.Witcher3 { public class Witcher3Model : GameModel { - private IntPtr _baseAddress; - private GamePointersCollectionModel _pointer; - private RemoteProcess _process; + private readonly Regex _signRegex; + private readonly Stopwatch _updateSw; private KeyboardRectangle _signRect; - private MemorySharp _mem; + private string _witcherSettings; public Witcher3Model(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel) { Name = "Witcher3"; ProcessName = "witcher3"; Scale = 4; + + _updateSw = new Stopwatch(); + _signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled); } public int Scale { get; set; } public override bool Enabled() { - return true; + return true; // TODO } public override void Dispose() { - _process = null; + _witcherSettings = null; + + _updateSw.Reset(); } public override void Enable() @@ -49,94 +50,61 @@ namespace Artemis.Modules.Games.Witcher3 Rotate = true, LoopSpeed = 0.5 }; - MemoryHelpers.GetPointers(); - _pointer = JsonConvert - .DeserializeObject(Offsets.Default.Witcher3); - var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessName); - _baseAddress = tempProcess.MainModule.BaseAddress; - _process = new RemoteProcess((uint) tempProcess.Id); - _mem = new MemorySharp(tempProcess); + // Ensure the config file is found + var witcherSettings = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + + @"\The Witcher 3\user.settings"; + if (File.Exists(witcherSettings)) + _witcherSettings = witcherSettings; + + _updateSw.Start(); } public override void Update() { - if (_process == null) + // Witcher effect is very static and reads from disk, don't want to update too often. + if (_updateSw.ElapsedMilliseconds < 500) + return; + _updateSw.Restart(); + + if (_witcherSettings == null) return; - var processHandle = _process.ProcessHandle; - var addr = MemoryHelpers.FindAddress(processHandle, _baseAddress, - _pointer.GameAddresses.First(ga => ga.Description == "Sign").BasePointer, - _pointer.GameAddresses.First(ga => ga.Description == "Sign").Offsets); + var reader = new StreamReader(File.Open(_witcherSettings, + FileMode.Open, + FileAccess.Read, + FileShare.ReadWrite)); + var configContent = reader.ReadToEnd(); + reader.Close(); - var test = - _mem.Modules.MainModule.FindPattern( - new byte[] - { - 0x88, 0x07, 0x48, 0x8B, 0x5C, 0x24, 0x30, 0x48, 0x83, 0xC4, 0x20, 0x5F, 0xC3, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xC2, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x48 - }, - "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 0, true); - var tessst = _process.MemoryManager.Read(test.Address); - var result = _process.MemoryManager.Read(addr); + var signRes = _signRegex.Match(configContent); + if (signRes.Groups.Count < 2) + return; + var sign = signRes.Groups[1].Value; - switch (result) + switch (sign) { - case 0: - // Aard - _signRect.Colors = new List - { - Color.DeepSkyBlue, - Color.Blue, - Color.DeepSkyBlue, - Color.Blue - }; + case "ST_Aard\r": + _signRect.Colors = new List {Color.DeepSkyBlue, Color.Blue}; break; - case 1: - // Yrden - _signRect.Colors = new List - { - Color.Purple, - Color.DeepPink, - Color.Purple, - Color.DeepPink - }; + case "ST_Yrden\r": + _signRect.Colors = new List {Color.Purple, Color.DeepPink}; break; - case 2: - // Igni - _signRect.Colors = new List - { - Color.DarkOrange, - Color.Red, - Color.DarkOrange, - Color.Red - }; + case "ST_Igni\r": + _signRect.Colors = new List {Color.DarkOrange, Color.Red}; break; - case 3: - // Quen - _signRect.Colors = new List - { - Color.DarkOrange, - Color.Yellow, - Color.DarkOrange, - Color.Yellow - }; + case "ST_Quen\r": + _signRect.Colors = new List {Color.DarkOrange, Color.FromArgb(232, 193, 0)}; break; - case 4: - // Axii - _signRect.Colors = new List - { - Color.LawnGreen, - Color.DarkGreen, - Color.LawnGreen, - Color.DarkGreen - }; + case "ST_Axii\r": + _signRect.Colors = new List {Color.LawnGreen, Color.DarkGreen}; break; } } public override Bitmap GenerateBitmap() { - var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(); + var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale); using (var g = Graphics.FromImage(bitmap)) { g.Clear(Color.Transparent); diff --git a/Artemis/Artemis/MyMemory-x64.dll b/Artemis/Artemis/MyMemory-x64.dll deleted file mode 100644 index 168f97e14..000000000 Binary files a/Artemis/Artemis/MyMemory-x64.dll and /dev/null differ