diff --git a/NxNandManager/NxStorage.cpp b/NxNandManager/NxStorage.cpp index e2fdba37..277571fe 100644 --- a/NxNandManager/NxStorage.cpp +++ b/NxNandManager/NxStorage.cpp @@ -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) @@ -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")) { @@ -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; } } diff --git a/NxNandManager/gui/mainwindow.cpp b/NxNandManager/gui/mainwindow.cpp index 78e1e271..6a303eeb 100644 --- a/NxNandManager/gui/mainwindow.cpp +++ b/NxNandManager/gui/mainwindow.cpp @@ -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 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");