From baf70df47c50a8e3039597f22da1c19c83e79796 Mon Sep 17 00:00:00 2001 From: Dmitry Isaenko Date: Sat, 18 May 2019 05:22:55 +0300 Subject: [PATCH] upd --- .../NCA/NCASectionHeaderBlockController.java | 19 ++- .../konogonka/Tools/NCA/NCAContentPFS0.java | 2 + .../NCASectionTableBlock/NCASectionBlock.java | 28 ++-- .../FXML/NCA/NCASectionHeaderBlock.fxml | 153 +++++++++++++----- 4 files changed, 137 insertions(+), 65 deletions(-) diff --git a/src/main/java/konogonka/Controllers/NCA/NCASectionHeaderBlockController.java b/src/main/java/konogonka/Controllers/NCA/NCASectionHeaderBlockController.java index ae8aa46..e800024 100644 --- a/src/main/java/konogonka/Controllers/NCA/NCASectionHeaderBlockController.java +++ b/src/main/java/konogonka/Controllers/NCA/NCASectionHeaderBlockController.java @@ -75,7 +75,8 @@ public class NCASectionHeaderBlockController { @FXML private TextField romFsUnknownTf, - romFsHashTf; + romFsHashTf, + unknwnEndPaddingTF; @FXML private Label @@ -91,8 +92,8 @@ public class NCASectionHeaderBlockController { BKTRu32Section2Lbl, BKTRs32Section2Lbl, BKTRunknownSection2Lbl, - BKTRunknown1Lbl, - BKTRunknown2Lbl; + sectionCTRlowLbl, + sectionCTRhighLbl; public void resetTab() { versionLbl.setText("-"); @@ -166,8 +167,9 @@ public class NCASectionHeaderBlockController { BKTRu32Section2Lbl.setText("-"); BKTRs32Section2Lbl.setText("-"); BKTRunknownSection2Lbl.setText("-"); - BKTRunknown1Lbl.setText("-"); - BKTRunknown2Lbl.setText("-"); + sectionCTRlowLbl.setText("-"); + sectionCTRhighLbl.setText("-"); + unknwnEndPaddingTF.setText("-"); } public void populateTab(NCASectionBlock ncaSectionBlock){ @@ -187,7 +189,7 @@ public class NCASectionHeaderBlockController { sb.append("(PFS0)"); hashTypeLbl.setText(sb.toString()); cryptoTypeLbl.setText(String.format("%02x ", ncaSectionBlock.getCryptoType())); - paddingLbl.setText(String.format("%02x ", ncaSectionBlock.getPadding())); + paddingLbl.setText(byteArrToHexString(ncaSectionBlock.getPadding())); if ((ncaSectionBlock.getFsType() == 0) && (ncaSectionBlock.getHashType() == 0x3)){ romFsMagicLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagic()); romFsMagicNumberLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagicNumber() @@ -256,7 +258,8 @@ public class NCASectionHeaderBlockController { BKTRu32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRu32Section2())); BKTRs32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRs32Section2())); BKTRunknownSection2Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknownSection2())); - BKTRunknown1Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknown1())); - BKTRunknown2Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknown2())); + sectionCTRlowLbl.setText(byteArrToHexString(ncaSectionBlock.getSectionCTRlow())); + sectionCTRhighLbl.setText(byteArrToHexString(ncaSectionBlock.getSectionCTRhigh())); + unknwnEndPaddingTF.setText(byteArrToHexString(ncaSectionBlock.getUnknownEndPadding())); } } diff --git a/src/main/java/konogonka/Tools/NCA/NCAContentPFS0.java b/src/main/java/konogonka/Tools/NCA/NCAContentPFS0.java index dfbb6b0..3315042 100644 --- a/src/main/java/konogonka/Tools/NCA/NCAContentPFS0.java +++ b/src/main/java/konogonka/Tools/NCA/NCAContentPFS0.java @@ -70,10 +70,12 @@ public class NCAContentPFS0 { rawData = new byte[0x20]; // 32 bytes - size of SHA256 hash + /* if (raf.read(rawData) != -1) { System.out.println("Encrypted"); RainbowHexDump.hexDumpUTF8(rawData); } + */ try { /* System.out.println("Decrypted?"); diff --git a/src/main/java/konogonka/Tools/NCA/NCASectionTableBlock/NCASectionBlock.java b/src/main/java/konogonka/Tools/NCA/NCASectionTableBlock/NCASectionBlock.java index 697d570..1285860 100644 --- a/src/main/java/konogonka/Tools/NCA/NCASectionTableBlock/NCASectionBlock.java +++ b/src/main/java/konogonka/Tools/NCA/NCASectionTableBlock/NCASectionBlock.java @@ -11,7 +11,7 @@ public class NCASectionBlock { private byte fsType; private byte hashType; private byte cryptoType; - private byte padding; + private byte[] padding; private SuperBlockIVFC superBlockIVFC; private SuperBlockPFS0 superBlockPFS0; private byte[] BKTRfullHeader; @@ -30,8 +30,9 @@ public class NCASectionBlock { private int BKTRs32Section2; private byte[] BKTRunknownSection2; - private byte[] BKTRunknown1; - private byte[] BKTRunknown2; + private byte[] sectionCTRlow; + private byte[] sectionCTRhigh; + private byte[] unknownEndPadding; public NCASectionBlock(byte[] tableBlockBytes) throws Exception{ if (tableBlockBytes.length != 0x200) @@ -40,7 +41,7 @@ public class NCASectionBlock { fsType = tableBlockBytes[0x2]; hashType = tableBlockBytes[0x3]; cryptoType = tableBlockBytes[0x4]; - padding = tableBlockBytes[0x5]; + padding = Arrays.copyOfRange(tableBlockBytes, 0x5, 0x8); byte[] superBlockBytes = Arrays.copyOfRange(tableBlockBytes, 0x8, 0xf8); if ((fsType == 0) && (hashType == 0x3)) @@ -48,8 +49,8 @@ public class NCASectionBlock { else if ((fsType == 0x1) && (hashType == 0x2)) superBlockPFS0 = new SuperBlockPFS0(superBlockBytes); - BKTRfullHeader = Arrays.copyOfRange(tableBlockBytes, 0x100, 0x200); - + BKTRfullHeader = Arrays.copyOfRange(tableBlockBytes, 0x100, 0x140); + BKTRoffsetSection1 = getLElong(BKTRfullHeader, 0); BKTRsizeSection1 = getLElong(BKTRfullHeader, 0x8); BKTRmagicSection1 = new String(Arrays.copyOfRange(BKTRfullHeader, 0x10, 0x14), StandardCharsets.US_ASCII); @@ -62,17 +63,18 @@ public class NCASectionBlock { BKTRmagicSection2 = new String(Arrays.copyOfRange(BKTRfullHeader, 0x30, 0x34), StandardCharsets.US_ASCII); BKTRu32Section2 = getLEint(BKTRfullHeader, 0x34); BKTRs32Section2 = getLEint(BKTRfullHeader, 0x38); - BKTRunknownSection2 = Arrays.copyOfRange(tableBlockBytes, 0x3c, 0x40); + BKTRunknownSection2 = Arrays.copyOfRange(BKTRfullHeader, 0x3c, 0x40); - BKTRunknown1 = Arrays.copyOfRange(tableBlockBytes, 0x40, 0x44); - BKTRunknown2 = Arrays.copyOfRange(tableBlockBytes, 0x44, 0x48); + sectionCTRlow = Arrays.copyOfRange(tableBlockBytes, 0x140, 0x144); + sectionCTRhigh = Arrays.copyOfRange(tableBlockBytes, 0x144, 0x148); + unknownEndPadding = Arrays.copyOfRange(tableBlockBytes, 0x148, 0x200); } public byte[] getVersion() { return version; } public byte getFsType() { return fsType; } public byte getHashType() { return hashType; } public byte getCryptoType() { return cryptoType; } - public byte getPadding() { return padding; } + public byte[] getPadding() { return padding; } public SuperBlockIVFC getSuperBlockIVFC() { return superBlockIVFC; } public SuperBlockPFS0 getSuperBlockPFS0() { return superBlockPFS0; } public byte[] getBKTRfullHeader() { return BKTRfullHeader; } @@ -89,8 +91,8 @@ public class NCASectionBlock { public int getBKTRu32Section2() { return BKTRu32Section2; } public int getBKTRs32Section2() { return BKTRs32Section2; } public byte[] getBKTRunknownSection2() { return BKTRunknownSection2; } - public byte[] getBKTRunknown1() { return BKTRunknown1; } - public byte[] getBKTRunknown2() { return BKTRunknown2; } - + public byte[] getSectionCTRlow() { return sectionCTRlow; } + public byte[] getSectionCTRhigh() { return sectionCTRhigh; } + public byte[] getUnknownEndPadding() { return unknownEndPadding; } } diff --git a/src/main/resources/FXML/NCA/NCASectionHeaderBlock.fxml b/src/main/resources/FXML/NCA/NCASectionHeaderBlock.fxml index d8e81cb..1b9ed07 100644 --- a/src/main/resources/FXML/NCA/NCASectionHeaderBlock.fxml +++ b/src/main/resources/FXML/NCA/NCASectionHeaderBlock.fxml @@ -28,6 +28,9 @@ + + + @@ -153,7 +156,7 @@ - -