Update FsHeader
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone Build is passing

This commit is contained in:
Dmitry Isaenko 2022-09-05 00:29:43 +03:00
parent 27b7ba5e7f
commit 3634a8c98d
16 changed files with 3095 additions and 2025 deletions

20
pom.xml
View file

@ -141,10 +141,28 @@
<dependency>
<groupId>ru.redrise</groupId>
<artifactId>libKonogonka</artifactId>
<version>0.1</version>
<version>0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<!-- Consider removing
<dependency>
<groupId>org.hamcrest</groupId>

View file

@ -34,13 +34,13 @@ import java.net.URL;
import java.util.HashMap;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.Converter.byteArrToHexString;
public class NCAController implements ITabController {
private File selectedFile;
@FXML
private NCASectionHeaderBlockController
private NCAFsHeaderController
NCASectionHeaderFirstController,
NCASectionHeaderSecondController,
NCASectionHeaderThirdController,
@ -179,7 +179,7 @@ public class NCAController implements ITabController {
NCASectionContentFourthController.resetTab();
}
private void populateFields(NCAProvider ncaProvider){
private void populateFields(NCAProvider ncaProvider) {
if (ncaProvider == null)
return;
rsa2048oneTF.setText(byteArrToHexString(ncaProvider.getRsa2048one()));
@ -224,17 +224,27 @@ public class NCAController implements ITabController {
NCASectionHeaderThirdController.populateTab(ncaProvider.getSectionBlock2());
NCASectionHeaderFourthController.populateTab(ncaProvider.getSectionBlock3());
// Section content blocks
NCASectionContentFirstController.populateFields(
ncaProvider.getNCAContentProvider(0),
getNcaContent(ncaProvider, 0),
0);
NCASectionContentSecondController.populateFields(
ncaProvider.getNCAContentProvider(1),
getNcaContent(ncaProvider, 1),
1);
NCASectionContentThirdController.populateFields(
ncaProvider.getNCAContentProvider(2),
getNcaContent(ncaProvider, 2),
2);
NCASectionContentFourthController.populateFields(
ncaProvider.getNCAContentProvider(3),
getNcaContent(ncaProvider, 3),
3);
}
private NCAContent getNcaContent(NCAProvider provider, int i){
try{
return provider.getNCAContentProvider(i);
}
catch (Exception e){
e.printStackTrace();
}
return null;
}
}

View file

@ -0,0 +1,385 @@
/*
Copyright 2019-2022 Dmitry Isaenko
This file is part of Konogonka.
Konogonka is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Konogonka is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Konogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package konogonka.Controllers.NCA;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import libKonogonka.Tools.NCA.NCASectionTableBlock.CompressionInfo;
import libKonogonka.Tools.NCA.NCASectionTableBlock.MetaDataHashDataInfo;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NcaFsHeader;
import libKonogonka.Tools.NCA.NCASectionTableBlock.SparseInfo;
import static libKonogonka.Converter.byteArrToHexString;
public class NCAFsHeaderController {
@FXML
private Label
versionLbl,
fsTypeLbl,
hashTypeLbl,
cryptoTypeLbl,
metaDataHashTypeLbl,
paddingLbl;
@FXML
private TitledPane
romFsTitlePanel,
pfs0TitlePanel;
// PFS0Provider
@FXML
private Label
pfs0blockSizeLbl,
pfs0LayerCountLbl,
pfs0hashTableOffsetLbl,
pfs0hashTableSizeLbl,
pfs0relativeToSectionStartOffsetLbl,
pfs0sizePfs0Lbl,
sparseInfoTableOffsetLbl,
sparseInfoTableSizeLbl,
sparseInfoMagicLbl,
sparseInfoVersionLbl,
sparseInfoEntryCountLbl,
sparseInfoUnknownLbl,
sparseInfoPhysicalOffsetLbl,
sparseInfoGenerationLbl,
sparseInfoReseredLbl,
compressionInfoTableOffsetLbl,
compressionInfoTableSizeLbl,
compressionMagicLbl,
compressionInfoVersionLbl,
compressionInfoEntryCountLbl,
compressionInfoUnknownLbl,
compressionInfoReservedLbl,
metaDataHashDataTableOffsetLbl,
metaDataHashDataTableSizeLbl,
metaDataHashDataTableHashLbl;
@FXML
private TextField
pfs0SHA256hashTf,
pfs0zeroesTf;
// RomFS (IVFC)
@FXML
private Label
romFsMagicLbl,
romFsMagicNumberLbl,
romFsMasterHashSizeLbl,
romFsTotalNumberOfLevelsLbl,
romFsLvl1OffsetLbl,
romFsLvl1SizeLbl,
romFsLvl1SBlockSizeLbl,
romFsReserved1Lbl,
romFsLvl2OffsetLbl,
romFsLvl2SizeLbl,
romFsLvl2SBlockSizeLbl,
romFsReserved2Lbl,
romFsLvl3OffsetLbl,
romFsLvl3SizeLbl,
romFsLvl3SBlockSizeLbl,
romFsReserved3Lbl,
romFsLvl4OffsetLbl,
romFsLvl4SizeLbl,
romFsLvl4SBlockSizeLbl,
romFsReserved4Lbl,
romFsLvl5OffsetLbl,
romFsLvl5SizeLbl,
romFsLvl5SBlockSizeLbl,
romFsReserved5Lbl,
romFsLvl6OffsetLbl,
romFsLvl6SizeLbl,
romFsLvl6SBlockSizeLbl,
romFsReserved6Lbl,
romFsReservedTailLbl;
@FXML
private TextField
signatureSaltTf,
romFsMasterHashTf,
unknwnEndPaddingTF;
@FXML
private Label
indirectOffsetLbl,
indirectSizeLbl,
indirectInfoMagicLbl,
indirectInfoVersionLbl,
indirectInfoEntryCountLbl,
indirectInfoUnknownLbl,
aesCtrExOffsetLbl,
aesCtrExSizeLbl,
aesCtrExMagicLbl,
aesCtrExVersionLbl,
aesCtrExEntryCountLbl,
aesCtrExUnknownLbl,
sectionCTRLbl,
generationLbl;
public void resetTab() {
versionLbl.setText("-");
fsTypeLbl.setText("-");
hashTypeLbl.setText("-");
cryptoTypeLbl.setText("-");
metaDataHashTypeLbl.setText("-");
paddingLbl.setText("-");
romFsTitlePanel.setDisable(false);
romFsTitlePanel.setExpanded(false);
pfs0TitlePanel.setDisable(false);
pfs0TitlePanel.setExpanded(false);
//RomFS
romFsMagicLbl.setText("-");
romFsMagicNumberLbl.setText("-");
romFsMasterHashSizeLbl.setText("-");
romFsTotalNumberOfLevelsLbl.setText("-");
romFsLvl1OffsetLbl.setText("-");
romFsLvl1SizeLbl.setText("-");
romFsLvl1SBlockSizeLbl.setText("-");
romFsReserved1Lbl.setText("-");
romFsLvl2OffsetLbl.setText("-");
romFsLvl2SizeLbl.setText("-");
romFsLvl2SBlockSizeLbl.setText("-");
romFsReserved2Lbl.setText("-");
romFsLvl3OffsetLbl.setText("-");
romFsLvl3SizeLbl.setText("-");
romFsLvl3SBlockSizeLbl.setText("-");
romFsReserved3Lbl.setText("-");
romFsLvl4OffsetLbl.setText("-");
romFsLvl4SizeLbl.setText("-");
romFsLvl4SBlockSizeLbl.setText("-");
romFsReserved4Lbl.setText("-");
romFsLvl5OffsetLbl.setText("-");
romFsLvl5SizeLbl.setText("-");
romFsLvl5SBlockSizeLbl.setText("-");
romFsReserved5Lbl.setText("-");
romFsLvl6OffsetLbl.setText("-");
romFsLvl6SizeLbl.setText("-");
romFsLvl6SBlockSizeLbl.setText("-");
romFsReserved6Lbl.setText("-");
signatureSaltTf.setText("-");
romFsMasterHashTf.setText("-");
romFsReservedTailLbl.setText("-");
// PFS0Provider
pfs0SHA256hashTf.setText("-");
pfs0blockSizeLbl.setText("-");
pfs0LayerCountLbl.setText("-");
pfs0hashTableOffsetLbl.setText("-");
pfs0hashTableSizeLbl.setText("-");
pfs0relativeToSectionStartOffsetLbl.setText("-");
pfs0sizePfs0Lbl.setText("-");
pfs0zeroesTf.setText("-");
indirectOffsetLbl.setText("-");
indirectSizeLbl.setText("-");
indirectInfoMagicLbl.setText("-");
indirectInfoVersionLbl.setText("-");
indirectInfoEntryCountLbl.setText("-");
indirectInfoUnknownLbl.setText("-");
aesCtrExOffsetLbl.setText("-");
aesCtrExSizeLbl.setText("-");
aesCtrExMagicLbl.setText("-");
aesCtrExVersionLbl.setText("-");
aesCtrExEntryCountLbl.setText("-");
aesCtrExUnknownLbl.setText("-");
sectionCTRLbl.setText("-");
generationLbl.setText("-");
unknwnEndPaddingTF.setText("-");
sparseInfoTableOffsetLbl.setText("-");
sparseInfoTableSizeLbl.setText("-");
sparseInfoMagicLbl.setText("-");
sparseInfoVersionLbl.setText("-");
sparseInfoEntryCountLbl.setText("-");
sparseInfoUnknownLbl.setText("-");
sparseInfoPhysicalOffsetLbl.setText("-");
sparseInfoGenerationLbl.setText("-");
sparseInfoReseredLbl.setText("-");
compressionInfoTableOffsetLbl.setText("-");
compressionInfoTableSizeLbl.setText("-");
compressionMagicLbl.setText("-");
compressionInfoVersionLbl.setText("-");
compressionInfoEntryCountLbl.setText("-");
compressionInfoUnknownLbl.setText("-");
compressionInfoReservedLbl.setText("-");
metaDataHashDataTableOffsetLbl.setText("-");
metaDataHashDataTableSizeLbl.setText("-");
metaDataHashDataTableHashLbl.setText("-");
}
public void populateTab(NcaFsHeader ncaFsHeader){
versionLbl.setText(byteArrToHexString(ncaFsHeader.getVersion()));
StringBuilder sb = new StringBuilder();
sb.append(String.format("0x%02x ", ncaFsHeader.getFsType()));
if (ncaFsHeader.getFsType() == 0)
sb.append("(RomFS)");
else if (ncaFsHeader.getFsType() == 1)
sb.append("(PFS0)");
fsTypeLbl.setText(sb.toString());
sb = new StringBuilder();
sb.append(String.format("0x%02x ", ncaFsHeader.getHashType()));
if (ncaFsHeader.getHashType() == 0x3)
sb.append("(RomFS)");
else if (ncaFsHeader.getHashType() == 0x2)
sb.append("(PFS0)");
hashTypeLbl.setText(sb.toString());
switch (ncaFsHeader.getCryptoType()){
case 0: cryptoTypeLbl.setText(String.format("%02x - Auto", ncaFsHeader.getCryptoType()));;
break;
case 1: cryptoTypeLbl.setText(String.format("%02x - None", ncaFsHeader.getCryptoType()));;
break;
case 2: cryptoTypeLbl.setText(String.format("%02x - AesXts", ncaFsHeader.getCryptoType()));
break;
case 3: cryptoTypeLbl.setText(String.format("%02x - AesCtr", ncaFsHeader.getCryptoType()));
break;
case 4: cryptoTypeLbl.setText(String.format("%02x - AesCtrEx", ncaFsHeader.getCryptoType()));
break;
case 5: cryptoTypeLbl.setText(String.format("%02x - AesCtrSkipLayerHash", ncaFsHeader.getCryptoType()));
break;
case 6: cryptoTypeLbl.setText(String.format("%02x - AesCtrExSkipLayerHash", ncaFsHeader.getCryptoType()));
break;
default: cryptoTypeLbl.setText(String.format("%02x", ncaFsHeader.getCryptoType()));
}
switch (ncaFsHeader.getMetaDataHashType()){
case 0:
metaDataHashTypeLbl.setText(String.format("%d - None", ncaFsHeader.getMetaDataHashType()));
break;
case 1:
metaDataHashTypeLbl.setText(String.format("%d - HierarchicalIntegrity", ncaFsHeader.getMetaDataHashType()));
break;
default:
metaDataHashTypeLbl.setText(String.format("%d", ncaFsHeader.getMetaDataHashType()));
}
paddingLbl.setText(byteArrToHexString(ncaFsHeader.getPadding()));
if ((ncaFsHeader.getFsType() == 0) && (ncaFsHeader.getHashType() == 0x3)){
romFsMagicLbl.setText(ncaFsHeader.getSuperBlockIVFC().getMagic());
romFsMagicNumberLbl.setText(ncaFsHeader.getSuperBlockIVFC().getMagic()
+(!ncaFsHeader.getSuperBlockIVFC().getMagic().matches("2")? " (OK)":" (wrong magic number)")); // TODO: TEST
romFsMasterHashSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getMasterHashSize()));
romFsTotalNumberOfLevelsLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getTotalNumberOfLevels()));
romFsLvl1OffsetLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl1Offset()));
romFsLvl1SizeLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl1Size()));
romFsLvl1SBlockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getLvl1SBlockSize()));
romFsReserved1Lbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReserved1()));
romFsLvl2OffsetLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl2Offset()));
romFsLvl2SizeLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl2Size()));
romFsLvl2SBlockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getLvl2SBlockSize()));
romFsReserved2Lbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReserved2()));
romFsLvl3OffsetLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl3Offset()));
romFsLvl3SizeLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl3Size()));
romFsLvl3SBlockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getLvl3SBlockSize()));
romFsReserved3Lbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReserved3()));
romFsLvl4OffsetLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl4Offset()));
romFsLvl4SizeLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl4Size()));
romFsLvl4SBlockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getLvl4SBlockSize()));
romFsReserved4Lbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReserved4()));
romFsLvl5OffsetLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl5Offset()));
romFsLvl5SizeLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl5Size()));
romFsLvl5SBlockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getLvl5SBlockSize()));
romFsReserved5Lbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReserved5()));
romFsLvl6OffsetLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl6Offset()));
romFsLvl6SizeLbl.setText(getCuteDecHexRepresentation(ncaFsHeader.getSuperBlockIVFC().getLvl6Size()));
romFsLvl6SBlockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockIVFC().getLvl6SBlockSize()));
romFsReserved6Lbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReserved6()));
signatureSaltTf.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getSignatureSalt()));
romFsMasterHashTf.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getMasterHash()));
romFsReservedTailLbl.setText(byteArrToHexString(ncaFsHeader.getSuperBlockIVFC().getReservedTail()));
pfs0TitlePanel.setDisable(true);
}
else if ((ncaFsHeader.getFsType() == 0x1) && (ncaFsHeader.getHashType() == 0x2)){
pfs0SHA256hashTf.setText(byteArrToHexString(ncaFsHeader.getSuperBlockPFS0().getSHA256hash()));
pfs0blockSizeLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockPFS0().getBlockSize()));
pfs0LayerCountLbl.setText(Integer.toString(ncaFsHeader.getSuperBlockPFS0().getLayerCount()));
pfs0hashTableOffsetLbl.setText(Long.toString(ncaFsHeader.getSuperBlockPFS0().getHashTableOffset()));
pfs0hashTableSizeLbl.setText(Long.toString(ncaFsHeader.getSuperBlockPFS0().getHashTableSize()));
pfs0relativeToSectionStartOffsetLbl.setText(Long.toString(ncaFsHeader.getSuperBlockPFS0().getPfs0offset()));
pfs0sizePfs0Lbl.setText(Long.toString(ncaFsHeader.getSuperBlockPFS0().getPfs0size()));
pfs0zeroesTf.setText(byteArrToHexString(ncaFsHeader.getSuperBlockPFS0().getZeroes()));
romFsTitlePanel.setDisable(true);
}
else {
pfs0TitlePanel.setDisable(true);
romFsTitlePanel.setDisable(true);
}
indirectOffsetLbl.setText(Long.toString(ncaFsHeader.getPatchInfoOffsetSection1()));
indirectSizeLbl.setText(Long.toString(ncaFsHeader.getPatchInfoSizeSection1()));
indirectInfoMagicLbl.setText(ncaFsHeader.getPatchInfoMagicSection1());
indirectInfoVersionLbl.setText(Long.toString(ncaFsHeader.getPatchInfoSizeSection1()));
indirectInfoEntryCountLbl.setText(Integer.toString(ncaFsHeader.getEntryCountSection1()));
indirectInfoUnknownLbl.setText(byteArrToHexString(ncaFsHeader.getPatchInfoUnknownSection1()));
aesCtrExOffsetLbl.setText(Long.toString(ncaFsHeader.getPatchInfoOffsetSection2()));
aesCtrExSizeLbl.setText(Long.toString(ncaFsHeader.getPatchInfoSizeSection2()));
aesCtrExMagicLbl.setText(ncaFsHeader.getPatchInfoMagicSection2());
aesCtrExVersionLbl.setText(Integer.toString(ncaFsHeader.getPatchInfoVersionSection2()));
aesCtrExEntryCountLbl.setText(Integer.toString(ncaFsHeader.getEntryCountSection2()));
aesCtrExUnknownLbl.setText(byteArrToHexString(ncaFsHeader.getPatchInfoUnknownSection2()));
sectionCTRLbl.setText(byteArrToHexString(ncaFsHeader.getSectionCTR()));
generationLbl.setText(byteArrToHexString(ncaFsHeader.getGeneration()));
SparseInfo sparseInfo = ncaFsHeader.getSparseInfo();
sparseInfoTableOffsetLbl.setText(Long.toString(sparseInfo.getOffset()));
sparseInfoTableSizeLbl.setText(Long.toString(sparseInfo.getSize()));
sparseInfoMagicLbl.setText(sparseInfo.getBktrMagic());
sparseInfoVersionLbl.setText(Long.toString(sparseInfo.getBktrVersion()));
sparseInfoEntryCountLbl.setText(Integer.toString(sparseInfo.getBktrEntryCount()));
sparseInfoUnknownLbl.setText(byteArrToHexString(sparseInfo.getBktrUnknown()));
sparseInfoPhysicalOffsetLbl.setText(Long.toString(sparseInfo.getPhysicalOffset()));
sparseInfoGenerationLbl.setText(byteArrToHexString(sparseInfo.getGeneration()));
sparseInfoReseredLbl.setText(byteArrToHexString(sparseInfo.getUnknown()));
CompressionInfo compressionInfo = ncaFsHeader.getCompressionInfo();
compressionInfoTableOffsetLbl.setText(Long.toString(compressionInfo.getOffset()));
compressionInfoTableSizeLbl.setText(Long.toString(compressionInfo.getSize()));
compressionMagicLbl.setText(compressionInfo.getBktrMagic());
compressionInfoVersionLbl.setText(Long.toString(compressionInfo.getBktrVersion()));
compressionInfoEntryCountLbl.setText(Integer.toString(compressionInfo.getBktrEntryCount()));
compressionInfoUnknownLbl.setText(byteArrToHexString(compressionInfo.getBktrUnknown()));
compressionInfoReservedLbl.setText(byteArrToHexString(compressionInfo.getUnknown()));
MetaDataHashDataInfo metaDataHashDataInfo = ncaFsHeader.getMetaDataHashDataInfo();
metaDataHashDataTableOffsetLbl.setText(Long.toString(metaDataHashDataInfo.getOffset()));
metaDataHashDataTableSizeLbl.setText(Long.toString(metaDataHashDataInfo.getSize()));
metaDataHashDataTableHashLbl.setText(byteArrToHexString(metaDataHashDataInfo.getTableHash()));
unknwnEndPaddingTF.setText(byteArrToHexString(ncaFsHeader.getUnknownEndPadding()));
}
private String getCuteDecHexRepresentation(long value){
return String.format("%d (0x%02x)", value, value);
}
}

View file

@ -28,7 +28,7 @@ import javafx.scene.layout.VBox;
import konogonka.AppPreferences;
import konogonka.Controllers.NSP.NSPController;
import konogonka.Controllers.RFS.RomFsController;
import libKonogonka.LoperConverter;
import libKonogonka.Converter;
import konogonka.MediatorControl;
import libKonogonka.Tools.NCA.NCAContent;
import konogonka.Workers.DumbNCA3ContentExtractor;
@ -89,7 +89,7 @@ public class NCASectionContentController implements Initializable {
for (int i = 0; i < sha256hashList.size(); i++){
Label numberLblTmp = new Label(String.format("%10d", i));
numberLblTmp.setPadding(new Insets(5.0, 5.0, 5.0, 5.0));
Label sha256LblTmp = new Label(LoperConverter.byteArrToHexString(sha256hashList.get(i)));
Label sha256LblTmp = new Label(Converter.byteArrToHexString(sha256hashList.get(i)));
sha256LblTmp.setPadding(new Insets(5.0, 5.0, 5.0, 5.0));
sha256pane.getChildren().add(new HBox(numberLblTmp, sha256LblTmp));

View file

@ -1,284 +0,0 @@
/*
Copyright 2019-2022 Dmitry Isaenko
This file is part of Konogonka.
Konogonka is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Konogonka is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Konogonka. If not, see <https://www.gnu.org/licenses/>.
*/
package konogonka.Controllers.NCA;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.TitledPane;
import libKonogonka.Tools.NCA.NCASectionTableBlock.NCASectionBlock;
import static libKonogonka.LoperConverter.byteArrToHexString;
public class NCASectionHeaderBlockController {
@FXML
private Label
versionLbl,
fsTypeLbl,
hashTypeLbl,
cryptoTypeLbl,
paddingLbl;
@FXML
private TextField
BKTRHeaderTf;
@FXML
private TitledPane
romFsTitlePanel,
pfs0TitlePanel;
// PFS0Provider
@FXML
private Label
pfs0blockSizeLbl,
pfs0unknownNumberTwoLbl,
pfs0hashTableOffsetLbl,
pfs0hashTableSizeLbl,
pfs0relativeToSectionStartOffsetLbl,
pfs0sizePfs0Lbl;
@FXML
private TextField
pfs0SHA256hashTf,
pfs0zeroesTf;
// RomFS (IVFC)
@FXML
private Label
romFsMagicLbl,
romFsMagicNumberLbl,
romFsMasterHashSizeLbl,
romFsTotalNumberOfLevelsLbl,
romFsLvl1OffsetLbl,
romFsLvl1SizeLbl,
romFsLvl1SBlockSizeLbl,
romFsReserved1Lbl,
romFsLvl2OffsetLbl,
romFsLvl2SizeLbl,
romFsLvl2SBlockSizeLbl,
romFsReserved2Lbl,
romFsLvl3OffsetLbl,
romFsLvl3SizeLbl,
romFsLvl3SBlockSizeLbl,
romFsReserved3Lbl,
romFsLvl4OffsetLbl,
romFsLvl4SizeLbl,
romFsLvl4SBlockSizeLbl,
romFsReserved4Lbl,
romFsLvl5OffsetLbl,
romFsLvl5SizeLbl,
romFsLvl5SBlockSizeLbl,
romFsReserved5Lbl,
romFsLvl6OffsetLbl,
romFsLvl6SizeLbl,
romFsLvl6SBlockSizeLbl,
romFsReserved6Lbl;
@FXML
private TextField
romFsUnknownTf,
romFsHashTf,
unknwnEndPaddingTF;
@FXML
private Label
BKTRoffsetSection1Lbl,
BKTRsizeSection1Lbl,
BKTRmagicSection1Lbl,
BKTRu32Section1Lbl,
BKTRs32Section1Lbl,
BKTRunknownSection1Lbl,
BKTRoffsetSection2Lbl,
BKTRsizeSection2Lbl,
BKTRmagicSection2Lbl,
BKTRu32Section2Lbl,
BKTRs32Section2Lbl,
BKTRunknownSection2Lbl,
sectionCTRLbl;
public void resetTab() {
versionLbl.setText("-");
fsTypeLbl.setText("-");
hashTypeLbl.setText("-");
cryptoTypeLbl.setText("-");
paddingLbl.setText("-");
romFsTitlePanel.setDisable(false);
romFsTitlePanel.setExpanded(false);
pfs0TitlePanel.setDisable(false);
pfs0TitlePanel.setExpanded(false);
//RomFS
romFsMagicLbl.setText("-");
romFsMagicNumberLbl.setText("-");
romFsMasterHashSizeLbl.setText("-");
romFsTotalNumberOfLevelsLbl.setText("-");
romFsLvl1OffsetLbl.setText("-");
romFsLvl1SizeLbl.setText("-");
romFsLvl1SBlockSizeLbl.setText("-");
romFsReserved1Lbl.setText("-");
romFsLvl2OffsetLbl.setText("-");
romFsLvl2SizeLbl.setText("-");
romFsLvl2SBlockSizeLbl.setText("-");
romFsReserved2Lbl.setText("-");
romFsLvl3OffsetLbl.setText("-");
romFsLvl3SizeLbl.setText("-");
romFsLvl3SBlockSizeLbl.setText("-");
romFsReserved3Lbl.setText("-");
romFsLvl4OffsetLbl.setText("-");
romFsLvl4SizeLbl.setText("-");
romFsLvl4SBlockSizeLbl.setText("-");
romFsReserved4Lbl.setText("-");
romFsLvl5OffsetLbl.setText("-");
romFsLvl5SizeLbl.setText("-");
romFsLvl5SBlockSizeLbl.setText("-");
romFsReserved5Lbl.setText("-");
romFsLvl6OffsetLbl.setText("-");
romFsLvl6SizeLbl.setText("-");
romFsLvl6SBlockSizeLbl.setText("-");
romFsReserved6Lbl.setText("-");
romFsUnknownTf.setText("-");
romFsHashTf.setText("-");
// PFS0Provider
pfs0SHA256hashTf.setText("-");
pfs0blockSizeLbl.setText("-");
pfs0unknownNumberTwoLbl.setText("-");
pfs0hashTableOffsetLbl.setText("-");
pfs0hashTableSizeLbl.setText("-");
pfs0relativeToSectionStartOffsetLbl.setText("-");
pfs0sizePfs0Lbl.setText("-");
pfs0zeroesTf.setText("-");
BKTRHeaderTf.setText("-");
BKTRoffsetSection1Lbl.setText("-");
BKTRsizeSection1Lbl.setText("-");
BKTRmagicSection1Lbl.setText("-");
BKTRu32Section1Lbl.setText("-");
BKTRs32Section1Lbl.setText("-");
BKTRunknownSection1Lbl.setText("-");
BKTRoffsetSection2Lbl.setText("-");
BKTRsizeSection2Lbl.setText("-");
BKTRmagicSection2Lbl.setText("-");
BKTRu32Section2Lbl.setText("-");
BKTRs32Section2Lbl.setText("-");
BKTRunknownSection2Lbl.setText("-");
sectionCTRLbl.setText("-");
unknwnEndPaddingTF.setText("-");
}
public void populateTab(NCASectionBlock ncaSectionBlock){
versionLbl.setText(byteArrToHexString(ncaSectionBlock.getVersion()));
StringBuilder sb = new StringBuilder();
sb.append(String.format("0x%02x ", ncaSectionBlock.getFsType()));
if (ncaSectionBlock.getFsType() == 0)
sb.append("(RomFS)");
else if (ncaSectionBlock.getFsType() == 1)
sb.append("(PFS0)");
fsTypeLbl.setText(sb.toString());
sb = new StringBuilder();
sb.append(String.format("0x%02x ", ncaSectionBlock.getHashType()));
if (ncaSectionBlock.getHashType() == 0x3)
sb.append("(RomFS)");
else if (ncaSectionBlock.getHashType() == 0x2)
sb.append("(PFS0)");
hashTypeLbl.setText(sb.toString());
cryptoTypeLbl.setText(String.format("%02x ", ncaSectionBlock.getCryptoType()));
paddingLbl.setText(byteArrToHexString(ncaSectionBlock.getPadding()));
if ((ncaSectionBlock.getFsType() == 0) && (ncaSectionBlock.getHashType() == 0x3)){
romFsMagicLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagic());
romFsMagicNumberLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagicNumber()
+(ncaSectionBlock.getSuperBlockIVFC().getMagicNumber() == 0x20000? " (OK)":" (wrong magic number)"));
romFsMasterHashSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getMasterHashSize()));
romFsTotalNumberOfLevelsLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getTotalNumberOfLevels()));
romFsLvl1OffsetLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl1Offset()));
romFsLvl1SizeLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl1Size()));
romFsLvl1SBlockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getLvl1SBlockSize()));
romFsReserved1Lbl.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getReserved1()));
romFsLvl2OffsetLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl2Offset()));
romFsLvl2SizeLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl2Size()));
romFsLvl2SBlockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getLvl2SBlockSize()));
romFsReserved2Lbl.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getReserved2()));
romFsLvl3OffsetLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl3Offset()));
romFsLvl3SizeLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl3Size()));
romFsLvl3SBlockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getLvl3SBlockSize()));
romFsReserved3Lbl.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getReserved3()));
romFsLvl4OffsetLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl4Offset()));
romFsLvl4SizeLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl4Size()));
romFsLvl4SBlockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getLvl4SBlockSize()));
romFsReserved4Lbl.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getReserved4()));
romFsLvl5OffsetLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl5Offset()));
romFsLvl5SizeLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl5Size()));
romFsLvl5SBlockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getLvl5SBlockSize()));
romFsReserved5Lbl.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getReserved5()));
romFsLvl6OffsetLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl6Offset()));
romFsLvl6SizeLbl.setText(getCuteDecHexRepresentation(ncaSectionBlock.getSuperBlockIVFC().getLvl6Size()));
romFsLvl6SBlockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockIVFC().getLvl6SBlockSize()));
romFsReserved6Lbl.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getReserved6()));
romFsUnknownTf.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getUnknown()));
romFsHashTf.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockIVFC().getHash()));
pfs0TitlePanel.setDisable(true);
}
else if ((ncaSectionBlock.getFsType() == 0x1) && (ncaSectionBlock.getHashType() == 0x2)){
pfs0SHA256hashTf.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockPFS0().getSHA256hash()));
pfs0blockSizeLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockPFS0().getBlockSize()));
pfs0unknownNumberTwoLbl.setText(Integer.toString(ncaSectionBlock.getSuperBlockPFS0().getUnknownNumberTwo()));
pfs0hashTableOffsetLbl.setText(Long.toString(ncaSectionBlock.getSuperBlockPFS0().getHashTableOffset()));
pfs0hashTableSizeLbl.setText(Long.toString(ncaSectionBlock.getSuperBlockPFS0().getHashTableSize()));
pfs0relativeToSectionStartOffsetLbl.setText(Long.toString(ncaSectionBlock.getSuperBlockPFS0().getPfs0offset()));
pfs0sizePfs0Lbl.setText(Long.toString(ncaSectionBlock.getSuperBlockPFS0().getPfs0size()));
pfs0zeroesTf.setText(byteArrToHexString(ncaSectionBlock.getSuperBlockPFS0().getZeroes()));
romFsTitlePanel.setDisable(true);
}
else {
pfs0TitlePanel.setDisable(true);
romFsTitlePanel.setDisable(true);
}
BKTRHeaderTf.setText(byteArrToHexString(ncaSectionBlock.getBKTRfullHeader()));
BKTRoffsetSection1Lbl.setText(Long.toString(ncaSectionBlock.getBKTRoffsetSection1()));
BKTRsizeSection1Lbl.setText(Long.toString(ncaSectionBlock.getBKTRsizeSection1()));
BKTRmagicSection1Lbl.setText(ncaSectionBlock.getBKTRmagicSection1());
BKTRu32Section1Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRu32Section1()));
BKTRs32Section1Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRs32Section1()));
BKTRunknownSection1Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknownSection1()));
BKTRoffsetSection2Lbl.setText(Long.toString(ncaSectionBlock.getBKTRoffsetSection2()));
BKTRsizeSection2Lbl.setText(Long.toString(ncaSectionBlock.getBKTRsizeSection2()));
BKTRmagicSection2Lbl.setText(ncaSectionBlock.getBKTRmagicSection2());
BKTRu32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRu32Section2()));
BKTRs32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRs32Section2()));
BKTRunknownSection2Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknownSection2()));
sectionCTRLbl.setText(byteArrToHexString(ncaSectionBlock.getSectionCTR()));
unknwnEndPaddingTF.setText(byteArrToHexString(ncaSectionBlock.getUnknownEndPadding()));
}
private String getCuteDecHexRepresentation(long value){
return String.format("%d (0x%02x)", value, value);
}
}

View file

@ -22,7 +22,7 @@ import javafx.fxml.FXML;
import javafx.scene.control.Label;
import libKonogonka.Tools.NCA.NCAHeaderTableEntry;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.Converter.byteArrToHexString;
public class NCATableController {
@FXML

View file

@ -27,8 +27,8 @@ import libKonogonka.Tools.NPDM.ACID.FSAccessControlProvider;
import java.net.URL;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.LoperConverter.longToOctString;
import static libKonogonka.Converter.byteArrToHexString;
import static libKonogonka.Converter.longToOctString;
public class FSAccessControlController implements Initializable {
@FXML

View file

@ -27,8 +27,8 @@ import libKonogonka.Tools.NPDM.ACI0.FSAccessHeaderProvider;
import java.net.URL;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.LoperConverter.longToOctString;
import static libKonogonka.Converter.byteArrToHexString;
import static libKonogonka.Converter.longToOctString;
public class FSAccessHeaderController implements Initializable {
@FXML

View file

@ -33,7 +33,7 @@ import java.io.File;
import java.net.URL;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.Converter.byteArrToHexString;
public class NPDMController implements ITabController {

View file

@ -37,7 +37,7 @@ import java.net.URL;
import java.util.List;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.Converter.byteArrToHexString;
public class NSPController implements ITabController {

View file

@ -149,7 +149,7 @@ public class RomFsController implements ITabController {
public void analyze(File file) {
long lv6offset = -1;
try{
System.out.println(file.getName().replaceAll("(^.*lv6\\s)|(]\\.bin)", ""));
System.out.println("lv6offset expected: "+file.getName().replaceAll("(^.*lv6\\s)|(]\\.bin)", ""));
lv6offset = Long.parseLong(file.getName().replaceAll("(^.*lv6\\s)|(]\\.bin)", ""));
}
catch (Exception e){
@ -161,7 +161,6 @@ public class RomFsController implements ITabController {
this.setData(provider);
});
Thread workThread = new Thread(analyzer);
workThread.setDaemon(true);
workThread.start();
}

View file

@ -33,7 +33,7 @@ import java.io.File;
import java.net.URL;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.Converter.byteArrToHexString;
public class TIKController implements ITabController {
@FXML

View file

@ -32,7 +32,7 @@ import java.io.File;
import java.net.URL;
import java.util.ResourceBundle;
import static libKonogonka.LoperConverter.byteArrToHexString;
import static libKonogonka.Converter.byteArrToHexString;
public class XCIController implements ITabController {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -771,22 +771,22 @@
<children>
<TitledPane expanded="false" text="Section 0">
<content>
<fx:include fx:id="NCASectionHeaderFirst" source="NCASectionHeaderBlock.fxml" />
<fx:include fx:id="NCASectionHeaderFirst" source="NCAFsHeaderBlock.fxml" />
</content>
</TitledPane>
<TitledPane expanded="false" text="Section 1">
<content>
<fx:include fx:id="NCASectionHeaderSecond" source="NCASectionHeaderBlock.fxml" />
<fx:include fx:id="NCASectionHeaderSecond" source="NCAFsHeaderBlock.fxml" />
</content>
</TitledPane>
<TitledPane expanded="false" text="Section 2">
<content>
<fx:include fx:id="NCASectionHeaderThird" source="NCASectionHeaderBlock.fxml" />
<fx:include fx:id="NCASectionHeaderThird" source="NCAFsHeaderBlock.fxml" />
</content>
</TitledPane>
<TitledPane expanded="false" text="Section 3">
<content>
<fx:include fx:id="NCASectionHeaderFourth" source="NCASectionHeaderBlock.fxml" />
<fx:include fx:id="NCASectionHeaderFourth" source="NCAFsHeaderBlock.fxml" />
</content>
</TitledPane>
</children>