d0k3 / Decrypt9WIP

Multipurpose content dumper and decryptor for the Nintendo 3DS
GNU General Public License v2.0
404 stars 59 forks source link

GBA VC Save File Dumper very inconsistent #151

Closed ficion closed 7 years ago

ficion commented 7 years ago

I have been trying to dump the save file from the a the GBA VC of Metroid Fusion, using Decrypt9 (and Hourglass9 as well), without much luck.

Basically, Decrypt9 says it properly dumped, but it's not properly dumped. I inspected the .sav file yield and it's always this (exactly this, since I has checked all of my failed attempts): image [...] empty [...] image

My hunch is that it probably isn't dumping the right part of RAM. I know that you are supposed to load the GBA VC game first and then dump the save, because the save (GBA Card battery?) has to be held on RAM. I have tried:

All of these attempts yield the exact same file. It also happens with Hourglass9, unsurprisingly. I have tried many times, and only once it has worked (yielding a proper back-up), but I can't seem to reproduce it again.

This is in opposition to injecting a back-up save file into a GBA VC Game, which has worked all the times.

So far, there is another program which has actually worked in dumping the save file, called agbsave9. However, I'd like to know what am I doing wrong here (and I'd likely one to use one single too for injecting and dumping).

All my attempts have been using the latest version of Decrypt9WIP. I use SysNAND, a New 3DS and my System Menu version is 11.2.

d0k3 commented 7 years ago

This is strange. I'll research this problem, but, in the meantime, could you try GodMode9? There is a file called "gbavc.sav" in drive "S:", which you can copy / write over.

d0k3 commented 7 years ago

Also, is it possibly your issue has something to do with this issue? https://github.com/d0k3/Decrypt9WIP/issues/138

ficion commented 7 years ago

I tried GodMode9, but there was no gbavc.sav file to be found in that drive (I tried it after attempting to dump the file without shutting down the console). There was, however, an agbsave.bin file, which I assume comes from agbsave9. Also, I have read that issue, but I don't think it's similar to my problem. For one, injecting has worked every time I've tried (I did think I had problems with it as well previously, but it turned out that I was using an empty back-up file).

d0k3 commented 7 years ago

The gbavc.sav file is only not available in GM9, if it is not valid on your NAND. Could you try GM9 after you started that GBA game / after a succesfull injection? I'm unsure what coudl cause this problem at the moment.

d0k3 commented 7 years ago

Accidential close, sorry.

ficion commented 7 years ago

I just tried a save injection and it was successful (the save was replaced), but the file still didn't show up. Also, the previous time I tried GM9 I did open it after opening the GBA VC game, so. I have to mention that all of these latest test have only been done launching the payloads opening and closing the System Settings.

I also have no clue, too. Perhaps agbsave9 does something different in this regard. But still, it's weird that it doesn't seem to happen to other people. What configuration could I have different that could affect this? I use Luma3DS to load the payloads, perhaps there could be a problem there.

d0k3 commented 7 years ago

You are on A9LH, right? Any idea what version of A9LH (you can also just tell me when you installed it, I'll know which version then)? Is there anything special about your console.

"agbsave.bin" is the AGBSAVE partition in your system, which also contains the "gbavc.sav. "agbsave.bin" is a 512 byte header, followed by the GBA savedata. If the "gbavc.sav" file does not show up, the reason is the verification data inside that header is not correct.

Here's two ideas:

  1. What you could do is have a look at the agbsave.bin in the internal hex viewer or dump it, remove the first 512 byte and try if it the save works in an emulator (you may need to trim it).
  2. Use my test build of GodMode9 (link below). Press A on the agbsave.bin, then select "Calculate CMAC". Is the CMAC verified okay? If not, you are offered an option to fix it. I'd suggest you copy "agbsave.bin" somewhere before and after testing, then compare in a hex editor. After fixing, the gbavc.sav should also turn up in S:/ (might need to leave and reenter the drive).

GodMode9 testbuild: https://transfer.sh/lxJEu/godmode9-20170210-185036.zip

ficion commented 7 years ago

I didn't notice your edit, so I wrote this before your second suggestion. I will try your GodMode9 build now.


I'm not sure what's my A9LH version, but I installed it on January 9th.

I just tried trimming the file like you mentioned and it worked perfectly. I trimmed the first 512 bytes (everything before 0x200) and also removed everything past 0x7FFF.

The result was almost identical to the save dump yield by agbsave9 (which also had worked perfectly in the emulator), although the files weren't exactly the same: I hash checked them, then using a hex editor I noticed there were few bytes different here and there. I'm not sure why they aren't exactly the same, but both work well in the emulator (VBA-M) and there doesn't seem to be any difference in-game.

ficion commented 7 years ago

This is very weird, gbavc.sav does show up in S: when using your build (and only your build, I checked without it). I didn't even have to do any fix. agbsave.bin's CMAC also verifies correctly (so I don't actually have an option to fix it). I tried to use the gbavc.sav file in S: in an emulator and it also worked.

This is all so weird, but I think we're getting close to it.

d0k3 commented 7 years ago

Alright. Can you also try injecting via GM9?

d0k3 commented 7 years ago

Okay, I just noticed... You used the GM9 release earlier? That does not have gbavc.sav yet :). So, it was my fault. Try the injection in GM9, and I still need to think about how to fix it in D9

ficion commented 7 years ago

I'm not sure what you mean by "injection in GM9", I'm not sure how am I supposed to inject the save file? using GM9. Sorry if I can't be of much more help!

d0k3 commented 7 years ago

Just copy it into S:/. Must be named gbavc.sav. Y is the button you use to copy stuff in GM9.

ficion commented 7 years ago

It worked. I didn't really know you could inject a save just like that.

d0k3 commented 7 years ago

Alright... so there seems to be something fishy in D9 only. I'll look after that and may have a new testbuild later on. In the meantime - could you check your SD card for errors or use a different one?

ficion commented 7 years ago

I don't have access to a screwdriver at the moment, but I will post something if I manage to get my hands in one.

d0k3 commented 7 years ago

Okay, you could also try this test build and see if it still happens: https://transfer.sh/NbD4K/decrypt9wip-20170212-122739.zip

Dimensional commented 7 years ago

I managed to test your GM linked file earlier using Metroid, and I was also able to dump and inject the save in the same session. I simply unmounted the SD card, modified the save, then remounted without closing GM9. I haven't had a chance to test D9 would work, but at least this is useful.

ficion commented 7 years ago

Sorry for the delay. I tried it with that build and it still didn't yield a proper save file. It is probably something in my end, if it doesn't happen to other users, really.

d0k3 commented 7 years ago

Okay, I'm pretty sure the problem was in D9. Can you try this test build, so we can maybe close this issue? :) https://transfer.sh/tUtyw/decrypt9wip-20170214-110915.zip

ficion commented 7 years ago

The dumping worked!

Although... I removed all the .sav files on /files9/ before trying this build, however, when setting the name, there was a (!) next to the gbavc.sav option, as if I was going to overwrite a file, which was weird, since I made sure to delete that file as well. I also tried the file in S:/ and it worked as well.

d0k3 commented 7 years ago

That is strange, but that should be (most likely) an error on your end. Can you make 100% sure that file does not exist (not in root, not in files9/) and try again?

ficion commented 7 years ago

My bad, it did exist in root. Thanks a lot!

d0k3 commented 7 years ago

Alright, thank you. Solved, closed!