mirror of
https://github.com/siemens-mobile-hacks/libffshit.git
synced 2026-11-25 23:57:31 +00:00
Возможность извлечь только определённые партиции
This commit is contained in:
parent
385d813367
commit
8a8916cd31
9 changed files with 93 additions and 21 deletions
|
|
@ -16,7 +16,7 @@ class Base {
|
|||
|
||||
Base() { }
|
||||
|
||||
virtual void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) = 0;
|
||||
virtual void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector<std::string> parts_to_extract = {}) = 0;
|
||||
virtual const Directory::Ptr get_root() const = 0;
|
||||
|
||||
virtual ~Base() { }
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class EGOLD_CE : public Base {
|
|||
return std::make_shared<EGOLD_CE>(partitions);
|
||||
}
|
||||
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final;
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector<std::string> parts_to_extract = {}) override final;
|
||||
const Directory::Ptr get_root() const override final;
|
||||
|
||||
private:
|
||||
|
|
@ -73,7 +73,7 @@ class EGOLD_CE : public Base {
|
|||
|
||||
std::vector<uint32_t> recourse_protector;
|
||||
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data);
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract);
|
||||
|
||||
void print_block_header(const FFSBlock &block);
|
||||
void print_file_header(const FFSFile &file);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class SGOLD : public Base {
|
|||
return std::make_shared<SGOLD>(partitions);
|
||||
}
|
||||
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final;
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector<std::string> parts_to_extract = {}) override final;
|
||||
const Directory::Ptr get_root() const override final;
|
||||
|
||||
private:
|
||||
|
|
@ -71,7 +71,7 @@ class SGOLD : public Base {
|
|||
|
||||
bool prototype_6000;
|
||||
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data);
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract);
|
||||
|
||||
void scan(const std::string &block_name, FSBlocksMap &ffs_map, Directory::Ptr dir, const FileHeader &header, bool skip_broken = false, std::string path = "/");
|
||||
void read_recurse(FSBlocksMap &ffs_map, RawData &data, uint16_t next_id);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class SGOLD2 : public Base {
|
|||
return std::make_shared<SGOLD2>(partitions);
|
||||
}
|
||||
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final;
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector<std::string> parts_to_extract = {}) override final;
|
||||
const Directory::Ptr get_root() const override final;
|
||||
|
||||
private:
|
||||
|
|
@ -67,7 +67,7 @@ class SGOLD2 : public Base {
|
|||
std::vector<uint32_t> recourse_protector;
|
||||
|
||||
static void print_fit_header(const SGOLD2::FITHeader &header);
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data);
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract);
|
||||
|
||||
static void print_file_header(const FileHeader &header);
|
||||
static void print_file_part(const FilePart &part);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class SGOLD2_ELKA : public Base {
|
|||
return std::make_shared<SGOLD2_ELKA>(partitions);
|
||||
}
|
||||
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false) override final;
|
||||
void load(bool skip_broken = false, bool skip_dup = false, bool dump_data = false, std::vector<std::string> parts_to_extract = {}) override final;
|
||||
const Directory::Ptr get_root() const override final;
|
||||
|
||||
private:
|
||||
|
|
@ -77,7 +77,7 @@ class SGOLD2_ELKA : public Base {
|
|||
|
||||
std::vector<uint32_t> recourse_protector;
|
||||
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data);
|
||||
void parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract);
|
||||
|
||||
static void print_fit_header(const SGOLD2_ELKA::FITHeader &header);
|
||||
static void print_dir_header(const DirHeader &header);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ EGOLD_CE::EGOLD_CE(Partitions::Partitions::Ptr partitions) : partitions(partitio
|
|||
root_dir = Directory::build(ROOT_NAME, "/");
|
||||
}
|
||||
|
||||
void EGOLD_CE::load(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data);
|
||||
void EGOLD_CE::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract);
|
||||
}
|
||||
|
||||
const Directory::Ptr EGOLD_CE::get_root() const {
|
||||
|
|
@ -67,7 +67,7 @@ void EGOLD_CE::print_data(const FFSBlock &block) {
|
|||
}
|
||||
}
|
||||
|
||||
void EGOLD_CE::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
void EGOLD_CE::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
const auto &part_map = partitions->get_partitions();
|
||||
|
||||
for (const auto &pair : part_map) {
|
||||
|
|
@ -76,6 +76,24 @@ void EGOLD_CE::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
|||
const auto & part_blocks = part_info.get_blocks();
|
||||
|
||||
if (part_name.find("FFS") != std::string::npos) {
|
||||
if (parts_to_extract.size() != 0) {
|
||||
bool is_extract = false;
|
||||
|
||||
for (const auto &part_to_extract : parts_to_extract) {
|
||||
if (part_name == part_to_extract) {
|
||||
is_extract = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_extract) {
|
||||
Log::Logger::warn("Partition {} excluded", part_name);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size());
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ SGOLD::SGOLD(Partitions::Partitions::Ptr partitions) : partitions(partitions), p
|
|||
root_dir = Directory::build(ROOT_NAME, "/");
|
||||
}
|
||||
|
||||
void SGOLD::load(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data);
|
||||
void SGOLD::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract);
|
||||
}
|
||||
|
||||
const Directory::Ptr SGOLD::get_root() const {
|
||||
|
|
@ -175,7 +175,7 @@ void SGOLD::print_data(const FFSBlock &block) {
|
|||
}
|
||||
}
|
||||
|
||||
void SGOLD::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
void SGOLD::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
const auto &part_map = partitions->get_partitions();
|
||||
|
||||
for (const auto &pair : part_map) {
|
||||
|
|
@ -184,6 +184,24 @@ void SGOLD::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
|||
const auto & part_blocks = part_info.get_blocks();
|
||||
|
||||
if (part_name.find("FFS") != std::string::npos) {
|
||||
if (parts_to_extract.size() != 0) {
|
||||
bool is_extract = false;
|
||||
|
||||
for (const auto &part_to_extract : parts_to_extract) {
|
||||
if (part_name == part_to_extract) {
|
||||
is_extract = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_extract) {
|
||||
Log::Logger::warn("Partition {} excluded", part_name);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size());
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ SGOLD2::SGOLD2(Partitions::Partitions::Ptr partitions) : partitions(partitions)
|
|||
root_dir = Directory::build(ROOT_NAME, "/");
|
||||
}
|
||||
|
||||
void SGOLD2::load(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data);
|
||||
void SGOLD2::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract);
|
||||
}
|
||||
|
||||
const Directory::Ptr SGOLD2::get_root() const {
|
||||
|
|
@ -164,7 +164,7 @@ SGOLD2::FilePart SGOLD2::read_file_part(const RawData &data) {
|
|||
return part;
|
||||
}
|
||||
|
||||
void SGOLD2::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
void SGOLD2::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
const auto &part_map = partitions->get_partitions();
|
||||
|
||||
for (const auto &pair : part_map) {
|
||||
|
|
@ -173,6 +173,24 @@ void SGOLD2::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
|||
const auto & part_blocks = part_info.get_blocks();
|
||||
|
||||
if (part_name.find("FFS") != std::string::npos) {
|
||||
if (parts_to_extract.size() != 0) {
|
||||
bool is_extract = false;
|
||||
|
||||
for (const auto &part_to_extract : parts_to_extract) {
|
||||
if (part_name == part_to_extract) {
|
||||
is_extract = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_extract) {
|
||||
Log::Logger::warn("Partition {} excluded", part_name);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size());
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ SGOLD2_ELKA::SGOLD2_ELKA(Partitions::Partitions::Ptr partitions) : partitions(pa
|
|||
root_dir = Directory::build(ROOT_NAME, "/");
|
||||
}
|
||||
|
||||
void SGOLD2_ELKA::load(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data);
|
||||
void SGOLD2_ELKA::load(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
parse_FIT(skip_broken, skip_dup, dump_data, parts_to_extract);
|
||||
}
|
||||
|
||||
const Directory::Ptr SGOLD2_ELKA::get_root() const {
|
||||
|
|
@ -162,7 +162,7 @@ void SGOLD2_ELKA::print_data(const FFSBlock &block) {
|
|||
}
|
||||
}
|
||||
|
||||
void SGOLD2_ELKA::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
||||
void SGOLD2_ELKA::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data, std::vector<std::string> parts_to_extract) {
|
||||
const auto &part_map = partitions->get_partitions();
|
||||
|
||||
// auto check_header = [](const FITHeader &header, uint32_t block_size) -> bool {
|
||||
|
|
@ -210,6 +210,24 @@ void SGOLD2_ELKA::parse_FIT(bool skip_broken, bool skip_dup, bool dump_data) {
|
|||
const auto & part_blocks = part_info.get_blocks();
|
||||
|
||||
if (part_name.find("FFS") != std::string::npos) {
|
||||
if (parts_to_extract.size() != 0) {
|
||||
bool is_extract = false;
|
||||
|
||||
for (const auto &part_to_extract : parts_to_extract) {
|
||||
if (part_name == part_to_extract) {
|
||||
is_extract = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_extract) {
|
||||
Log::Logger::warn("Partition {} excluded", part_name);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Log::Logger::debug("Partition: {}, Blocks {}", part_name, part_blocks.size());
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue