This commit is contained in:
Dmitry Isaenko 2019-05-18 05:22:55 +03:00
parent 62800acc07
commit baf70df47c
4 changed files with 137 additions and 65 deletions

View file

@ -75,7 +75,8 @@ public class NCASectionHeaderBlockController {
@FXML @FXML
private TextField private TextField
romFsUnknownTf, romFsUnknownTf,
romFsHashTf; romFsHashTf,
unknwnEndPaddingTF;
@FXML @FXML
private Label private Label
@ -91,8 +92,8 @@ public class NCASectionHeaderBlockController {
BKTRu32Section2Lbl, BKTRu32Section2Lbl,
BKTRs32Section2Lbl, BKTRs32Section2Lbl,
BKTRunknownSection2Lbl, BKTRunknownSection2Lbl,
BKTRunknown1Lbl, sectionCTRlowLbl,
BKTRunknown2Lbl; sectionCTRhighLbl;
public void resetTab() { public void resetTab() {
versionLbl.setText("-"); versionLbl.setText("-");
@ -166,8 +167,9 @@ public class NCASectionHeaderBlockController {
BKTRu32Section2Lbl.setText("-"); BKTRu32Section2Lbl.setText("-");
BKTRs32Section2Lbl.setText("-"); BKTRs32Section2Lbl.setText("-");
BKTRunknownSection2Lbl.setText("-"); BKTRunknownSection2Lbl.setText("-");
BKTRunknown1Lbl.setText("-"); sectionCTRlowLbl.setText("-");
BKTRunknown2Lbl.setText("-"); sectionCTRhighLbl.setText("-");
unknwnEndPaddingTF.setText("-");
} }
public void populateTab(NCASectionBlock ncaSectionBlock){ public void populateTab(NCASectionBlock ncaSectionBlock){
@ -187,7 +189,7 @@ public class NCASectionHeaderBlockController {
sb.append("(PFS0)"); sb.append("(PFS0)");
hashTypeLbl.setText(sb.toString()); hashTypeLbl.setText(sb.toString());
cryptoTypeLbl.setText(String.format("%02x ", ncaSectionBlock.getCryptoType())); 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)){ if ((ncaSectionBlock.getFsType() == 0) && (ncaSectionBlock.getHashType() == 0x3)){
romFsMagicLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagic()); romFsMagicLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagic());
romFsMagicNumberLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagicNumber() romFsMagicNumberLbl.setText(ncaSectionBlock.getSuperBlockIVFC().getMagicNumber()
@ -256,7 +258,8 @@ public class NCASectionHeaderBlockController {
BKTRu32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRu32Section2())); BKTRu32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRu32Section2()));
BKTRs32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRs32Section2())); BKTRs32Section2Lbl.setText(Integer.toString(ncaSectionBlock.getBKTRs32Section2()));
BKTRunknownSection2Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknownSection2())); BKTRunknownSection2Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknownSection2()));
BKTRunknown1Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknown1())); sectionCTRlowLbl.setText(byteArrToHexString(ncaSectionBlock.getSectionCTRlow()));
BKTRunknown2Lbl.setText(byteArrToHexString(ncaSectionBlock.getBKTRunknown2())); sectionCTRhighLbl.setText(byteArrToHexString(ncaSectionBlock.getSectionCTRhigh()));
unknwnEndPaddingTF.setText(byteArrToHexString(ncaSectionBlock.getUnknownEndPadding()));
} }
} }

View file

@ -70,10 +70,12 @@ public class NCAContentPFS0 {
rawData = new byte[0x20]; // 32 bytes - size of SHA256 hash rawData = new byte[0x20]; // 32 bytes - size of SHA256 hash
/*
if (raf.read(rawData) != -1) { if (raf.read(rawData) != -1) {
System.out.println("Encrypted"); System.out.println("Encrypted");
RainbowHexDump.hexDumpUTF8(rawData); RainbowHexDump.hexDumpUTF8(rawData);
} }
*/
try { try {
/* /*
System.out.println("Decrypted?"); System.out.println("Decrypted?");

View file

@ -11,7 +11,7 @@ public class NCASectionBlock {
private byte fsType; private byte fsType;
private byte hashType; private byte hashType;
private byte cryptoType; private byte cryptoType;
private byte padding; private byte[] padding;
private SuperBlockIVFC superBlockIVFC; private SuperBlockIVFC superBlockIVFC;
private SuperBlockPFS0 superBlockPFS0; private SuperBlockPFS0 superBlockPFS0;
private byte[] BKTRfullHeader; private byte[] BKTRfullHeader;
@ -30,8 +30,9 @@ public class NCASectionBlock {
private int BKTRs32Section2; private int BKTRs32Section2;
private byte[] BKTRunknownSection2; private byte[] BKTRunknownSection2;
private byte[] BKTRunknown1; private byte[] sectionCTRlow;
private byte[] BKTRunknown2; private byte[] sectionCTRhigh;
private byte[] unknownEndPadding;
public NCASectionBlock(byte[] tableBlockBytes) throws Exception{ public NCASectionBlock(byte[] tableBlockBytes) throws Exception{
if (tableBlockBytes.length != 0x200) if (tableBlockBytes.length != 0x200)
@ -40,7 +41,7 @@ public class NCASectionBlock {
fsType = tableBlockBytes[0x2]; fsType = tableBlockBytes[0x2];
hashType = tableBlockBytes[0x3]; hashType = tableBlockBytes[0x3];
cryptoType = tableBlockBytes[0x4]; cryptoType = tableBlockBytes[0x4];
padding = tableBlockBytes[0x5]; padding = Arrays.copyOfRange(tableBlockBytes, 0x5, 0x8);
byte[] superBlockBytes = Arrays.copyOfRange(tableBlockBytes, 0x8, 0xf8); byte[] superBlockBytes = Arrays.copyOfRange(tableBlockBytes, 0x8, 0xf8);
if ((fsType == 0) && (hashType == 0x3)) if ((fsType == 0) && (hashType == 0x3))
@ -48,8 +49,8 @@ public class NCASectionBlock {
else if ((fsType == 0x1) && (hashType == 0x2)) else if ((fsType == 0x1) && (hashType == 0x2))
superBlockPFS0 = new SuperBlockPFS0(superBlockBytes); superBlockPFS0 = new SuperBlockPFS0(superBlockBytes);
BKTRfullHeader = Arrays.copyOfRange(tableBlockBytes, 0x100, 0x200); BKTRfullHeader = Arrays.copyOfRange(tableBlockBytes, 0x100, 0x140);
BKTRoffsetSection1 = getLElong(BKTRfullHeader, 0); BKTRoffsetSection1 = getLElong(BKTRfullHeader, 0);
BKTRsizeSection1 = getLElong(BKTRfullHeader, 0x8); BKTRsizeSection1 = getLElong(BKTRfullHeader, 0x8);
BKTRmagicSection1 = new String(Arrays.copyOfRange(BKTRfullHeader, 0x10, 0x14), StandardCharsets.US_ASCII); 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); BKTRmagicSection2 = new String(Arrays.copyOfRange(BKTRfullHeader, 0x30, 0x34), StandardCharsets.US_ASCII);
BKTRu32Section2 = getLEint(BKTRfullHeader, 0x34); BKTRu32Section2 = getLEint(BKTRfullHeader, 0x34);
BKTRs32Section2 = getLEint(BKTRfullHeader, 0x38); BKTRs32Section2 = getLEint(BKTRfullHeader, 0x38);
BKTRunknownSection2 = Arrays.copyOfRange(tableBlockBytes, 0x3c, 0x40); BKTRunknownSection2 = Arrays.copyOfRange(BKTRfullHeader, 0x3c, 0x40);
BKTRunknown1 = Arrays.copyOfRange(tableBlockBytes, 0x40, 0x44); sectionCTRlow = Arrays.copyOfRange(tableBlockBytes, 0x140, 0x144);
BKTRunknown2 = Arrays.copyOfRange(tableBlockBytes, 0x44, 0x48); sectionCTRhigh = Arrays.copyOfRange(tableBlockBytes, 0x144, 0x148);
unknownEndPadding = Arrays.copyOfRange(tableBlockBytes, 0x148, 0x200);
} }
public byte[] getVersion() { return version; } public byte[] getVersion() { return version; }
public byte getFsType() { return fsType; } public byte getFsType() { return fsType; }
public byte getHashType() { return hashType; } public byte getHashType() { return hashType; }
public byte getCryptoType() { return cryptoType; } public byte getCryptoType() { return cryptoType; }
public byte getPadding() { return padding; } public byte[] getPadding() { return padding; }
public SuperBlockIVFC getSuperBlockIVFC() { return superBlockIVFC; } public SuperBlockIVFC getSuperBlockIVFC() { return superBlockIVFC; }
public SuperBlockPFS0 getSuperBlockPFS0() { return superBlockPFS0; } public SuperBlockPFS0 getSuperBlockPFS0() { return superBlockPFS0; }
public byte[] getBKTRfullHeader() { return BKTRfullHeader; } public byte[] getBKTRfullHeader() { return BKTRfullHeader; }
@ -89,8 +91,8 @@ public class NCASectionBlock {
public int getBKTRu32Section2() { return BKTRu32Section2; } public int getBKTRu32Section2() { return BKTRu32Section2; }
public int getBKTRs32Section2() { return BKTRs32Section2; } public int getBKTRs32Section2() { return BKTRs32Section2; }
public byte[] getBKTRunknownSection2() { return BKTRunknownSection2; } public byte[] getBKTRunknownSection2() { return BKTRunknownSection2; }
public byte[] getBKTRunknown1() { return BKTRunknown1; } public byte[] getSectionCTRlow() { return sectionCTRlow; }
public byte[] getBKTRunknown2() { return BKTRunknown2; } public byte[] getSectionCTRhigh() { return sectionCTRhigh; }
public byte[] getUnknownEndPadding() { return unknownEndPadding; }
} }

View file

@ -28,6 +28,9 @@
<RowConstraints maxHeight="30.0" minHeight="30.0" /> <RowConstraints maxHeight="30.0" minHeight="30.0" />
<RowConstraints minHeight="110.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="110.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="110.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="110.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints /> <RowConstraints />
</rowConstraints> </rowConstraints>
<children> <children>
@ -153,7 +156,7 @@
</AnchorPane> </AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="5"> <AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="5">
<children> <children>
<Label text="0x1" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <Label text="0x3" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding> <padding>
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
</padding> </padding>
@ -189,7 +192,7 @@
</AnchorPane> </AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="7"> <AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="7">
<children> <children>
<Label text="0x200(?)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <Label text="0x40" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding> <padding>
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
</padding> </padding>
@ -1268,8 +1271,6 @@
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="30.0" minHeight="30.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="30.0" minHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<AnchorPane styleClass="customTitleGrid"> <AnchorPane styleClass="customTitleGrid">
@ -1390,16 +1391,6 @@
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
</padding> </padding>
</Label> </Label>
<Label text="0x40" GridPane.rowIndex="13">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label text="0x4?" GridPane.columnIndex="1" GridPane.rowIndex="13">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label text="Magic &quot;BKTR&quot;" GridPane.columnIndex="2" GridPane.rowIndex="3"> <Label text="Magic &quot;BKTR&quot;" GridPane.columnIndex="2" GridPane.rowIndex="3">
<padding> <padding>
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
@ -1420,26 +1411,6 @@
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
</padding> </padding>
</Label> </Label>
<Label text="Unknown" GridPane.columnIndex="2" GridPane.rowIndex="13">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label text="0x44" GridPane.rowIndex="14">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label text="0x4?" GridPane.columnIndex="1" GridPane.rowIndex="14">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label text="Unknown" GridPane.columnIndex="2" GridPane.rowIndex="14">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label fx:id="BKTRoffsetSection1Lbl" text="-" GridPane.columnIndex="3" GridPane.rowIndex="1"> <Label fx:id="BKTRoffsetSection1Lbl" text="-" GridPane.columnIndex="3" GridPane.rowIndex="1">
<padding> <padding>
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
@ -1470,16 +1441,6 @@
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
</padding> </padding>
</Label> </Label>
<Label fx:id="BKTRunknown1Lbl" text="-" GridPane.columnIndex="3" GridPane.rowIndex="13">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label fx:id="BKTRunknown2Lbl" text="-" GridPane.columnIndex="3" GridPane.rowIndex="14">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
<Label text="0x4" GridPane.columnIndex="1" GridPane.rowIndex="10"> <Label text="0x4" GridPane.columnIndex="1" GridPane.rowIndex="10">
<padding> <padding>
<Insets left="5.0" right="5.0" /> <Insets left="5.0" right="5.0" />
@ -1611,6 +1572,110 @@
</VBox> </VBox>
</content> </content>
</ScrollPane> </ScrollPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="8">
<children>
<Label layoutX="13.0" layoutY="6.0" text="0x140" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="8">
<children>
<Label text="0x4" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="9">
<children>
<Label text="0x144" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="9">
<children>
<Label text="0x4" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.rowIndex="10">
<children>
<Label text="0x148" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="1" GridPane.rowIndex="10">
<children>
<Label text="0xB8" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="9">
<children>
<Label text="Section CTR high" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="8">
<children>
<Label text="Section CTR low" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="2" GridPane.rowIndex="10">
<children>
<Label text="Unknown (Padding?)" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="8">
<children>
<Label fx:id="sectionCTRlowLbl" layoutX="42.0" layoutY="7.0" text="-" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="9">
<children>
<Label fx:id="sectionCTRhighLbl" layoutX="28.0" layoutY="6.0" text="-" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="5.0" right="5.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane styleClass="customGrid" GridPane.columnIndex="3" GridPane.rowIndex="10">
<children>
<TextField fx:id="unknwnEndPaddingTF" layoutX="-59.0" layoutY="3.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</children> </children>
<VBox.margin> <VBox.margin>
<Insets /> <Insets />