hadeutscher / OvercookedTool

Overcooked 2 savegame conversion tool
45 stars 8 forks source link

Fix decrypt compatibility with .NET6 and above #24

Open SergejKiller opened 1 month ago

hadeutscher commented 1 month ago

have you made sure this works in game after decrypting and re-encrypting the file? do you mind attaching a sample savegame for which this issue arises?

the reason I'm suspicious about this is because the code you're modifying is literally copied from the game's code after decompiling. So if this code really is buggy, the game itself should have trouble parsing the file as well

hadeutscher commented 1 month ago

Another thing that may have happened is that some recent patch modified this code and introduced the possibility of non 16 bytes aligned savegames. Assuming you have a recently patched Overcooked 2 installation, do you mind opening the executable with ILSpy and checking if the Deobfuscate function changed? (that's the function's original name, I didn't change it)

SergejKiller commented 1 month ago

Unfortunately I cannot attach the random file types. So I've attached the json file, which you can manually encrypt and decrypt and see if the content says the same.

This issue might an artifact of switching to .NET 8.0 runtime.

CoopSlot_SaveFile_0.json

hadeutscher commented 1 month ago

Unfortunately I cannot attach the random file types. So I've attached the json file, which you can manually encrypt and decrypt and see if the content says the same.

This issue might an artifact of switching to .NET 8.0 runtime.

CoopSlot_SaveFile_0.json

Thanks; is this JSON file the output you got when decrypting with or without this patch? I don't see any extra bytes at the end as you described in the issue

SergejKiller commented 1 month ago

That's the correct file. If you encrypt it and then immediately decrypt it using the old tool, do you get the same file size?

SergejKiller commented 1 month ago

It seems .NET6+ change in behavior: https://github.com/dotnet/core/issues/6895

hadeutscher commented 1 month ago

I don't have the game installed; can you check what they did on their code? Was the game even upgraded to .NET >= 6 or is it on some older version that doesn't have this change?

SergejKiller commented 1 month ago

As .NET3 is obsolete I've been using OvercookedTool with .NET8 and run into that problem. My change should be compatible with .NET3 framework as well, but I do not have it to verify.

hadeutscher commented 1 month ago

I understand, but I'm afraid of diverging much from the original code as this is decompiled code. Can you make this change as small as possible (e.g. just add a second cryptoStream.Read(...); on the remainder right below the existing call) and document carefully that this line was not present in the original code, but was added to make the code compatible with recent .NET versions?