-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WiiSave: (not so) Minor cleanup #6836
Conversation
Source/Core/Core/HW/WiiSave.h
Outdated
CWiiSaveCrypted(const std::string& filename, u64 title_id = 0); | ||
~CWiiSaveCrypted(); | ||
WiiSave(); | ||
WiiSave(const std::string& filename); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/HW/WiiSave.cpp
Outdated
mbedtls_aes_setkey_dec(&m_aes_ctx, s_sd_key, 128); | ||
WiiSave::WiiSave(const std::string& filename) : WiiSave() | ||
{ | ||
m_encrypted_save_path = filename; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/HW/WiiSave.cpp
Outdated
CWiiSaveCrypted export_save("", title_id); | ||
if (export_save.m_valid) | ||
WiiSave export_save{title_id}; | ||
if (export_save.Export()) | ||
{ | ||
SuccessAlertT("Successfully exported file to %s", export_save.m_encrypted_save_path.c_str()); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/HW/WiiSave.cpp
Outdated
success++; | ||
} | ||
SuccessAlertT("Successfully exported %u save(s) to %s", success, | ||
(File::GetUserPath(D_USER_IDX) + "private/wii/title/").c_str()); | ||
} | ||
|
||
CWiiSaveCrypted::CWiiSaveCrypted(const std::string& filename, u64 title_id) | ||
: m_encrypted_save_path(filename), m_title_id(title_id) | ||
WiiSave::WiiSave() | ||
{ | ||
memcpy(m_sd_iv, "\x21\x67\x12\xE6\xAA\x1F\x68\x9F\x95\xC5\xA2\x23\x24\xDC\x6A\x98", 0x10); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Source/Core/Core/HW/WiiSave.cpp
Outdated
const u32 CWiiSaveCrypted::s_ng_id = 0x0403AC68; | ||
constexpr u8 s_sd_key[16] = {0xAB, 0x01, 0xB9, 0xD8, 0xE1, 0x62, 0x2B, 0x08, | ||
0xAF, 0xBA, 0xD8, 0x4D, 0xBF, 0xC2, 0xA5, 0x5D}; | ||
constexpr u8 s_md5_blanker[16] = {0x0E, 0x65, 0x37, 0x81, 0x99, 0xBE, 0x45, 0x17, |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
2d5ce0e
to
11bf528
Compare
5ab7fe8
to
7336ab6
Compare
Just wondering, should |
Source/Core/DolphinQt2/MenuBar.cpp
Outdated
CWiiSaveCrypted::ExportAllSaves(); | ||
const std::pair<size_t, std::string> result = WiiSave::ExportAll(); | ||
QMessageBox::information(this, tr("Save Export"), | ||
tr("Exported %n save(s) to %1", "", static_cast<int>(result.first)) |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
@BhaaLseN edit: ended up changing it
|
42fc23d
to
24754e5
Compare
Gets rid of the need to manually cast when reading/writing, which is error prone and repetitive.
Move the import/export operation into separate functions, as it doesn't really make sense for the constructor to do *everything*, including printing success/failure message boxes. The existing constructor was split into two: one that takes a path, and another taking a title ID. This makes it more obvious what is actually done when a path/TID is passed and also clarifies what parameters should be passed. (No more magic 0 or "" value.)
This moves the result dialogs to DolphinQt2, since WiiSave should not really be responsible for interacting with the user as a simple Wii save importing/exporting class. This also fixes Wii save import/export showing result dialogs twice, once from WiiSave, and another time from DolphinQt2.
Makes copying, comparing more readable
Export and ExportAll now open a directory picker (that defaults to the previous default directory, i.e. the Dolphin user dir). Also removes the need to return the path in the export functions since the user knows which path they chose.
24754e5
to
80b3d7c
Compare
Naming fixes: get rid of the legacy "C" prefix and "Crypted" suffix -- we got rid of it for VolumeWiiCrypted a while ago. Also fix all of the struct names (including members).
Don't expose constants and keys that don't have to be.
Remove most of the swaps that were visually polluting the code read/write logic by using Common::BigEndianValue. This is more readable and much less error prone as it becomes impossible to accidentally forget to swap endianness somewhere.
Remove an unused, dummy Extract member function.
Clean up constructor and static functions:
Move the import/export operation into separate functions, as it doesn't really make sense for the constructor to do everything, even things like printing success/failure message boxes.
The existing constructor was split into two: one that takes a path, and another taking a title ID. This makes it more obvious what is actually done when a path/TID is passed. This also makes it clear what parameters should be passed. (No more magic 0 or "" value.)
There's still a significant amount of duplicated code (for instance, the title listing function should be using ES::GetInstalledTitles, the crypto stuff ES::Sign, etc.). I'll address these issues in a followup PR.