diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8869f37a..43cb136e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,10 @@ name: build on: + workflow_dispatch: push: - branches: [ "main" ] + branches: + - main pull_request: - branches: [ "main" ] - workflow_dispatch: env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/qodana.yml b/.github/workflows/qodana.yml index 107234b1..52824e16 100644 --- a/.github/workflows/qodana.yml +++ b/.github/workflows/qodana.yml @@ -1,10 +1,12 @@ name: Qodana on: - workflow_dispatch: - pull_request: + #schedule: + # - cron: "30 1 * * *" push: - branches: # Specify your branches here - - main # The 'main' branch + branches: + - main + pull_request: + workflow_dispatch: jobs: qodana: diff --git a/Components/SoulMemory.dll b/Components/SoulMemory.dll index 7fdc099e..17ea487c 100644 Binary files a/Components/SoulMemory.dll and b/Components/SoulMemory.dll differ diff --git a/Components/SoulSplitter.dll b/Components/SoulSplitter.dll index 2984c191..6eba9b12 100644 Binary files a/Components/SoulSplitter.dll and b/Components/SoulSplitter.dll differ diff --git a/Components/Updates.xml b/Components/Updates.xml index d0b3b007..27861b4a 100644 --- a/Components/Updates.xml +++ b/Components/Updates.xml @@ -1,16 +1,28 @@ + + + + + + + Elden Ring: Fixed 1.10.x screenstate offset (thanks Soarqin!) + Elden Ring: Added and fixed a couple eventflags (thanks Soarqin!) + Elden Ring: Fixed 1.12 offsets + Dark souls Remastered: Fixed 1.01 compatibility + + - - - - - - Fixed event flag logger not opening from the menu - Elden Ring: Fixed MIGT (thanks ViRazY!) - - - + + + + + + Fixed event flag logger not opening from the menu + Elden Ring: Fixed MIGT (thanks ViRazY!) + + + diff --git a/Directory.Build.props b/Directory.Build.props index 69ecb4cb..e31bfa4d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 1.7.3 + 1.7.4 diff --git a/src/SoulMemory/DarkSouls1/Remastered.cs b/src/SoulMemory/DarkSouls1/Remastered.cs index 6b854239..266f0dbc 100644 --- a/src/SoulMemory/DarkSouls1/Remastered.cs +++ b/src/SoulMemory/DarkSouls1/Remastered.cs @@ -39,6 +39,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using System.Text.RegularExpressions; using SoulMemory.Parameters; @@ -65,11 +66,27 @@ public class Remastered : IDarkSouls1 private readonly Pointer _soloParamMan = new Pointer(); private readonly Pointer _loadingScreenItems = new Pointer(); private readonly Pointer _msgMan = new Pointer(); + private DsrVersion _version; private int? _steamId3; private bool? _isJapanese; private List _itemLotParams = new List(); private List _weaponDescriptionsTable = new List(); + private long _playerCtrlOffset = 0x68; + private long _currentSaveSlotOffset = 0xaa0; + + private enum DsrVersion + { + [Version("1.0.0.0")] + V101, + [Version("1.3.0.0")] + V130, + [Version("1.3.1.0")] + V131, + [Version("unknown")] + Unknown + } + public Process GetProcess() => _process; public ResultErr TryRefresh() => MemoryScanner.TryRefresh(ref _process, "darksoulsremastered", InitPointers, ResetPointers); @@ -93,12 +110,20 @@ private void ResetPointers() _weaponDescriptionsTable.Clear(); _steamId3 = null; _isJapanese = null; + _version = DsrVersion.Unknown; } private ResultErr InitPointers() { - try + try { + if (_process.MainModule == null) + { + return Result.Err(new RefreshError(RefreshErrorReason.MainModuleNull)); + } + + _version = _process.MainModule.FileVersionInfo.ResolveVersion(); + ResolveGameVersionSpecificOffsets(_version); var treeBuilder = GetTreeBuilder(); var result = MemoryScanner.TryResolvePointers(treeBuilder, _process); if(result.IsErr) @@ -117,6 +142,24 @@ private ResultErr InitPointers() } } + private void ResolveGameVersionSpecificOffsets(DsrVersion version) + { + switch (version) + { + default: + _playerCtrlOffset = 0x68; + _currentSaveSlotOffset = 0xaa0; + break; + + case DsrVersion.V101: + _playerCtrlOffset = 0x48; + _currentSaveSlotOffset = 0xa90; + break; + + } + Console.WriteLine(_playerCtrlOffset); + } + public TreeBuilder GetTreeBuilder() { var treeBuilder = new TreeBuilder(); @@ -134,7 +177,7 @@ public TreeBuilder GetTreeBuilder() treeBuilder .ScanRelative("WorldChrManImp", "48 8b 0d ? ? ? ? 0f 28 f1 48 85 c9 74 ? 48 89 7c", 3, 7) .AddPointer(_playerIns, 0, 0x68) - .AddPointer(_playerPos, 0, 0x68, 0x68, 0x28) + .AddPointer(_playerPos, 0, 0x68, _playerCtrlOffset, 0x28) ; treeBuilder @@ -187,7 +230,7 @@ public TreeBuilder GetTreeBuilder() public int NgCount() => _gameDataMan?.ReadInt32(0x78) ?? 0; - public int GetCurrentSaveSlot() => _gameMan?.ReadInt32(0xaa0) ?? 0; + public int GetCurrentSaveSlot() => _gameMan?.ReadInt32(_currentSaveSlotOffset) ?? 0; public Vector3f GetPosition() => _playerPos == null ? new Vector3f(0, 0, 0) : new Vector3f(_playerPos.ReadFloat(0x10), _playerPos.ReadFloat(0x14), _playerPos.ReadFloat(0x18)); diff --git a/src/SoulMemory/EldenRing/EldenRing.cs b/src/SoulMemory/EldenRing/EldenRing.cs index 98741d08..d68798db 100644 --- a/src/SoulMemory/EldenRing/EldenRing.cs +++ b/src/SoulMemory/EldenRing/EldenRing.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using SoulMemory.Memory; using SoulMemory.Native; using Pointer = SoulMemory.Memory.Pointer; @@ -80,39 +81,49 @@ private void InitializeOffsets(Version v) var version = GetVersion(v); switch (version) { - case EldenRingVersion.V102: + case EldenRingVersion.V1_02_0: + case EldenRingVersion.V1_02_1: + case EldenRingVersion.V1_02_2: + case EldenRingVersion.V1_02_3: _screenStateOffset = 0x718; _positionOffset = 0x6b8; _mapIdOffset = 0x6c8; _playerInsOffset = 0x18468; break; - case EldenRingVersion.V103: + case EldenRingVersion.V1_03_0: + case EldenRingVersion.V1_03_1: + case EldenRingVersion.V1_03_2: _screenStateOffset = 0x728; _positionOffset = 0x6b8; _mapIdOffset = 0x6c8; _playerInsOffset = 0x18468; break; - case EldenRingVersion.V104: - case EldenRingVersion.V105: - case EldenRingVersion.V106: + + case EldenRingVersion.V1_04_0: + case EldenRingVersion.V1_04_1: + case EldenRingVersion.V1_05_0: + case EldenRingVersion.V1_06_0: _screenStateOffset = 0x728; _positionOffset = 0x6B0; _mapIdOffset = 0x6c0; _playerInsOffset = 0x18468; break; - case EldenRingVersion.V107: + case EldenRingVersion.V1_07_0: _screenStateOffset = 0x728; _positionOffset = 0x6B0; _mapIdOffset = 0x6c0; _playerInsOffset = 0x1e508; break; - case EldenRingVersion.V108: - case EldenRingVersion.V109: - case EldenRingVersion.V110: + case EldenRingVersion.V1_08_0: + case EldenRingVersion.V1_08_1: + case EldenRingVersion.V1_09_0: + case EldenRingVersion.V1_09_1: + case EldenRingVersion.V1_10_0: + case EldenRingVersion.V1_10_1: _screenStateOffset = 0x728; _positionOffset = 0x6d4; _mapIdOffset = 0x6d0; @@ -120,7 +131,12 @@ private void InitializeOffsets(Version v) break; default: - case EldenRingVersion.V112: + case EldenRingVersion.V1_12_0: + case EldenRingVersion.V1_12_3: + case EldenRingVersion.V1_13_0: + case EldenRingVersion.V1_14_0: + case EldenRingVersion.V1_15_0: + case EldenRingVersion.V1_16_0: _screenStateOffset = 0x730; _positionOffset = 0x6d4; _mapIdOffset = 0x6d0; @@ -186,67 +202,90 @@ private void ResetPointers() #endregion + #region version ================================================================================================ + + private readonly Dictionary _versions = new Dictionary() + { + + { EldenRingVersion.V1_02_0, new Version(1,2,0,0) }, + { EldenRingVersion.V1_02_1, new Version(1,2,1,0) }, + { EldenRingVersion.V1_02_2, new Version(1,2,2,0) }, + { EldenRingVersion.V1_02_3, new Version(1,2,3,0) }, + { EldenRingVersion.V1_03_0, new Version(1,3,0,0) }, + { EldenRingVersion.V1_03_1, new Version(1,3,1,0) }, + { EldenRingVersion.V1_03_2, new Version(1,3,2,0) }, + { EldenRingVersion.V1_04_0, new Version(1,4,0,0) }, + { EldenRingVersion.V1_04_1, new Version(1,4,1,0) }, + { EldenRingVersion.V1_05_0, new Version(1,5,0,0) }, + { EldenRingVersion.V1_06_0, new Version(1,6,0,0) }, + { EldenRingVersion.V1_07_0, new Version(1,7,0,0) }, + { EldenRingVersion.V1_08_0, new Version(1,8,0,0) }, + { EldenRingVersion.V1_08_1, new Version(1,8,1,0) }, + { EldenRingVersion.V1_09_0, new Version(1,9,0,0) }, + { EldenRingVersion.V1_09_1, new Version(1,9,1,0) }, + //1.10 turned into 2.0.0.0 for some reason + { EldenRingVersion.V1_10_0, new Version(2,0,0,0) }, + { EldenRingVersion.V1_10_1, new Version(2,0,1,0) }, + { EldenRingVersion.V1_12_0, new Version(2,2,0,0) }, + { EldenRingVersion.V1_12_3, new Version(2,2,3,0) }, + { EldenRingVersion.V1_13_0, new Version(2,3,0,0) }, + { EldenRingVersion.V1_14_0, new Version(2,4,0,0) }, + { EldenRingVersion.V1_15_0, new Version(2,5,0,0) }, + { EldenRingVersion.V1_16_0, new Version(2,6,0,0) }, + }; public enum EldenRingVersion { - V102, - V103, - V104, - V105, - V106, - V107, - V108, - V109, - V110, - V112, + + V1_02_0, + V1_02_1, + V1_02_2, + V1_02_3, + + V1_03_0, + V1_03_1, + V1_03_2, + + V1_04_0, + V1_04_1, + + V1_05_0, + V1_06_0, + V1_07_0, + + V1_08_0, + V1_08_1, + + V1_09_0, + V1_09_1, + + V1_10_0, + V1_10_1, + + V1_12_0, + V1_12_3, + + V1_13_0, + V1_14_0, + V1_15_0, + V1_16_0, + Unknown, }; public EldenRingVersion GetVersion(Version v) { - switch (v.Major) + var version = _versions.FirstOrDefault(i => i.Value.CompareTo(v) == 0); + if (version.Value == null) { - default: - return EldenRingVersion.Unknown; - - case 1: - switch (v.Minor) - { - default: - return EldenRingVersion.Unknown; - case 2: - return EldenRingVersion.V102; - case 3: - return EldenRingVersion.V103; - case 4: - return EldenRingVersion.V104; - case 5: - return EldenRingVersion.V105; - case 6: - return EldenRingVersion.V106; - case 7: - return EldenRingVersion.V107; - case 8: - return EldenRingVersion.V108; - case 9: - return EldenRingVersion.V109; - case 10: - return EldenRingVersion.V110; - } - - case 2: - switch (v.Minor) - { - default: - return EldenRingVersion.Unknown; - case 0: - return EldenRingVersion.V110; - case 2: - return EldenRingVersion.V112; - } + return EldenRingVersion.Unknown; } + + return version.Key; } + #endregion + public void EnableHud() { if (_hud != null) diff --git a/src/SoulMemory/Extensions.cs b/src/SoulMemory/Extensions.cs index 5a81260c..bf78ad92 100644 --- a/src/SoulMemory/Extensions.cs +++ b/src/SoulMemory/Extensions.cs @@ -16,7 +16,10 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; using System.Xml; +using SoulMemory.Memory; namespace SoulMemory { @@ -80,5 +83,20 @@ public static long ClearBit(this long l, int index) return l & ~((long)0x1 << index); } + public static T ResolveVersion(this FileVersionInfo fileVersionInfo) where T : Enum + { + var values = Enum.GetValues(typeof(T)) + .Cast() + .Select(i => (i, i.GetEnumAttribute().Version)) + .ToList(); + + var versionStr = $"{fileVersionInfo.FileMajorPart}.{fileVersionInfo.FileMinorPart}.{fileVersionInfo.FileBuildPart}.{fileVersionInfo.FilePrivatePart}"; + if (values.Any(i => i.Version == versionStr)) + { + return values.First(i => i.Version == versionStr).i; + } + + return values.First(i => i.Version == "unknown").i; + } } } diff --git a/src/SoulMemory/Memory/Extensions.cs b/src/SoulMemory/Memory/Extensions.cs index 861f46c3..98141eb0 100644 --- a/src/SoulMemory/Memory/Extensions.cs +++ b/src/SoulMemory/Memory/Extensions.cs @@ -15,6 +15,7 @@ // along with this program. If not, see . using System; +using System.Diagnostics; using System.Linq; using System.Reflection; @@ -58,5 +59,16 @@ public static string GetDisplayDescription(this Enum enumValue) } return displayName; } + + public static T GetEnumAttribute(this Enum value) where T : Attribute + { + var attribute = value + .GetType() + .GetMember(value.ToString()) + .FirstOrDefault() + .GetCustomAttribute(); + + return attribute; + } } } diff --git a/src/SoulMemory/SoulMemory.csproj b/src/SoulMemory/SoulMemory.csproj index f6634477..f0ca8ae5 100644 --- a/src/SoulMemory/SoulMemory.csproj +++ b/src/SoulMemory/SoulMemory.csproj @@ -55,7 +55,6 @@ - diff --git a/src/SoulMemory/VersionAttribute.cs b/src/SoulMemory/VersionAttribute.cs new file mode 100644 index 00000000..8cf7edc9 --- /dev/null +++ b/src/SoulMemory/VersionAttribute.cs @@ -0,0 +1,34 @@ +// This file is part of the SoulSplitter distribution (https://github.com/FrankvdStam/SoulSplitter). +// Copyright (c) 2022 Frank van der Stam. +// https://github.com/FrankvdStam/SoulSplitter/blob/main/LICENSE +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; + +namespace SoulMemory +{ + public class VersionAttribute : Attribute + { + public VersionAttribute(string version) + { + Version = version; + } + + public string Version { get; } + public Version GetVersion() => new Version(Version); + } +} diff --git a/src/cli/Program.cs b/src/cli/Program.cs index f4f06a6a..67a739e5 100644 --- a/src/cli/Program.cs +++ b/src/cli/Program.cs @@ -41,8 +41,17 @@ internal class Program [STAThread] static void Main(string[] args) { + TestUi(); + GameLoop((e) => + { + var saveSlot = e.GetCurrentSaveSlot(); + var pos = e.GetPosition(); + var igtElapsed = TimeSpan.FromMilliseconds(e.GetInGameTimeMilliseconds()); + Console.WriteLine($"IGT: {igtElapsed} slot: {saveSlot} pos: {pos}"); + }); + GlobalHotKey.RegisterHotKey(ModifierKeys.Alt, Key.A, () =>{ Debug.WriteLine("A"); }); GlobalHotKey.RegisterHotKey(ModifierKeys.Alt, Key.S, () =>{ Debug.WriteLine("S"); }); GlobalHotKey.RegisterHotKey(ModifierKeys.Alt, Key.D, () =>{ Debug.WriteLine("D"); }); diff --git a/tests/SoulMemory.Tests/SoulMemory.Tests.csproj b/tests/SoulMemory.Tests/SoulMemory.Tests.csproj index 6f74ab79..0b560396 100644 --- a/tests/SoulMemory.Tests/SoulMemory.Tests.csproj +++ b/tests/SoulMemory.Tests/SoulMemory.Tests.csproj @@ -14,10 +14,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + diff --git a/tests/SoulSplitter.Tests/SoulSplitter.Tests.csproj b/tests/SoulSplitter.Tests/SoulSplitter.Tests.csproj index d3f27420..88c90ac9 100644 --- a/tests/SoulSplitter.Tests/SoulSplitter.Tests.csproj +++ b/tests/SoulSplitter.Tests/SoulSplitter.Tests.csproj @@ -19,10 +19,10 @@ - - - - + + + +