Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullreference exception when trying to read a sharedstorage. #5

Open
Salepate opened this issue Oct 28, 2021 · 2 comments
Open

Nullreference exception when trying to read a sharedstorage. #5

Salepate opened this issue Oct 28, 2021 · 2 comments

Comments

@Salepate
Copy link

Salepate commented Oct 28, 2021

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

@xXSFORTUNEXx
Copy link

Do you use any mods like bigger inventory? Basically anything that changes the base inventory/stash sizes?

@Salepate
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants