XML support [basic]
This commit is contained in:
parent
37014aaf7f
commit
02b49d9cb2
12 changed files with 129 additions and 24 deletions
|
@ -19,4 +19,10 @@ Deep WIP multi-tool to work with XCI/NSP/NCA/NRO(?) files
|
||||||
|
|
||||||
### System requirements
|
### System requirements
|
||||||
|
|
||||||
JRE/JDK 8u60 or higher.
|
JRE/JDK 8u60 or higher.
|
||||||
|
|
||||||
|
### Checklist
|
||||||
|
|
||||||
|
* [ ] LogPrinter to singleton implementation
|
||||||
|
* [ ] CNMT support
|
||||||
|
* [ ] support
|
|
@ -6,8 +6,8 @@ import javafx.scene.Scene;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import konogonka.Controllers.IRowModel;
|
import konogonka.Controllers.IRowModel;
|
||||||
import konogonka.Controllers.NCA.NCAController;
|
import konogonka.Controllers.ITabController;
|
||||||
import konogonka.Controllers.TIK.TIKController;
|
import konogonka.Controllers.XML.XMLController;
|
||||||
import konogonka.Tools.ISuperProvider;
|
import konogonka.Tools.ISuperProvider;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -29,19 +29,18 @@ public class ChildWindow {
|
||||||
else if(model.getFileName().endsWith(".tik")){
|
else if(model.getFileName().endsWith(".tik")){
|
||||||
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/TIK/TIKTab.fxml"));
|
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/TIK/TIKTab.fxml"));
|
||||||
}
|
}
|
||||||
|
else if(model.getFileName().endsWith(".xml")){
|
||||||
|
loaderSettings = new FXMLLoader(getClass().getResource("/FXML/XML/XMLTab.fxml"));
|
||||||
|
}
|
||||||
else if(model.getFileName().endsWith(".cert")){
|
else if(model.getFileName().endsWith(".cert")){
|
||||||
// TODO: IMPLEMENT
|
// TODO: IMPLEMENT
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(model.getFileName().endsWith(".tik")){
|
else if(model.getFileName().endsWith(".cnmt")){
|
||||||
// TODO: IMPLEMENT
|
// TODO: IMPLEMENT
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(model.getFileName().endsWith(".xml")){
|
else // TODO: Dynamic detection function
|
||||||
// TODO: IMPLEMENT
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Locale userLocale = new Locale(Locale.getDefault().getISO3Language());
|
Locale userLocale = new Locale(Locale.getDefault().getISO3Language());
|
||||||
|
@ -49,15 +48,14 @@ public class ChildWindow {
|
||||||
loaderSettings.setResources(resourceBundle);
|
loaderSettings.setResources(resourceBundle);
|
||||||
Parent parentAbout = loaderSettings.load();
|
Parent parentAbout = loaderSettings.load();
|
||||||
|
|
||||||
|
// TODO: fix?
|
||||||
// TODO: REFACTOR
|
if(model.getFileName().endsWith(".xml")){
|
||||||
if (model.getFileName().endsWith(".nca")){
|
XMLController myController = loaderSettings.<XMLController>getController();
|
||||||
NCAController ncaController = loaderSettings.<NCAController>getController();
|
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset(), model.getFileSize());
|
||||||
ncaController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
|
||||||
}
|
}
|
||||||
else if(model.getFileName().endsWith(".tik")){
|
else {
|
||||||
TIKController tikController = loaderSettings.<TIKController>getController();
|
ITabController myController = loaderSettings.<ITabController>getController();
|
||||||
tikController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
myController.analyze(provider.getFile(), provider.getRawFileDataStart()+model.getFileOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import konogonka.Controllers.NCA.NCAController;
|
||||||
import konogonka.Controllers.NSP.NSPController;
|
import konogonka.Controllers.NSP.NSPController;
|
||||||
import konogonka.Controllers.TIK.TIKController;
|
import konogonka.Controllers.TIK.TIKController;
|
||||||
import konogonka.Controllers.XCI.XCIController;
|
import konogonka.Controllers.XCI.XCIController;
|
||||||
|
import konogonka.Controllers.XML.XMLController;
|
||||||
import konogonka.MediatorControl;
|
import konogonka.MediatorControl;
|
||||||
import konogonka.Settings.SettingsWindow;
|
import konogonka.Settings.SettingsWindow;
|
||||||
import konogonka.Tools.ISuperProvider;
|
import konogonka.Tools.ISuperProvider;
|
||||||
|
@ -47,6 +48,8 @@ public class MainController implements Initializable {
|
||||||
private NCAController NCATabController;
|
private NCAController NCATabController;
|
||||||
@FXML
|
@FXML
|
||||||
private TIKController TIKTabController;
|
private TIKController TIKTabController;
|
||||||
|
@FXML
|
||||||
|
private XMLController XMLTabController;
|
||||||
|
|
||||||
private File selectedFile;
|
private File selectedFile;
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ public class MainController implements Initializable {
|
||||||
else
|
else
|
||||||
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
||||||
|
|
||||||
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NS files", "*.nsp", "*.xci", "*.nca", "*.tik"));
|
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NS files", "*.nsp", "*.xci", "*.nca", "*.tik", "*.xml"));
|
||||||
|
|
||||||
this.selectedFile = fileChooser.showOpenDialog(analyzeBtn.getScene().getWindow());
|
this.selectedFile = fileChooser.showOpenDialog(analyzeBtn.getScene().getWindow());
|
||||||
|
|
||||||
|
@ -89,6 +92,7 @@ public class MainController implements Initializable {
|
||||||
XCITabController.resetTab();
|
XCITabController.resetTab();
|
||||||
NCATabController.resetTab();
|
NCATabController.resetTab();
|
||||||
TIKTabController.resetTab();
|
TIKTabController.resetTab();
|
||||||
|
XMLTabController.resetTab();
|
||||||
|
|
||||||
if (this.selectedFile != null && this.selectedFile.exists()) {
|
if (this.selectedFile != null && this.selectedFile.exists()) {
|
||||||
filenameSelected.setText(this.selectedFile.getAbsolutePath());
|
filenameSelected.setText(this.selectedFile.getAbsolutePath());
|
||||||
|
@ -102,6 +106,8 @@ public class MainController implements Initializable {
|
||||||
tabPane.getSelectionModel().select(2);
|
tabPane.getSelectionModel().select(2);
|
||||||
else if (this.selectedFile.getName().toLowerCase().endsWith(".tik"))
|
else if (this.selectedFile.getName().toLowerCase().endsWith(".tik"))
|
||||||
tabPane.getSelectionModel().select(3);
|
tabPane.getSelectionModel().select(3);
|
||||||
|
else if (this.selectedFile.getName().toLowerCase().endsWith(".xml"))
|
||||||
|
tabPane.getSelectionModel().select(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
logArea.clear();
|
logArea.clear();
|
||||||
|
@ -118,6 +124,8 @@ public class MainController implements Initializable {
|
||||||
NCATabController.analyze(selectedFile);
|
NCATabController.analyze(selectedFile);
|
||||||
else if (selectedFile.getName().toLowerCase().endsWith("tik"))
|
else if (selectedFile.getName().toLowerCase().endsWith("tik"))
|
||||||
TIKTabController.analyze(selectedFile);
|
TIKTabController.analyze(selectedFile);
|
||||||
|
else if (selectedFile.getName().toLowerCase().endsWith("xml"))
|
||||||
|
XMLTabController.analyze(selectedFile);
|
||||||
}
|
}
|
||||||
@FXML
|
@FXML
|
||||||
private void showHideLogs(){
|
private void showHideLogs(){
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class NSPController implements ITabController {
|
||||||
* */
|
* */
|
||||||
@Override
|
@Override
|
||||||
public void analyze(File selectedFile, long offset){
|
public void analyze(File selectedFile, long offset){
|
||||||
// TODO: IMPLEMENT
|
// TODO: IMPLEMENT?
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,6 @@ import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import konogonka.AppPreferences;
|
import konogonka.AppPreferences;
|
||||||
import konogonka.Controllers.ITabController;
|
import konogonka.Controllers.ITabController;
|
||||||
import konogonka.MediatorControl;
|
|
||||||
import konogonka.Tools.TIK.TIKProvider;
|
import konogonka.Tools.TIK.TIKProvider;
|
||||||
import konogonka.Workers.AnalyzerTIK;
|
import konogonka.Workers.AnalyzerTIK;
|
||||||
|
|
||||||
|
|
75
src/main/java/konogonka/Controllers/XML/XMLController.java
Normal file
75
src/main/java/konogonka/Controllers/XML/XMLController.java
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
package konogonka.Controllers.XML;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
|
import konogonka.Controllers.ITabController;
|
||||||
|
import konogonka.MediatorControl;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class XMLController implements ITabController {
|
||||||
|
@FXML
|
||||||
|
|
||||||
|
private TextArea mainTa;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle resourceBundle) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read from start to end
|
||||||
|
* */
|
||||||
|
@Override
|
||||||
|
public void analyze(File file) { analyze(file, 0); }
|
||||||
|
/**
|
||||||
|
* Read from offset to end
|
||||||
|
* */
|
||||||
|
@Override
|
||||||
|
public void analyze(File file, long offset) {
|
||||||
|
try {
|
||||||
|
if (file.length() - offset > 10485760) // 10mB
|
||||||
|
throw new Exception("XMLController -> analyze(): File is too big. It must be something wrong with it. Usually they're smaller");
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
if (bis.skip(offset) != offset)
|
||||||
|
throw new Exception("XMLController -> analyze(): Unable to skip requested range");
|
||||||
|
int readChunk = (int) (file.length() - offset);
|
||||||
|
byte[] buffer = new byte[readChunk]; // Let it be 1kB
|
||||||
|
if (bis.read(buffer) != readChunk)
|
||||||
|
throw new Exception("XMLController -> analyze(): Unable to read requested range");
|
||||||
|
mainTa.appendText(new String(buffer, 0, readChunk, StandardCharsets.UTF_8));
|
||||||
|
bis.close();
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
MediatorControl.getInstance().getContoller().logArea.appendText("XMLController -> analyze(): \n"+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Read from offset to length
|
||||||
|
* */
|
||||||
|
public void analyze(File file, long offset, long fileSize) {
|
||||||
|
System.out.println(file.length()+" "+offset+" "+fileSize);
|
||||||
|
try {
|
||||||
|
if (fileSize > 10485760) // 10mB
|
||||||
|
throw new Exception("XMLController -> analyze(): File is too big. It must be something wrong with it. Usually they're smaller");
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||||
|
if (bis.skip(offset) != offset)
|
||||||
|
throw new Exception("XMLController -> analyze(): Unable to skip requested range");
|
||||||
|
byte[] buffer = new byte[(int)fileSize]; // Let it be 1kB
|
||||||
|
if (bis.read(buffer) != fileSize)
|
||||||
|
throw new Exception("XMLController -> analyze(): Unable to read requested range");
|
||||||
|
mainTa.appendText(new String(buffer, 0, (int) fileSize, StandardCharsets.UTF_8));
|
||||||
|
bis.close();
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
MediatorControl.getInstance().getContoller().logArea.appendText("XMLController -> analyze(): \n"+e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void resetTab() {
|
||||||
|
mainTa.setText(null);
|
||||||
|
}
|
||||||
|
}
|
11
src/main/resources/FXML/XML/XMLTab.fxml
Normal file
11
src/main/resources/FXML/XML/XMLTab.fxml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.TextArea?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="konogonka.Controllers.XML.XMLController">
|
||||||
|
<children>
|
||||||
|
<TextArea fx:id="mainTa" editable="false" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
|
@ -79,6 +79,14 @@
|
||||||
<Label text="TIK" />
|
<Label text="TIK" />
|
||||||
</graphic>
|
</graphic>
|
||||||
</Tab>
|
</Tab>
|
||||||
|
<Tab closable="false">
|
||||||
|
<content>
|
||||||
|
<fx:include fx:id="XMLTab" source="XML/XMLTab.fxml" />
|
||||||
|
</content>
|
||||||
|
<graphic>
|
||||||
|
<Label text="XML" />
|
||||||
|
</graphic>
|
||||||
|
</Tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<AnchorPane fx:id="logPane" prefHeight="200.0" prefWidth="200.0">
|
<AnchorPane fx:id="logPane" prefHeight="200.0" prefWidth="200.0">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
btnFileOpen=Select NSP/XCI/NCA/TIK
|
btnFileOpen=Select NSP/XCI/NCA/TIK/XML
|
||||||
btnAnalyze=Analyze
|
btnAnalyze=Analyze
|
||||||
lblNoFileSelected=No files selected.
|
lblNoFileSelected=No files selected.
|
||||||
tableNumberLbl=#
|
tableNumberLbl=#
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
btnFileOpen=Selectionner NSP/XCI/NCA/TIK
|
btnFileOpen=Selectionner NSP/XCI/NCA/TIK/XML
|
||||||
btnAnalyze=Analyser
|
btnAnalyze=Analyser
|
||||||
lblNoFileSelected=Aucuns fichiers s\u00E9lectionn\u00E9s.
|
lblNoFileSelected=Aucuns fichiers s\u00E9lectionn\u00E9s.
|
||||||
tableUploadLbl=Extraire ?
|
tableUploadLbl=Extraire ?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
btnFileOpen=\u0412\u044B\u0431\u0440\u0430\u0442\u044C NSP/XCI/NCA/TIK
|
btnFileOpen=\u0412\u044B\u0431\u0440\u0430\u0442\u044C NSP/XCI/NCA/TIK/XML
|
||||||
btnAnalyze=\u0410\u043D\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C
|
btnAnalyze=\u0410\u043D\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u0442\u044C
|
||||||
lblNoFileSelected=\u0424\u0430\u0439\u043B\u044B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u044B.
|
lblNoFileSelected=\u0424\u0430\u0439\u043B\u044B \u043D\u0435 \u0432\u044B\u0431\u0440\u0430\u043D\u044B.
|
||||||
tableUploadLbl=\u0420\u0430\u0441\u043F\u0430\u043A\u043E\u0432\u0430\u0442\u044C?
|
tableUploadLbl=\u0420\u0430\u0441\u043F\u0430\u043A\u043E\u0432\u0430\u0442\u044C?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
btnFileOpen=\u0412\u0438\u0431\u0440\u0430\u0442\u0438 NSP/XCI/NCA/TIK
|
btnFileOpen=\u0412\u0438\u0431\u0440\u0430\u0442\u0438 NSP/XCI/NCA/TIK/XML
|
||||||
btnAnalyze=\u0410\u043D\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438
|
btnAnalyze=\u0410\u043D\u0430\u043B\u0456\u0437\u0443\u0432\u0430\u0442\u0438
|
||||||
lblNoFileSelected=\u0424\u0430\u0439\u043B\u0438 \u043D\u0435 \u0432\u0438\u0431\u0440\u0430\u043D\u0456.
|
lblNoFileSelected=\u0424\u0430\u0439\u043B\u0438 \u043D\u0435 \u0432\u0438\u0431\u0440\u0430\u043D\u0456.
|
||||||
tableNumberLbl=\u2116
|
tableNumberLbl=\u2116
|
||||||
|
|
Loading…
Reference in a new issue