mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-04 00:38:47 +00:00
Add checks for TMD and Ticket
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <QPixmap>
|
||||
#include <fmt/format.h>
|
||||
#include "common/string_util.h"
|
||||
#include "core/db/title_db.h"
|
||||
#include "core/file_sys/ncch_container.h"
|
||||
#include "core/file_sys/title_metadata.h"
|
||||
#include "core/importer.h"
|
||||
@@ -23,16 +24,15 @@ TitleInfoDialog::TitleInfoDialog(QWidget* parent, const Core::Config& config,
|
||||
const double scale = qApp->desktop()->logicalDpiX() / 96.0;
|
||||
resize(static_cast<int>(width() * scale), static_cast<int>(height() * scale));
|
||||
|
||||
InitializeInfo(config, importer, specifier);
|
||||
InitializeLanguageComboBox();
|
||||
LoadInfo(config, importer, specifier);
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &TitleInfoDialog::accept);
|
||||
}
|
||||
|
||||
TitleInfoDialog::~TitleInfoDialog() = default;
|
||||
|
||||
void TitleInfoDialog::InitializeInfo(const Core::Config& config, Core::SDMCImporter& importer,
|
||||
const Core::ContentSpecifier& specifier) {
|
||||
void TitleInfoDialog::LoadInfo(const Core::Config& config, Core::SDMCImporter& importer,
|
||||
const Core::ContentSpecifier& specifier) {
|
||||
Core::TitleMetadata tmd;
|
||||
if (!importer.LoadTMD(specifier, tmd)) {
|
||||
QMessageBox::warning(this, tr("threeSD"), tr("Could not load title information."));
|
||||
@@ -80,6 +80,27 @@ void TitleInfoDialog::InitializeInfo(const Core::Config& config, Core::SDMCImpor
|
||||
}
|
||||
ui->encryptionLineEdit->setText(encryption_text);
|
||||
|
||||
// Checks
|
||||
const bool tmd_legit = tmd.ValidateSignature() && tmd.VerifyHashes();
|
||||
if (tmd_legit) {
|
||||
ui->tmdCheckLabel->setText(tr("Legit"));
|
||||
} else {
|
||||
ui->tmdCheckLabel->setText(tr("Illegit"));
|
||||
}
|
||||
|
||||
if (const auto& ticket_db = importer.GetTicketDB();
|
||||
ticket_db && ticket_db->tickets.count(specifier.id)) {
|
||||
|
||||
const bool ticket_legit = ticket_db->tickets.at(specifier.id).ValidateSignature();
|
||||
if (ticket_legit) {
|
||||
ui->ticketCheckLabel->setText(tr("Legit"));
|
||||
} else {
|
||||
ui->ticketCheckLabel->setText(tr("Illegit"));
|
||||
}
|
||||
} else {
|
||||
ui->ticketCheckLabel->setText(tr("Missing"));
|
||||
}
|
||||
|
||||
// Load SMDH
|
||||
std::vector<u8> smdh_buffer;
|
||||
if (!ncch.LoadSectionExeFS("icon", smdh_buffer) || smdh_buffer.size() != sizeof(Core::SMDH) ||
|
||||
@@ -98,6 +119,8 @@ void TitleInfoDialog::InitializeInfo(const Core::Config& config, Core::SDMCImpor
|
||||
ui->iconSmallLabel->setPixmap(
|
||||
QPixmap::fromImage(QImage(reinterpret_cast<const uchar*>(smdh.GetIcon(false).data()), 24,
|
||||
24, QImage::Format::Format_RGB16)));
|
||||
// Load names
|
||||
InitializeLanguageComboBox();
|
||||
}
|
||||
|
||||
void TitleInfoDialog::InitializeLanguageComboBox() {
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Core {
|
||||
class Config;
|
||||
class ContentSpecifier;
|
||||
class SDMCImporter;
|
||||
class TitleMetadata;
|
||||
} // namespace Core
|
||||
|
||||
namespace Ui {
|
||||
@@ -25,8 +26,8 @@ public:
|
||||
~TitleInfoDialog();
|
||||
|
||||
private:
|
||||
void InitializeInfo(const Core::Config& config, Core::SDMCImporter& importer,
|
||||
const Core::ContentSpecifier& specifier);
|
||||
void LoadInfo(const Core::Config& config, Core::SDMCImporter& importer,
|
||||
const Core::ContentSpecifier& specifier);
|
||||
void InitializeLanguageComboBox();
|
||||
void UpdateNames();
|
||||
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="versionLineEdit"/>
|
||||
<widget class="QLineEdit" name="versionLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="2">
|
||||
<widget class="QLabel" name="iconLargeLabel">
|
||||
@@ -58,7 +62,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="encryptionLineEdit"/>
|
||||
<widget class="QLineEdit" name="encryptionLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel">
|
||||
@@ -68,7 +76,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="titleIDLineEdit"/>
|
||||
<widget class="QLineEdit" name="titleIDLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -87,7 +99,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="shortTitleLineEdit"/>
|
||||
<widget class="QLineEdit" name="shortTitleLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="languageComboBox"/>
|
||||
@@ -100,7 +116,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="longTitleLineEdit"/>
|
||||
<widget class="QLineEdit" name="longTitleLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel">
|
||||
@@ -110,7 +130,11 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="publisherLineEdit"/>
|
||||
<widget class="QLineEdit" name="publisherLineEdit">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user