Skip to content

Commit

Permalink
Slight API change
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Dec 11, 2024
1 parent 158ed40 commit 56f64cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion LibCpp2IL/Metadata/Il2CppAssemblyNameDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public byte[]? PublicKey
{
get
{
var result = LibCpp2IlMain.TheMetadata!.GetBytesFromIndex(publicKeyIndex);
var result = LibCpp2IlMain.TheMetadata!.GetByteArrayFromIndex(publicKeyIndex);
return result.Length == 0 ? null : result;
}
}
Expand Down
24 changes: 12 additions & 12 deletions LibCpp2IL/Metadata/Il2CppMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,18 @@ public int GetDefaultValueFromIndex(int index)

private ConcurrentDictionary<int, string> _cachedStrings = new ConcurrentDictionary<int, string>();

/// <summary>
/// Read a byte array from the string data section of the metadata.
/// </summary>
/// <param name="index">The offset relative to the start of the string section.</param>
/// <returns>The </returns>
public byte[] GetByteArrayFromIndex(int index)
{
var offset = metadataHeader.stringOffset + index;
var count = ReadUnityCompressedUIntAtRawAddr(offset, out var bytesRead);
return ReadByteArrayAtRawAddress(offset + bytesRead, (int)count);
}

public string GetStringFromIndex(int index)
{
GetLockOrThrow();
Expand All @@ -426,18 +438,6 @@ public string GetStringFromIndex(int index)
}
}

/// <summary>
/// Read a byte array from the string data section of the metadata.
/// </summary>
/// <param name="index">The offset relative to the start of the string section.</param>
/// <returns>The </returns>
public byte[] GetBytesFromIndex(int index)
{
var offset = metadataHeader.stringOffset + index;
var count = ReadUnityCompressedUIntAtRawAddr(offset, out var bytesRead);
return ReadByteArrayAtRawAddress(offset + bytesRead, (int)count);
}

internal string ReadStringFromIndexNoReadLock(int index)
{
if (!_cachedStrings.ContainsKey(index))
Expand Down

0 comments on commit 56f64cf

Please sign in to comment.