D2SLib
D2SLib copied to clipboard
Nullreference exception when trying to read a sharedstorage.
Hello,
I tried accessing a d2i file (created through a offline playthrough in D2R). But I get a nullreference exception when trying to read the data
byte[] bytes = File.ReadAllBytes("test.d2i");
D2I save = Core.ReadD2I(bytes, 0x61);
The project is a .netcore 3.1 (lts) console application. My diablo 2 R installation is up to date.
Any idea what could cause this?
I tried running the unit test using my shared storage file :
Message:
Test method D2SLibTests.D2ITest.VerifyCanReadSharedStash115 threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
Stack Trace:
Item.ReadComplete(BitReader reader, Item item, UInt32 version) line 313
Item.Read(BitReader reader, UInt32 version) line 152
ItemList.Read(BitReader reader, UInt32 version) line 62
D2I.Read(Byte[] bytes, UInt32 version) line 18
Core.ReadD2I(Byte[] bytes, UInt32 version) line 49
D2ITest.VerifyCanReadSharedStash115() line 19`
Taking a look at the callstack the itemList received strange values but I still don't know why
public static ItemList Read(BitReader reader, UInt32 version)
{
ItemList itemList = new ItemList();
itemList.Header = reader.ReadUInt16(); // <====== yield 43605
itemList.Count = reader.ReadUInt16(); // <====== yield 43605
// ...
After further analysis, I've come to realize that the serializer may have been outdated? I've tried several operations on the storage and each storage page begins with 55 AA 55 AA
(43605 43605)
Regards
I shared my storage file in case you want to test it: https://mega.nz/file/t1sRCKoR#UaGEkK6jIfLLHBtwaIhMob0atSE_AVajSSuVgqFdNDo
Do you use any mods like bigger inventory? Basically anything that changes the base inventory/stash sizes?
I can't recall If I have done all my tests on modified storage but yes It was intended to handle custom sized storages operations.