Skip to content

Commit bf36e1d

Browse files
committed
Fixed #605
1 parent aa1be20 commit bf36e1d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Il2CppDumper/ExecutableFormats/WebAssembly.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ public WebAssembly(Stream stream) : base(stream)
4646

4747
public WebAssemblyMemory CreateMemory()
4848
{
49+
var last = dataSections[dataSections.Length - 1];
50+
var bssStart = last.Offset + (uint)last.Data.Length;
4951
var stream = new MemoryStream(new byte[Length]);
5052
foreach (var dataSection in dataSections)
5153
{
5254
stream.Position = dataSection.Offset;
5355
stream.Write(dataSection.Data, 0, dataSection.Data.Length);
5456
}
55-
return new WebAssemblyMemory(stream, Is32Bit);
57+
return new WebAssemblyMemory(stream, bssStart);
5658
}
5759
}
5860
}

Il2CppDumper/ExecutableFormats/WebAssemblyMemory.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ namespace Il2CppDumper
44
{
55
public sealed class WebAssemblyMemory : Il2Cpp
66
{
7-
public WebAssemblyMemory(Stream stream, bool is32Bit) : base(stream)
7+
private uint bssStart;
8+
9+
public WebAssemblyMemory(Stream stream, uint bssStart) : base(stream)
810
{
9-
Is32Bit = is32Bit;
11+
Is32Bit = true;
12+
this.bssStart = bssStart;
1013
}
1114

1215
public override ulong MapVATR(ulong addr)
@@ -55,9 +58,9 @@ public override SectionHelper GetSectionHelper(int methodCount, int typeDefiniti
5558
};
5659
var bss = new SearchSection
5760
{
58-
offset = Length,
61+
offset = bssStart,
5962
offsetEnd = long.MaxValue, //hack
60-
address = Length,
63+
address = bssStart,
6164
addressEnd = long.MaxValue //hack
6265
};
6366
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);

Il2CppDumper/Utils/SectionHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ private ulong FindMetadataRegistrationOld()
220220
foreach (var section in data)
221221
{
222222
il2Cpp.Position = section.offset;
223-
while (il2Cpp.Position < section.offsetEnd)
223+
while (il2Cpp.Position < section.offsetEnd - il2Cpp.PointerSize)
224224
{
225225
var addr = il2Cpp.Position;
226226
if (il2Cpp.ReadIntPtr() == typeDefinitionsCount)

0 commit comments

Comments
 (0)