Skip to content

Commit

Permalink
chore(MemoryReader): Update assembly version numbers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
myinusa committed Dec 10, 2024
1 parent fef4720 commit 64ac041
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Processory/Internal/MemoryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public string ReadString(ulong offset, int maxLength = 1024) {
byte[] buffer = Read((nuint)offset, maxLength);
int nullTerminatorIndex = Array.IndexOf<byte>(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) {
Expand Down
5 changes: 5 additions & 0 deletions Processory/Internal/MemoryReaderArray.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System;

namespace Processory.Internal {
// public partial class MemoryReader { }
}
28 changes: 2 additions & 26 deletions Processory/Internal/RunTimeTypeInformation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Processory.Native;
using System.Text;
using System.Text;
using Processory.Native;

namespace Processory.Internal;
public class RunTimeTypeInformation {
Expand Down Expand Up @@ -100,46 +100,22 @@ private string GetBaseClassName(nuint baseClassArrayPtr, nuint baseAddress, int
/// <param name="address">The address of the RTTI structure.</param>
/// <returns>An array of strings containing the names of the RTTI classes, or null if the retrieval fails.</returns>
public string[] GetRTTIClass(ulong address) {
// if (MemoryReader.ProcessHandler == nint.Zero) {
// throw new InvalidOperationException("Process handler is not set.");
// }

nuint structAddr = memoryReader.Read<nuint>(address);
//if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)structAddr)) {
// return Array.Empty<string>();
//}
if (structAddr == nuint.Zero) return Array.Empty<string>();

nuint objectLocatorPtr = memoryReader.Read<nuint>(structAddr - (nuint)objectLocatorOffset);
//if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)objectLocatorPtr)) {
// return Array.Empty<string>();
//}
if (objectLocatorPtr == nuint.Zero) return Array.Empty<string>();

var baseOffset = memoryReader.Read<int>((ulong)objectLocatorPtr + BaseOffsetPosition);
//if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)objectLocatorPtr)) {
// return Array.Empty<string>();
//}
// if (baseOffset == IntPtr.Zero) return Array.Empty<string>();

nuint baseAddress = nuint.Subtract(objectLocatorPtr, baseOffset);

nuint classHierarchyDescriptorPtr = GetClassHierarchyDescriptorPtr(objectLocatorPtr, baseAddress, ClassHierarchyDescriptorOffsetPosition);
//if (!ProcessoryClient.AddressHelper.IsValidAddress((IntPtr)classHierarchyDescriptorPtr)) {
// return Array.Empty<string>();
//}
if (classHierarchyDescriptorPtr == nuint.Zero) return Array.Empty<string>();

int baseClassCount = memoryReader.Read<int>((ulong)classHierarchyDescriptorPtr + BaseClassCountPosition);
//if (!ProcessoryClient.AddressHelper.IsValidAddress(baseClassCount)) {
// return Array.Empty<string>();
//}
if (baseClassCount == 0 || baseClassCount > MaxBaseClassCount) return Array.Empty<string>();

nuint baseClassArrayPtr = GetBaseClassArrayPtr(classHierarchyDescriptorPtr, baseAddress, BaseClassArrayOffsetPosition);
//if (!ProcessoryClient.AddressHelper.IsValidAddress((nint)baseClassArrayPtr)) {
// return Array.Empty<string>();
//}
if (baseClassArrayPtr == nuint.Zero) return Array.Empty<string>();

return GetBaseClassNames(baseClassArrayPtr, baseAddress, baseClassCount) ?? Array.Empty<string>();
Expand Down
2 changes: 1 addition & 1 deletion Processory/Processory.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<PropertyGroup>
<VersionPrefix>1.18.241209.1314</VersionPrefix>
<VersionPrefix>1.18.241209.1856</VersionPrefix>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Processory/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions docs/tips.md
Original file line number Diff line number Diff line change
@@ -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.
```

0 comments on commit 64ac041

Please sign in to comment.