nfsu / NFS

Is a tool created for rom hacking, it stands for Nintendo File System (Utils) and can quickly read and interpret nds files such as NARC, NCLR, NCGR, etc.
MIT License
24 stars 1 forks source link

Runtime error: Archive BTAF didn't match format #7

Closed 0xJes closed 6 years ago

0xJes commented 6 years ago

This is the code:

#include "filesystem.h"

int main()
{
    Buffer buf = Buffer::read("test.nds");
    nfs::NDS *nds = (nfs::NDS*) buf.ptr;
    nfs::FileSystem fs(nds);

    nfs::NARC &narc = fs.get<nfs::NARC>(*fs["fielddata/eventdata/zone_event.narc"]);

    nfs::Archive arc(narc);  //error here
}

For some reason i can't step into nfs::Archive arc(narc); to see what exactly happens, but looks like btafb.size != btaf.files * 8 in archive.cpp evaluates to true and throws EXCEPTION("Archive BTAF didn't match format");.

I checked for these values in the main function: screenshot_20180621_212315

Looks like you want to check if the FAT size correspond to the number of files but buffer.size only holds the properties of the FAT, not the FAT itself.

Archive::Archive(NARC &narc) {

    BTAF &btaf = narc.at<0>();
    Buffer btafb = narc.get<0>();

    if (btafb.size != btaf.files * 8)
        EXCEPTION("Archive BTAF didn't match format");
    ...
Nielsbishere commented 6 years ago

What ROM are you trying to load? try using a decrypted NDS ROM and maybe one that's pretty common as well. 'btafb' is the buffer of the BTAF file; aka the files in the buffer. This means that it should indeed match btaf.files * 8; since 8 bytes are noted per file in the FAT.

0xJes commented 6 years ago

I'm using Pokémon Platinum, i tried other 2 decrypted roms with several narc files and all fails the same way.

Nielsbishere commented 6 years ago

Strange, what's the origin of the ROM? The US, the EU? Because both of those work for me. Could you send me the values of the NARC; including the size of the binary data?

EDIT: Qt works on Linux right? So you could try to build NFSU (requires building Qt for Linux first) and then open the ROM with that.

0xJes commented 6 years ago

I tried with two releases, EUR and ESP, however, both narcs are identical. imagen

Nielsbishere commented 6 years ago

It seems like you are right, it is checking against the incorrect size, I'll check how I can fix that.

Nielsbishere commented 6 years ago

It should be fixed in the new push; check if that works. I did test it on MSVC and the file you tried also worked for me. Be aware that not all file formats can be recognized and that means that some files might be called "32.????". A NARC doesn't provide any names and or extensions, so it is impossible to find the meaning of every file with just that format.