Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct support of Il2CppRGCTXDefinition in metadata version above 27.1 #339

Merged
Merged
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
1 change: 1 addition & 0 deletions LibCpp2IL/BinaryStructures/Il2CppRGCTXDataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public enum Il2CppRGCTXDataType : int
IL2CPP_RGCTX_DATA_CLASS,
IL2CPP_RGCTX_DATA_METHOD,
IL2CPP_RGCTX_DATA_ARRAY,
IL2CPP_RGCTX_DATA_CONSTRAINED,
}
63 changes: 59 additions & 4 deletions LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,72 @@
public Il2CppRGCTXDataType type;
public int _rawIndex;

public int MethodIndex => _rawIndex;
public int MethodIndex => type == Il2CppRGCTXDataType.IL2CPP_RGCTX_DATA_CONSTRAINED ? _constrainedData.MethodIndex : _defData.MethodIndex;

public int TypeIndex => _rawIndex;
public int TypeIndex => type == Il2CppRGCTXDataType.IL2CPP_RGCTX_DATA_CONSTRAINED ? _constrainedData.TypeIndex : _defData.TypeIndex;

public Il2CppMethodSpec? MethodSpec => LibCpp2IlMain.Binary?.GetMethodSpec(MethodIndex);

public Il2CppTypeReflectionData? Type => LibCpp2ILUtils.GetTypeReflectionData(LibCpp2IlMain.Binary!.GetType(TypeIndex));


public class Il2CppRGCTXDefinitionData : ReadableClass
{
private int rgctxDataDummy;
public int MethodIndex => rgctxDataDummy;
public int TypeIndex => rgctxDataDummy;
public override void Read(ClassReadingBinaryReader reader)
{
rgctxDataDummy = reader.ReadInt32();
}
}

public class Il2CppRGCTXConstrainedData : ReadableClass
{
public int _typeIndex;
public int _encodedMethodIndex;
public int TypeIndex => _typeIndex;
public int MethodIndex => _encodedMethodIndex;

public override void Read(ClassReadingBinaryReader reader)
{
_typeIndex = reader.ReadInt32();
_encodedMethodIndex = reader.ReadInt32();
}
}
[Version(Min = 27.2f)]
private Il2CppRGCTXConstrainedData _constrainedData;

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build - Windows .NET Framework Zip

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build Single-File Artifact (linux-x64, Cpp2IL)

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build Single-File Artifact (osx-x64, Cpp2IL)

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 44 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build Single-File Artifact (win-x64, Cpp2IL)

Non-nullable field '_constrainedData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

private Il2CppRGCTXDefinitionData _defData;

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Run Tests & Publish Dev Package

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build - Windows .NET Framework Zip

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build Single-File Artifact (linux-x64, Cpp2IL)

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build Single-File Artifact (osx-x64, Cpp2IL)

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 46 in LibCpp2IL/BinaryStructures/Il2CppRGCTXDefinition.cs

View workflow job for this annotation

GitHub Actions / Build Single-File Artifact (win-x64, Cpp2IL)

Non-nullable field '_defData' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
public override void Read(ClassReadingBinaryReader reader)
{
type = (Il2CppRGCTXDataType)reader.ReadInt32();
_rawIndex = reader.ReadInt32();
type = IsLessThan(29) ? (Il2CppRGCTXDataType)reader.ReadInt32() : (Il2CppRGCTXDataType)reader.ReadInt64();
if (IsLessThan(27.2f))
{
_defData = new Il2CppRGCTXDefinitionData();
_defData.Read(reader);
}
else
{
var va = reader.ReadNUint();
if (type == Il2CppRGCTXDataType.IL2CPP_RGCTX_DATA_CONSTRAINED)
{
var bakPosition = reader.Position;
reader.Position = LibCpp2IlMain.Binary!.MapVirtualAddressToRaw(va);
_constrainedData = new Il2CppRGCTXConstrainedData();
_constrainedData.Read(reader);
reader.Position = bakPosition;
}
else
{
var bakPosition = reader.Position;
reader.Position = LibCpp2IlMain.Binary!.MapVirtualAddressToRaw(va);
_defData = new Il2CppRGCTXDefinitionData();
_defData.Read(reader);
reader.Position = bakPosition;
}

}

}
}
Loading