Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/HackF5.UnitySpy/AssemblyImageFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static AssemblyImage GetAssemblyImage(UnityProcessFacade process, string
domain = process.ReadPtr(domainAddress);
}
//// pointer to array of structs of type _MonoAssembly
var assemblyArrayAddress = process.ReadPtr(domain + process.MonoLibraryOffsets.ReferencedAssemblies);
var assemblyArrayAddress = process.ReadPtr(domain + /*process.MonoLibraryOffsets.ReferencedAssemblies*/160);
for (var assemblyAddress = assemblyArrayAddress;
assemblyAddress != IntPtr.Zero;
assemblyAddress = process.ReadPtr(assemblyAddress + process.SizeOfPtr))
Expand Down
6 changes: 3 additions & 3 deletions src/HackF5.UnitySpy/Detail/AssemblyImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ private ConcurrentDictionary<IntPtr, TypeDefinition> CreateTypeDefinitions()
{
var definitions = new ConcurrentDictionary<IntPtr, TypeDefinition>();
int classCache = this.Process.MonoLibraryOffsets.ImageClassCache;
var classCacheSize = this.ReadUInt32(classCache + this.Process.MonoLibraryOffsets.HashTableSize);
var classCacheTableArray = this.ReadPtr(classCache + this.Process.MonoLibraryOffsets.HashTableTable);
var classCacheSize = this.ReadUInt32(/*classCache + this.Process.MonoLibraryOffsets.HashTableSize*/1256);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I only know the good values for classeCache + HashTableSize and classCache + HashTableTable but I have no idea about the individual values of each offset

var classCacheTableArray = this.ReadPtr(1264/*classCache + this.Process.MonoLibraryOffsets.HashTableTable*/);

for (var tableItem = 0;
tableItem < (classCacheSize * this.Process.SizeOfPtr);
tableItem += this.Process.SizeOfPtr)
{
for (var definition = this.Process.ReadPtr(classCacheTableArray + tableItem);
definition != IntPtr.Zero;
definition = this.Process.ReadPtr(definition + this.Process.MonoLibraryOffsets.TypeDefinitionNextClassCache))
definition = this.Process.ReadPtr(definition + /*this.Process.MonoLibraryOffsets.TypeDefinitionNextClassCache*/264))
{
definitions.GetOrAdd(definition, new TypeDefinition(this, definition));
}
Expand Down
15 changes: 9 additions & 6 deletions src/HackF5.UnitySpy/Detail/TypeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public TypeDefinition([NotNull] AssemblyImage image, IntPtr address)
// Get the generic type arguments
if (this.TypeInfo.TypeCode == TypeCode.GENERICINST)
{
this.fieldCount = this.ReadInt32(96);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I can't simply use 96 for the TypeDefinitionFieldCount offset since this line isn't always executed at the same time as the line that uses TypeDefinitionFieldCount

var monoGenericClassAddress = this.TypeInfo.Data;
var monoClassAddress = this.Process.ReadPtr(monoGenericClassAddress);
this.Image.GetTypeDefinition(monoClassAddress);
Expand Down Expand Up @@ -159,7 +160,7 @@ public TValue GetStaticValue<TValue>(string fieldName)
try
{
var vTableMemorySize = this.Process.SizeOfPtr * this.VTableSize;
var valuePtr = this.Process.ReadPtr(this.VTable + this.Process.MonoLibraryOffsets.VTable + vTableMemorySize);
var valuePtr = this.Process.ReadPtr(this.VTable + /*this.Process.MonoLibraryOffsets.VTable*/72 + vTableMemorySize);
return field.GetValue<TValue>(valuePtr);
}
catch (Exception e)
Expand Down Expand Up @@ -193,7 +194,7 @@ private IReadOnlyList<FieldDefinition> GetFields()
}

var fields = new List<FieldDefinition>();
if (this.ClassKind == MonoClassKind.GInst)
if (this.ClassKind is MonoClassKind.GInst or MonoClassKind.GParam)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't simply an offset change

{
fields.AddRange(this.GetGeneric().GetFields());
}
Expand Down Expand Up @@ -248,13 +249,15 @@ private IEnumerable<TypeDefinition> NestedHierarchy()

private TypeDefinition GetGeneric()
{
if (this.ClassKind != MonoClassKind.GInst)
if (this.ClassKind is MonoClassKind.GInst or MonoClassKind.GParam)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't simply an offset change

{
var genericContainerPtr = this.ReadPtr(this.Process.MonoLibraryOffsets.TypeDefinitionMonoGenericClass);
return this.Image.GetTypeDefinition(this.Process.ReadPtr(genericContainerPtr));
}
else
{
return null;
}

var genericContainerPtr = this.ReadPtr(this.Process.MonoLibraryOffsets.TypeDefinitionMonoGenericClass);
return this.Image.GetTypeDefinition(this.Process.ReadPtr(genericContainerPtr));
}
}
}
1 change: 1 addition & 0 deletions src/HackF5.UnitySpy/Offsets/UnityVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public struct UnityVersion
public static readonly UnityVersion Version2018_4_10 = new UnityVersion(2018, 4, 10);
public static readonly UnityVersion Version2019_4_5 = new UnityVersion(2019, 4, 5);
public static readonly UnityVersion Version2020_3_13 = new UnityVersion(2020, 3, 13);
public static readonly UnityVersion Version2022_3_10 = new UnityVersion(2022, 3, 10);

public UnityVersion(int year, int versionWithinYear, int subversionWithinYear)
{
Expand Down
3 changes: 1 addition & 2 deletions src/HackF5.UnitySpy/ProcessFacade/ProcessFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ private int GetSize(TypeCode typeCode)

case TypeCode.U:
case TypeCode.U4:
return sizeof(uint);

return 8;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be bound to offsets

case TypeCode.I8:
return sizeof(long);

Expand Down