From 64ac041ebf3e70e3c1b3c31d3234627d92d0b788 Mon Sep 17 00:00:00 2001 From: Matthias Yinusa <49248934+myinusa@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:51:58 +0000 Subject: [PATCH] chore(MemoryReader): Update assembly version numbers chore(MemoryReaderArray): Add new MemoryReaderArray class refactor(RunTimeTypeInformation): Optimize RTTI retrieval logic style(Processory.csproj, AssemblyInfo.cs): Update project and assembly version strings chore(docs/tips.md): Create tips documentation --- Processory/Internal/MemoryReader.cs | 2 +- Processory/Internal/MemoryReaderArray.cs | 5 ++++ Processory/Internal/RunTimeTypeInformation.cs | 28 ++----------------- Processory/Processory.csproj | 2 +- Processory/Properties/AssemblyInfo.cs | 2 +- docs/tips.md | 10 +++++++ 6 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 Processory/Internal/MemoryReaderArray.cs create mode 100644 docs/tips.md diff --git a/Processory/Internal/MemoryReader.cs b/Processory/Internal/MemoryReader.cs index 7fb23f0..512cf9c 100644 --- a/Processory/Internal/MemoryReader.cs +++ b/Processory/Internal/MemoryReader.cs @@ -142,7 +142,7 @@ public string ReadString(ulong offset, int maxLength = 1024) { byte[] buffer = Read((nuint)offset, maxLength); int nullTerminatorIndex = Array.IndexOf(buffer, 0); int length = nullTerminatorIndex >= 0 ? nullTerminatorIndex : buffer.Length; - return System.Text.Encoding.ASCII.GetString(buffer, 0, length); + return Encoding.ASCII.GetString(buffer, 0, length); } public nint ReadPointer(nint address) { diff --git a/Processory/Internal/MemoryReaderArray.cs b/Processory/Internal/MemoryReaderArray.cs new file mode 100644 index 0000000..1b438f8 --- /dev/null +++ b/Processory/Internal/MemoryReaderArray.cs @@ -0,0 +1,5 @@ +using System; + +namespace Processory.Internal { + // public partial class MemoryReader { } +} \ No newline at end of file diff --git a/Processory/Internal/RunTimeTypeInformation.cs b/Processory/Internal/RunTimeTypeInformation.cs index 0d953b9..5012687 100644 --- a/Processory/Internal/RunTimeTypeInformation.cs +++ b/Processory/Internal/RunTimeTypeInformation.cs @@ -1,5 +1,5 @@ -using Processory.Native; -using System.Text; +using System.Text; +using Processory.Native; namespace Processory.Internal; public class RunTimeTypeInformation { @@ -100,46 +100,22 @@ private string GetBaseClassName(nuint baseClassArrayPtr, nuint baseAddress, int /// The address of the RTTI structure. /// An array of strings containing the names of the RTTI classes, or null if the retrieval fails. public string[] GetRTTIClass(ulong address) { - // if (MemoryReader.ProcessHandler == nint.Zero) { - // throw new InvalidOperationException("Process handler is not set."); - // } - nuint structAddr = memoryReader.Read(address); - //if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)structAddr)) { - // return Array.Empty(); - //} if (structAddr == nuint.Zero) return Array.Empty(); nuint objectLocatorPtr = memoryReader.Read(structAddr - (nuint)objectLocatorOffset); - //if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)objectLocatorPtr)) { - // return Array.Empty(); - //} if (objectLocatorPtr == nuint.Zero) return Array.Empty(); var baseOffset = memoryReader.Read((ulong)objectLocatorPtr + BaseOffsetPosition); - //if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)objectLocatorPtr)) { - // return Array.Empty(); - //} - // if (baseOffset == IntPtr.Zero) return Array.Empty(); - nuint baseAddress = nuint.Subtract(objectLocatorPtr, baseOffset); nuint classHierarchyDescriptorPtr = GetClassHierarchyDescriptorPtr(objectLocatorPtr, baseAddress, ClassHierarchyDescriptorOffsetPosition); - //if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)classHierarchyDescriptorPtr)) { - // return Array.Empty(); - //} if (classHierarchyDescriptorPtr == nuint.Zero) return Array.Empty(); int baseClassCount = memoryReader.Read((ulong)classHierarchyDescriptorPtr + BaseClassCountPosition); - //if (!ProcessoryClient.AddressHelper.IsValidAddress(baseClassCount)) { - // return Array.Empty(); - //} if (baseClassCount == 0 || baseClassCount > MaxBaseClassCount) return Array.Empty(); nuint baseClassArrayPtr = GetBaseClassArrayPtr(classHierarchyDescriptorPtr, baseAddress, BaseClassArrayOffsetPosition); - //if (!ProcessoryClient.AddressHelper.IsValidAddress((nint)baseClassArrayPtr)) { - // return Array.Empty(); - //} if (baseClassArrayPtr == nuint.Zero) return Array.Empty(); return GetBaseClassNames(baseClassArrayPtr, baseAddress, baseClassCount) ?? Array.Empty(); diff --git a/Processory/Processory.csproj b/Processory/Processory.csproj index 67c64a9..3f7817d 100644 --- a/Processory/Processory.csproj +++ b/Processory/Processory.csproj @@ -13,7 +13,7 @@ - 1.18.241209.1314 + 1.18.241209.1856 diff --git a/Processory/Properties/AssemblyInfo.cs b/Processory/Properties/AssemblyInfo.cs index 44fa5cc..c8d84d5 100644 --- a/Processory/Properties/AssemblyInfo.cs +++ b/Processory/Properties/AssemblyInfo.cs @@ -11,7 +11,7 @@ #pragma warning disable CS7035 // The specified version string does not conform to the recommended format - major.minor.build.revision -[assembly: AssemblyFileVersion("1.18.241209.1314")] +[assembly: AssemblyFileVersion("1.18.241209.1856")] [assembly: AssemblyInformationalVersion("1.18.0")] #pragma warning restore CS7035 diff --git a/docs/tips.md b/docs/tips.md new file mode 100644 index 0000000..7808167 --- /dev/null +++ b/docs/tips.md @@ -0,0 +1,10 @@ +# Tips + +``` +MemoryReader: This class will handle basic memory reading operations. +MemoryReaderArray: This class will handle reading arrays from memory. +MemoryReaderString: This class will handle reading strings from memory. +MemoryReaderPointer: This class will handle reading pointers from memory. +MemoryReaderHelper: This class will contain helper methods used by other classes. + +``` \ No newline at end of file