Skip to content
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
11 changes: 7 additions & 4 deletions LibCpp2IL/Il2CppBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public abstract class Il2CppBinary(MemoryStream input) : ClassReadingBinaryReade
/// </summary>
public virtual ClassReadingBinaryReader Reader => this;

private float _metadataVersion;
public sealed override float MetadataVersion => _metadataVersion;
private float? _metadataVersion;
public sealed override float MetadataVersion => _metadataVersion ?? 0;

internal void SetMetadataVersion(float version) => _metadataVersion = version;

public int InBinaryMetadataSize { get; private set; }

public void Init(ulong pCodeRegistration, ulong pMetadataRegistration, Il2CppMetadata metadata)
{
_metadataVersion = metadata.MetadataVersion;

var cr = pCodeRegistration > 0 ? ReadReadableAtVirtualAddress<Il2CppCodeRegistration>(pCodeRegistration) : null;
var mr = pMetadataRegistration > 0 ? ReadReadableAtVirtualAddress<Il2CppMetadataRegistration>(pMetadataRegistration) : null;

Expand Down Expand Up @@ -487,6 +487,9 @@ public virtual bool TryGetExportedFunctionName(ulong addr, [NotNullWhen(true)] o

public virtual (ulong pCodeRegistration, ulong pMetadataRegistration) FindCodeAndMetadataReg(Il2CppMetadata metadata)
{
if (!_metadataVersion.HasValue)
throw new InvalidOperationException("MetadataVersion must be set before searching for code and metadata registration. Call SetMetadataVersion first.");

LibLogger.VerboseNewline("\tAttempting to locate code and metadata registration functions...");

var methodCount = metadata.methodDefs.Count(x => x.methodIndex >= 0);
Expand Down
1 change: 1 addition & 0 deletions LibCpp2IL/LibCpp2IlBinaryRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ internal static Il2CppBinary CreateAndInit(byte[] buffer, Il2CppMetadata metadat
var start = DateTime.Now;

var binary = match.FactoryFunc(memStream);
binary.SetMetadataVersion(metadata.MetadataVersion);

LibCpp2IlMain.Binary = binary;

Expand Down
Loading