Skip to content

Commit

Permalink
FW ver. detection :
Browse files Browse the repository at this point in the history
- Removed: detection from journal & play report (doesn't work well for downgraded NAND)
- Added: from GUI, will retry fw detection whith updated nca DB (from eliboa.com) when fw isn't detected in NxStorage init
  • Loading branch information
eliboa committed Jan 27, 2022
1 parent 27a2884 commit fe1ec33
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
13 changes: 7 additions & 6 deletions NxNandManager/NxStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ void NxStorage::setStorageInfo(int partition)
while (cur_off < max_off && nxHandle->read(cur_off, buff, &bytesRead, CLUSTER_SIZE))
{
std::string haystack(buff, buff + CLUSTER_SIZE);
/*
// Find needle (firmware version) in haystack
std::size_t n = haystack.find("OsVersion");
if (n != std::string::npos)
Expand All @@ -835,16 +836,16 @@ void NxStorage::setStorageInfo(int partition)
}
}
}

*/
// Find needle (serial number) in haystack
n = haystack.find("\xACSerialNumber");
std::size_t n = haystack.find("\xACSerialNumber");
if (!strlen(serial_number) && n != std::string::npos)
strcpy(serial_number, haystack.substr(n + 14, 14).c_str());

cur_off += bytesRead;
}
}

/*
// Read play report => /save/80000000000000a1 --> Let's just assume file is not fragmented in SYSTEM (TODO : Scan FAT for fragmentation)
if (cur_part->fat32_dir(&dir_entries, "/save/80000000000000a1"))
{
Expand Down Expand Up @@ -878,11 +879,11 @@ void NxStorage::setStorageInfo(int partition)
cur_off += bytesRead;
}
}

*/
// overwrite fw version if value found in journal/play report is greater than fw version in
// package1ldr (trick for downgraded NAND, only works for FULL NAND)
if(firmware_version_boot0.major > 0 && firmware_version_boot0.major < firmware_version.major)
firmware_version = firmware_version_boot0;
//if(firmware_version_boot0.major > 0 && firmware_version_boot0.major < firmware_version.major)
// firmware_version = firmware_version_boot0;
}
}

Expand Down
38 changes: 36 additions & 2 deletions NxNandManager/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,42 @@ void MainWindow::inputSet(NxStorage *storage)
ui->fwversion_value->setStatusTip("Error while decrypting content, wrong keys ? (CTRL+K to configure keyset)");
}
else {
ui->fwversion_value->setText("KEYSET NEEDED!");
ui->fwversion_value->setStatusTip("Unable to decrypt content (CTRL+K to configure keyset)");

bool search = false;
if (!m_ncaDB->is_Empty())
{
// Look for firmware version in NCA DB (async)
search = true;
QFuture<void> future = QtConcurrent::run([&]() {
auto system = input->getNxPartition(SYSTEM);
bool found = false;
if (system->mount_fs() == SUCCESS)
{
for (auto t : m_ncaDB->findTitlesById("0100000000000809")) //SystemVersion
{
auto file = NxFile(system, wstring(L"/Contents/registered/").append(t->filename.toStdWString()));
if (file.exists()) {
ui->fwversion_value->setText(t->firmware);
found = true;
break;
}
}
}
if (!found) {
ui->fwversion_value->setText("NOT FOUND!");
ui->fwversion_value->setStatusTip("Unable to found fw version");
}
});

}

if (!search)
{
ui->fwversion_value->setText("NOT FOUND!");
ui->fwversion_value->setStatusTip("Unable to found fw version (CTRL+K to configure keyset)");
}
else ui->fwversion_value->setText("Searching...");

}
}
else ui->fwversion_value->setText("N/A");
Expand Down

1 comment on commit fe1ec33

@eliboa
Copy link
Owner Author

@eliboa eliboa commented on fe1ec33 Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #73

Please sign in to comment.