mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-03 16:49:04 +00:00
build system updates and other fixes
add preset config import qt separate core and frontend
This commit is contained in:
+15
-13
@@ -1,14 +1,16 @@
|
||||
target_sources(threeSD PRIVATE
|
||||
core/data_container.cpp
|
||||
core/data_container.h
|
||||
core/decryptor.cpp
|
||||
core/decryptor.h
|
||||
core/importer.cpp
|
||||
core/importer.h
|
||||
core/inner_fat.cpp
|
||||
core/inner_fat.h
|
||||
core/key/arithmetic128.cpp
|
||||
core/key/arithmetic128.h
|
||||
core/key/key.cpp
|
||||
core/key/key.h
|
||||
add_library(core STATIC
|
||||
data_container.cpp
|
||||
data_container.h
|
||||
decryptor.cpp
|
||||
decryptor.h
|
||||
importer.cpp
|
||||
importer.h
|
||||
inner_fat.cpp
|
||||
inner_fat.h
|
||||
key/arithmetic128.cpp
|
||||
key/arithmetic128.h
|
||||
key/key.cpp
|
||||
key/key.h
|
||||
)
|
||||
|
||||
target_link_libraries(core PRIVATE common cryptopp)
|
||||
|
||||
+74
-1
@@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <regex>
|
||||
#include "common/assert.h"
|
||||
#include "common/common_paths.h"
|
||||
#include "common/file_util.h"
|
||||
@@ -17,7 +18,7 @@ SDMCImporter::SDMCImporter(const Config& config_) : config(config_) {
|
||||
SDMCImporter::~SDMCImporter() = default;
|
||||
|
||||
bool SDMCImporter::Init() {
|
||||
ASSERT_MSG(config.is_good && !config.sdmc_path.empty() && !config.user_path.empty() &&
|
||||
ASSERT_MSG(!config.sdmc_path.empty() && !config.user_path.empty() &&
|
||||
!config.bootrom_path.empty() && !config.movable_sed_path.empty(),
|
||||
"Config is not good");
|
||||
|
||||
@@ -245,3 +246,75 @@ void SDMCImporter::ListSysdata(std::vector<ContentSpecifier>& out) const {
|
||||
|
||||
#undef CHECK_CONTENT
|
||||
}
|
||||
|
||||
std::vector<Config> LoadPresetConfig(std::string mount_point) {
|
||||
if (mount_point.back() != '/' && mount_point.back() != '\\') {
|
||||
mount_point += '/';
|
||||
}
|
||||
|
||||
// Not a Nintendo 3DS sd card at all
|
||||
if (!FileUtil::Exists(mount_point + "Nintendo 3DS/")) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Config config_template{};
|
||||
config_template.user_path = FileUtil::GetUserPath(FileUtil::UserPath::UserDir);
|
||||
|
||||
// Load dumped data paths if using our dumper
|
||||
if (FileUtil::Exists(mount_point + "threeSD/")) {
|
||||
#define LOAD_DATA(var, path) \
|
||||
if (FileUtil::Exists(mount_point + "threeSD/" + path)) { \
|
||||
config_template.var = mount_point + "threeSD/" + path; \
|
||||
}
|
||||
|
||||
LOAD_DATA(movable_sed_path, MOVABLE_SED);
|
||||
LOAD_DATA(bootrom_path, BOOTROM9);
|
||||
LOAD_DATA(safe_mode_firm_path, "firm/");
|
||||
LOAD_DATA(seed_db_path, SEED_DB);
|
||||
LOAD_DATA(secret_sector_path, SECRET_SECTOR);
|
||||
#undef LOAD_DATA
|
||||
}
|
||||
|
||||
// Regex for 3DS ID0 and ID1
|
||||
const std::regex id_regex{"[0-9a-f]{32}"};
|
||||
|
||||
// Load SDMC dir
|
||||
std::vector<Config> out;
|
||||
const auto ProcessDirectory = [&id_regex, &config_template, &out](const std::string& path) {
|
||||
return FileUtil::ForeachDirectoryEntry(
|
||||
nullptr, path,
|
||||
[&id_regex, &config_template, &out](u64* /*num_entries_out*/,
|
||||
const std::string& directory,
|
||||
const std::string& virtual_name) {
|
||||
if (!FileUtil::IsDirectory(directory + virtual_name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!std::regex_match(virtual_name, id_regex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Config config = config_template;
|
||||
config.sdmc_path = directory + virtual_name + "/";
|
||||
out.push_back(config);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
FileUtil::ForeachDirectoryEntry(
|
||||
nullptr, mount_point + "Nintendo 3DS/",
|
||||
[&id_regex, &ProcessDirectory](u64* /*num_entries_out*/, const std::string& directory,
|
||||
const std::string& virtual_name) {
|
||||
if (!FileUtil::IsDirectory(directory + virtual_name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!std::regex_match(virtual_name, id_regex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return ProcessDirectory(directory + virtual_name);
|
||||
});
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
+6
-3
@@ -51,9 +51,6 @@ struct Config {
|
||||
std::string safe_mode_firm_path; ///< Path to safe mode firm (A folder) (Sysdata 1)
|
||||
std::string seed_db_path; ///< Path to seeddb.bin (Sysdata 2)
|
||||
std::string secret_sector_path; ///< Path to secret sector (New3DS only) (Sysdata 3)
|
||||
|
||||
// Whether this config has all necessary information
|
||||
bool is_good;
|
||||
};
|
||||
|
||||
class SDMCImporter {
|
||||
@@ -96,3 +93,9 @@ private:
|
||||
Config config;
|
||||
std::unique_ptr<SDMCDecryptor> decryptor;
|
||||
};
|
||||
|
||||
/**
|
||||
* Look for and load preset config for a SD card mounted at mount_point.
|
||||
* @return a list of preset config available. can be empty
|
||||
*/
|
||||
std::vector<Config> LoadPresetConfig(std::string mount_point);
|
||||
|
||||
@@ -31,7 +31,8 @@ struct KeyDesc {
|
||||
bool same_as_before;
|
||||
};
|
||||
|
||||
AESKey HexToKey(const std::string& hex) {
|
||||
// TODO: Use this to support manual input of keys
|
||||
[[maybe_unused]] AESKey HexToKey(const std::string& hex) {
|
||||
if (hex.size() < 32) {
|
||||
throw std::invalid_argument("hex string is too short");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user