Added extra security for detecting fumen files
Making sure the file ends with .bin to avoid false positives
This commit is contained in:
parent
2cf94175c5
commit
87b6044e53
@ -149,7 +149,13 @@ EncryptFile (const std::string &input_file, const std::string &hex_key) {
|
||||
|
||||
bool
|
||||
IsFumenEncrypted (const std::string &filename) {
|
||||
std::ifstream file (filename, std::ios::binary);
|
||||
// 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 ());
|
||||
@ -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 ();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user