Osadziłem w extraktorze wykrywanie metody pakowania na podstawie wartości flagi. Klucz jest importowany w momęcie jego wykrycia, Podmieniłem poprzednią metodę pliku konfiguracyjnego z txt na json (nie przetestowano). Brak flagi do generowania pliku HPP z tablicami kluczy.
This commit is contained in:
parent
8402ce1b65
commit
293c1412ad
10 changed files with 18 additions and 34 deletions
|
|
@ -62,8 +62,12 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
|||
}
|
||||
|
||||
// Wczytaj klucz deszyfruj¹cy
|
||||
//std::filesystem::path kdir = cargoFileName.stem();
|
||||
//eman.loadKey(kdir.string());
|
||||
std::filesystem::path kdir = cargoFileName.stem();
|
||||
if (std::filesystem::exists(kdir.string() + ".key"))
|
||||
{
|
||||
std::cout << "Decryption key detected" << std::endl;
|
||||
eman.loadKey(kdir.string());
|
||||
}
|
||||
|
||||
//Otwieranie kontenera
|
||||
cargoFile.open(cargoFileName, std::ios::binary);
|
||||
|
|
@ -85,7 +89,7 @@ bool ExtractCargo::Extract(const std::string& cFile)
|
|||
bool ExtractCargo::CheckCargoFile()
|
||||
{
|
||||
std::vector<char> magic(signature.size());
|
||||
uint16_t cargoVer = 0;
|
||||
short cargoVer = 0;
|
||||
|
||||
if (!cargoFile.is_open())
|
||||
{
|
||||
|
|
@ -98,8 +102,6 @@ bool ExtractCargo::CheckCargoFile()
|
|||
cargoFile.read(reinterpret_cast<char*>(&filesLen), sizeof(filesLen));
|
||||
cargoFile.read(reinterpret_cast<char*>(&tablePosition), sizeof(tablePosition));
|
||||
|
||||
std::cout << std::string(magic.begin(), magic.end()) << std::endl;
|
||||
|
||||
if (std::string(magic.begin(), magic.end()) != signature)
|
||||
{
|
||||
std::cerr << "Error: Corrupted Cargo" << std::endl;
|
||||
|
|
@ -154,7 +156,7 @@ void ExtractCargo::computingBytes(const std::vector<char>& input, std::vector<ch
|
|||
break;
|
||||
|
||||
default:
|
||||
output = std::move(input);
|
||||
output = input;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -165,7 +167,6 @@ void ExtractCargo::computingBytes(const std::vector<char>& input, std::vector<ch
|
|||
void ExtractCargo::LoadFilesTable()
|
||||
{
|
||||
cargoFile.seekg(tablePosition);
|
||||
std::cout << "TU TABLICA" << std::endl;
|
||||
for (uint32_t i = 0; i < filesLen; ++i)
|
||||
{
|
||||
FilesTable fhTmp;
|
||||
|
|
@ -175,8 +176,6 @@ void ExtractCargo::LoadFilesTable()
|
|||
cargoFile.read(nameBuffor.data(), fhTmp.nameLen);
|
||||
fhTmp.nameFile = std::string(nameBuffor.begin(), nameBuffor.end());
|
||||
|
||||
std::cout << fhTmp.nameFile << std::endl;
|
||||
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.hashName), sizeof(fhTmp.hashName));
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.offset), sizeof(fhTmp.offset));
|
||||
cargoFile.read(reinterpret_cast<char*>(&fhTmp.size), sizeof(fhTmp.size));
|
||||
|
|
@ -192,14 +191,10 @@ void ExtractCargo::LoadFilesTable()
|
|||
//-----------------------------------------------------------------------------
|
||||
void ExtractCargo::ExtractingFilesFromCargo()
|
||||
{
|
||||
CompressingManager cm;
|
||||
|
||||
for (const auto& fh : filesHeads)
|
||||
{
|
||||
std::filesystem::path dir = cargoFileName.stem() / fh.nameFile;
|
||||
CreateDirections(dir);
|
||||
std::cout << "TU EXTRAT" << std::endl;
|
||||
std::cout << dir << std::endl;
|
||||
std::ofstream file(dir, std::ios::binary);
|
||||
|
||||
cargoFile.seekg(fh.offset);
|
||||
|
|
@ -208,7 +203,7 @@ void ExtractCargo::ExtractingFilesFromCargo()
|
|||
cargoFile.read(buffor.data(), fh.size);
|
||||
|
||||
std::vector<char> rawBuffor;
|
||||
computingBytes(buffor, rawBuffor, fh.size);
|
||||
computingBytes(buffor, rawBuffor, fh.flag);
|
||||
|
||||
if (!HashValid(rawBuffor, fh.crc))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue