1
1
mirror of synced 2025-02-07 06:31:17 +01:00

Merge pull request #11 from AkaiiKitsune/Refactor

Fixed LayeredFS not always encrypting 08.18 Fumens
This commit is contained in:
esuo1198 2024-11-12 00:18:47 +09:00 committed by GitHub
commit f6440fd501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -11,6 +11,7 @@ It currently supports the following versions:
## Setup
Copy the extracted contents of `dist.zip` to the same directory as Taiko.exe
If your game hangs on a black screen at launch for more than a minute, Start Taiko.exe as Administrator !
### config.toml

View File

@ -149,14 +149,20 @@ EncryptFile (const std::string &input_file, const std::string &hex_key) {
bool
IsFumenEncrypted (const std::string &filename) {
std::ifstream file (filename, std::ios::binary);
file.seekg (0x210, std::ios::beg);
std::vector<unsigned char> buffer (32);
// Check if the filename ends with ".bin"
if (filename.size() < 4 || filename.substr(filename.size() - 4) != ".bin") {
std::cout << "Not a Fumen file: " << filename << std::endl;
return true; // If it doesn't we return early, as the file we're seeing isn't a fumen !
}
std::ifstream file(filename, std::ios::binary);
file.seekg (0x214, std::ios::beg);
std::vector<unsigned char> buffer (24);
file.read (reinterpret_cast<char *> (buffer.data ()), buffer.size ());
// Check if the read bytes match the expected pattern
std::vector<unsigned char> expected_bytes = {0x00, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00};
std::vector<unsigned char> expected_bytes = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
return buffer != expected_bytes;
}
@ -192,7 +198,7 @@ HOOK (HANDLE, CreateFileAHook, PROC_ADDRESS ("kernel32.dll", "CreateFileA"), LPC
uint32_t crc = CRC32C (0, crc_vector.data (), crc_vector.size ());
WriteFile (encPath, EncryptFile (newPath, fumenKey), crc); // And we save it
} else {
std::cout << "Missing or invalid fumen key : " << std::filesystem::relative (newPath) << " couldn't be encrypted."
std::cout << "Missing or invalid fumen key: " << std::filesystem::relative (newPath) << " couldn't be encrypted."
<< std::endl;
encPath = path.string ();
}
@ -223,7 +229,7 @@ HOOK (HANDLE, CreateFileAHook, PROC_ADDRESS ("kernel32.dll", "CreateFileA"), LPC
uint32_t crc = CRC32C (0, crc_vector.data (), crc_vector.size ());
WriteFile (encPath, EncryptFile (json_path.string (), datatableKey), crc); // And save it
} else {
std::cout << "Missing or invalid datatable key : " << std::filesystem::relative (newPath) << " couldn't be encrypted."
std::cout << "Missing or invalid datatable key: " << std::filesystem::relative (newPath) << " couldn't be encrypted."
<< std::endl;
encPath = path.string ();
}