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

[Feature Request] Extract exefs from games #295

Open
SuperTavor opened this issue Sep 27, 2023 · 8 comments
Open

[Feature Request] Extract exefs from games #295

SuperTavor opened this issue Sep 27, 2023 · 8 comments

Comments

@SuperTavor
Copy link

citra skill issue, would appreciate if you could add it.

@wheremyfoodat
Copy link
Owner

The code to do this is already there pretty much, need a UI to actually do it though.

@SuperTavor
Copy link
Author

epic! can't wait. btw, thanks for the literal godspeed response

@wheremyfoodat
Copy link
Owner

:rpog:

@wheremyfoodat
Copy link
Owner

You can hack ExeFS dumping into the source code real quick if you'd like too

@SuperTavor
Copy link
Author

SuperTavor commented Sep 27, 2023

my cpp is not nearly good enough 😭

@SuperTavor
Copy link
Author

guess I gotta watch another 6 hour course

@wheremyfoodat
Copy link
Owner

for (int i = 0; i < 10; i++) {
u8* fileInfo = &exeFSHeader[i * 16];
char name[9];
std::memcpy(name, fileInfo, 8); // Get file name as a string
name[8] = '\0'; // Add null terminator to it just in case there's none
u32 fileOffset = *(u32*)&fileInfo[0x8];
u32 fileSize = *(u32*)&fileInfo[0xC];
if (fileSize != 0) {
printf("File %d. Name: %s, Size: %08X, Offset: %08X\n", i, name, fileSize, fileOffset);
}
if (std::strcmp(name, ".code") == 0) {
if (hasCode()) {
Helpers::panic("Second code file in a single NCCH partition. What should this do?\n");
}
if (compressCode) {
std::vector<u8> tmp;
tmp.resize(fileSize);
// A file offset of 0 means our file is located right after the ExeFS header
// So in the ROM, files are located at (file offset + exeFS offset + exeFS header size)
readFromFile(file, exeFS, tmp.data(), fileOffset + exeFSHeaderSize, fileSize);
// Decompress .code file from the tmp vector to the "code" vector
if (!CartLZ77::decompress(codeFile, tmp)) {
printf("Failed to decompress .code file\n");
return false;
}
} else {
codeFile.resize(fileSize);
readFromFile(file, exeFS, codeFile.data(), fileOffset + exeFSHeaderSize, fileSize);
}
}
}
}

This is the code that enumerates ExeFS files. You can use the same code used for reading the .code file to load the other ExeFS files, and dump them like this https://stackoverflow.com/a/14089675

@SuperTavor
Copy link
Author

I'll try, thanks

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