Skip to content

Commit

Permalink
Fixed #605
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfare committed Apr 23, 2022
1 parent aa1be20 commit bf36e1d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Il2CppDumper/ExecutableFormats/WebAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ public WebAssembly(Stream stream) : base(stream)

public WebAssemblyMemory CreateMemory()
{
var last = dataSections[dataSections.Length - 1];
var bssStart = last.Offset + (uint)last.Data.Length;
var stream = new MemoryStream(new byte[Length]);
foreach (var dataSection in dataSections)
{
stream.Position = dataSection.Offset;
stream.Write(dataSection.Data, 0, dataSection.Data.Length);
}
return new WebAssemblyMemory(stream, Is32Bit);
return new WebAssemblyMemory(stream, bssStart);
}
}
}
11 changes: 7 additions & 4 deletions Il2CppDumper/ExecutableFormats/WebAssemblyMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ namespace Il2CppDumper
{
public sealed class WebAssemblyMemory : Il2Cpp
{
public WebAssemblyMemory(Stream stream, bool is32Bit) : base(stream)
private uint bssStart;

public WebAssemblyMemory(Stream stream, uint bssStart) : base(stream)
{
Is32Bit = is32Bit;
Is32Bit = true;
this.bssStart = bssStart;
}

public override ulong MapVATR(ulong addr)
Expand Down Expand Up @@ -55,9 +58,9 @@ public override SectionHelper GetSectionHelper(int methodCount, int typeDefiniti
};
var bss = new SearchSection
{
offset = Length,
offset = bssStart,
offsetEnd = long.MaxValue, //hack
address = Length,
address = bssStart,
addressEnd = long.MaxValue //hack
};
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
Expand Down
2 changes: 1 addition & 1 deletion Il2CppDumper/Utils/SectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private ulong FindMetadataRegistrationOld()
foreach (var section in data)
{
il2Cpp.Position = section.offset;
while (il2Cpp.Position < section.offsetEnd)
while (il2Cpp.Position < section.offsetEnd - il2Cpp.PointerSize)
{
var addr = il2Cpp.Position;
if (il2Cpp.ReadIntPtr() == typeDefinitionsCount)
Expand Down

0 comments on commit bf36e1d

Please sign in to comment.