Skip to content

Commit 653a683

Browse files
Xpl0itRSamboyCoding
authored andcommitted
Add index/offset accessors to Il2CppMetadata
Introduce utility accessors to Il2CppMetadata for retrieving entries by index or by offset. Adds methods for nested type indices, interface indices, property definitions, method definitions, and field definitions (both index- and offset-based), complementing existing range helpers and reducing manual index arithmetic when parsing metadata.
1 parent c849bf3 commit 653a683

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

LibCpp2IL/Metadata/Il2CppMetadata.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,23 +640,40 @@ internal string ReadStringFromIndexNoReadLock(int index)
640640

641641
public Il2CppParameterDefinition GetParameterDefinitionFromIndex(Il2CppVariableWidthIndex<Il2CppParameterDefinition> index) => parameterDefs[index.Value];
642642

643+
public Il2CppNestedTypeIndex GetNestedTypeIndicesFromIndex(Il2CppVariableWidthIndex<Il2CppNestedTypeIndex> index) => nestedTypeIndices[index.Value];
644+
645+
public Il2CppNestedTypeIndex GetNestedTypeIndicesFromOffset(Il2CppVariableWidthIndex<Il2CppNestedTypeIndex> startIndex, ushort offset) => nestedTypeIndices[startIndex.Value + offset];
646+
643647
public IEnumerable<int> GetNestedTypeIndicesFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppNestedTypeIndex> index, int count) => nestedTypeIndices.Skip(index.Value).Take(count).Select(n => n.Value);
644648

649+
public Il2CppVariableWidthIndex<Il2CppType> GetInterfaceIndicesFromIndex(Il2CppVariableWidthIndex<Il2CppInterfaceOffset> index) => interfaceIndices[index.Value];
650+
651+
public Il2CppVariableWidthIndex<Il2CppType> GetInterfaceIndicesFromOffset(Il2CppVariableWidthIndex<Il2CppInterfaceOffset> startIndex, ushort offset) => interfaceIndices[startIndex.Value + offset];
652+
645653
public IEnumerable<Il2CppVariableWidthIndex<Il2CppType>> GetInterfaceIndicesFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppInterfaceOffset> index, int count) => interfaceIndices.Skip(index.Value).Take(count);
646654

647655
public Il2CppInterfaceOffset[] GetInterfaceOffsetsFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppInterfaceOffset> index, int count) => interfaceOffsets.SubArray(index.Value, count);
648656

657+
public Il2CppPropertyDefinition GetPropertyDefinitionsFromIndex(Il2CppVariableWidthIndex<Il2CppPropertyDefinition> index) => propertyDefs[index.Value];
658+
659+
public Il2CppPropertyDefinition GetPropertyDefinitionsFromOffset(Il2CppVariableWidthIndex<Il2CppPropertyDefinition> startIndex, ushort offset) => propertyDefs[startIndex.Value + offset];
660+
649661
public Il2CppPropertyDefinition[] GetPropertyDefinitionsFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppPropertyDefinition> index, int count) => propertyDefs.SubArray(index.Value, count);
650662

651663
public Il2CppEventDefinition[] GetEventDefinitionsFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppEventDefinition> index, int count) => eventDefs.SubArray(index.Value, count);
652664

653665
public Il2CppMethodDefinition GetMethodDefinitionFromIndex(Il2CppVariableWidthIndex<Il2CppMethodDefinition> index) => methodDefs[index.Value];
666+
667+
public Il2CppMethodDefinition GetMethodDefinitionFromOffset(Il2CppVariableWidthIndex<Il2CppMethodDefinition> startIndex, ushort offset) => methodDefs[startIndex.Value + offset];
654668

655669
public Il2CppMethodDefinition[] GetMethodDefinitionsFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppMethodDefinition> index, int count) => methodDefs.SubArray(index.Value, count);
656670

657671
public Il2CppGenericParameter GetGenericParameterFromIndex(Il2CppVariableWidthIndex<Il2CppGenericParameter> index) => genericParameters[index.Value];
658672

659673
public Il2CppFieldDefinition GetFieldDefinitionFromIndex(Il2CppVariableWidthIndex<Il2CppFieldDefinition> index) => fieldDefs[index.Value];
674+
675+
public Il2CppFieldDefinition GetFieldDefinitionFromOffset(Il2CppVariableWidthIndex<Il2CppFieldDefinition> startIndex, ushort offset) => fieldDefs[startIndex.Value + offset];
676+
660677
public Il2CppFieldDefinition[] GetFieldDefinitionsFromIndexAndCount(Il2CppVariableWidthIndex<Il2CppFieldDefinition> index, int count) => fieldDefs.SubArray(index.Value, count);
661678

662679
public string GetStringLiteralFromIndex(uint index)

0 commit comments

Comments
 (0)