Skip to content

Commit 0d98cd5

Browse files
committed
Fixes from #542
1 parent 14e0335 commit 0d98cd5

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

Cpp2IL.Core/Cpp2IlApi.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,19 @@ public static void InitializeLibCpp2Il(string assemblyPath, string metadataPath,
8585

8686
ConfigureLib(allowUserToInputAddresses);
8787

88+
#if !DEBUG
8889
try
90+
#endif
8991
{
9092
var context = LibCpp2IlMain.LoadFromFileAsContext(assemblyPath, metadataPath, unityVersion);
9193
OnLibInitialized(context);
9294
}
95+
#if !DEBUG
9396
catch (Exception e)
9497
{
9598
throw new LibCpp2ILInitializationException("Fatal Exception initializing LibCpp2IL!", e);
9699
}
100+
#endif
97101

98102
}
99103

LibCpp2IL/Il2CppBinary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public abstract class Il2CppBinary(MemoryStream input) : ClassReadingBinaryReade
6969

7070
public int InBinaryMetadataSize { get; private set; }
7171

72-
private LibCpp2IlContext? _context;
72+
protected LibCpp2IlContext? _context;
7373

7474
protected override void OnReadableCreated(ReadableClass instance)
7575
{

LibCpp2IL/Wasm/WasmFile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public sealed class WasmFile : Il2CppBinary
2121

2222
public override ClassReadingBinaryReader Reader => _memoryBlock;
2323

24+
internal LibCpp2IlContext? Context => _context;
25+
2426
public WasmFile(MemoryStream input) : base(input)
2527
{
2628
is32Bit = true;

LibCpp2IL/Wasm/WasmMemoryBlock.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ public WasmMemoryBlock(WasmFile file) : base(BuildStream(file))
4040
is32Bit = true;
4141
Bytes = ((MemoryStream)BaseStream).ToArray();
4242
}
43+
44+
protected override void OnReadableCreated(ReadableClass instance)
45+
{
46+
if(_file.Context != null)
47+
instance.OwningContext = _file.Context;
48+
}
4349
}

0 commit comments

Comments
 (0)