Skip to content

Commit

Permalink
Fix bug when resolving indirectly pointed at field offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
gompoc authored and SamboyCoding committed Oct 11, 2021
1 parent 45c43b5 commit b778940
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Cpp2IL.Core/Analysis/FieldUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ private static List<FieldInType> RecalculateFieldOffsetsForGenericType(TypeRefer
private static FieldBeingAccessedData? GetIndirectlyPointedAtField(List<FieldInType> allFields, ulong offset, bool tryFindFloatingPointValue)
{
//We have no field directly at this offset - find the one immediately prior, and map that struct to its own fields
var structFIT = allFields.FindLast(f => !f.Static && f.Offset <= offset);

FieldInType structFIT = default(FieldInType);

foreach (var field in allFields)
if (!field.Static && field.Offset <= offset && field.Offset > structFIT.Offset)
structFIT = field;

if (structFIT.FieldType == null || structFIT.Constant != null) return null; //Couldn't find one, or they're all constants

Expand Down

0 comments on commit b778940

Please sign in to comment.