diff --git a/src/main/java/konogonka/Controllers/MainController.java b/src/main/java/konogonka/Controllers/MainController.java index 814082d..472edd9 100644 --- a/src/main/java/konogonka/Controllers/MainController.java +++ b/src/main/java/konogonka/Controllers/MainController.java @@ -86,7 +86,7 @@ public class MainController implements Initializable { else fileChooser.setInitialDirectory(new File(System.getProperty("user.home"))); - fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NS files", "*.nsp", "*.xci", "*.nca", "*.tik", "*.xml", "*.npdm")); + fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NS files", "*.nsp", "*.nsz", "*.xci", "*.nca", "*.tik", "*.xml", "*.npdm")); this.selectedFile = fileChooser.showOpenDialog(analyzeBtn.getScene().getWindow()); // todo: fix @@ -102,18 +102,28 @@ public class MainController implements Initializable { filenameSelected.setText(this.selectedFile.getAbsolutePath()); previouslyOpenedPath = this.selectedFile.getParent(); analyzeBtn.setDisable(false); - if (this.selectedFile.getName().toLowerCase().endsWith(".nsp")) - tabPane.getSelectionModel().select(0); - else if (this.selectedFile.getName().toLowerCase().endsWith(".xci")) - tabPane.getSelectionModel().select(1); - else if (this.selectedFile.getName().toLowerCase().endsWith(".nca")) - tabPane.getSelectionModel().select(2); - else if (this.selectedFile.getName().toLowerCase().endsWith(".tik")) - tabPane.getSelectionModel().select(3); - else if (this.selectedFile.getName().toLowerCase().endsWith(".xml")) - tabPane.getSelectionModel().select(4); - else if (this.selectedFile.getName().toLowerCase().endsWith(".npdm")) - tabPane.getSelectionModel().select(5); + String fileExtension = this.selectedFile.getName().toLowerCase().replaceAll("^.*\\.", ""); + switch (fileExtension){ + case "nsp": + case "nsz": + tabPane.getSelectionModel().select(0); + break; + case "xci": + tabPane.getSelectionModel().select(1); + break; + case "nca": + tabPane.getSelectionModel().select(2); + break; + case "tic": + tabPane.getSelectionModel().select(3); + break; + case "xml": + tabPane.getSelectionModel().select(4); + break; + case "npdm": + tabPane.getSelectionModel().select(5); + break; + } } logArea.clear(); @@ -122,18 +132,28 @@ public class MainController implements Initializable { * Start analyze * */ private void analyzeFile(){ - if (selectedFile.getName().toLowerCase().endsWith("nsp")) - NSPTabController.analyze(selectedFile); // TODO: NSP OR XCI - else if (selectedFile.getName().toLowerCase().endsWith("xci")) - XCITabController.analyze(selectedFile); - else if (selectedFile.getName().toLowerCase().endsWith("nca")) - NCATabController.analyze(selectedFile); - else if (selectedFile.getName().toLowerCase().endsWith("tik")) - TIKTabController.analyze(selectedFile); - else if (selectedFile.getName().toLowerCase().endsWith("xml")) - XMLTabController.analyze(selectedFile); - else if (selectedFile.getName().toLowerCase().endsWith("npdm")) - NPDMTabController.analyze(selectedFile); + final String fileExtension = selectedFile.getName().toLowerCase().replaceAll("^.*\\.", ""); + switch (fileExtension){ + case "nsp": + case "nsz": + NSPTabController.analyze(selectedFile); // TODO: NSP OR XCI + break; + case "xci": + XCITabController.analyze(selectedFile); + break; + case "nca": + NCATabController.analyze(selectedFile); + break; + case "tic": + TIKTabController.analyze(selectedFile); + break; + case "xml": + XMLTabController.analyze(selectedFile); + break; + case "npdm": + NPDMTabController.analyze(selectedFile); + break; + } } @FXML private void showHideLogs(){ diff --git a/src/main/java/konogonka/Tools/NCA/NCAProvider.java b/src/main/java/konogonka/Tools/NCA/NCAProvider.java index 4962972..57b61f4 100644 --- a/src/main/java/konogonka/Tools/NCA/NCAProvider.java +++ b/src/main/java/konogonka/Tools/NCA/NCAProvider.java @@ -193,8 +193,27 @@ public class NCAProvider { decryptedKey2 = cipher.doFinal(encryptedKey2); decryptedKey3 = cipher.doFinal(encryptedKey3); } - else - throw new Exception("key_are_key_[UNKNOWN] requested ("+keyIndex+"). Not supported."); + else{ + StringBuilder exceptionStringBuilder = new StringBuilder("key_area_key_"); + switch (keyIndex){ + case 0: + exceptionStringBuilder.append("application_"); + break; + case 1: + exceptionStringBuilder.append("ocean_"); + break; + case 2: + exceptionStringBuilder.append("system_"); + break; + default: + exceptionStringBuilder.append(keyIndex); + exceptionStringBuilder.append("[UNKNOWN]_"); + } + exceptionStringBuilder.append(String.format("%02d", cryptoTypeReal)); + exceptionStringBuilder.append(" requested. Not supported or not found."); + + throw new Exception(exceptionStringBuilder.toString()); + } } tableEntry0 = new NCAHeaderTableEntry(tableBytes); diff --git a/src/main/resources/locale.properties b/src/main/resources/locale.properties index d960fa7..9af4883 100644 --- a/src/main/resources/locale.properties +++ b/src/main/resources/locale.properties @@ -1,4 +1,4 @@ -btnFileOpen=Select NSP/XCI/NCA/TIK/XML +btnFileOpen=Select btnAnalyze=Analyze lblNoFileSelected=No files selected. tableNumberLbl=# diff --git a/src/main/resources/locale_fra.properties b/src/main/resources/locale_fra.properties index b27721a..bf8e0f4 100644 --- a/src/main/resources/locale_fra.properties +++ b/src/main/resources/locale_fra.properties @@ -1,4 +1,4 @@ -btnFileOpen=Selectionner NSP/XCI/NCA/TIK/XML +btnFileOpen=Selectionner btnAnalyze=Analyser lblNoFileSelected=Aucuns fichiers s\u00E9lectionn\u00E9s. tableUploadLbl=Extraire ? diff --git a/src/main/resources/locale_rus.properties b/src/main/resources/locale_rus.properties index 91f8646..aded4df 100644 --- a/src/main/resources/locale_rus.properties +++ b/src/main/resources/locale_rus.properties @@ -1,4 +1,4 @@ -btnFileOpen=\u0412\u044B\u0431\u0440\u0430\u0442\u044C NSP/XCI/NCA/TIK/XML +btnFileOpen=\u0412\u044B\u0431\u0440\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. tableUploadLbl=\u0420\u0430\u0441\u043F\u0430\u043A\u043E\u0432\u0430\u0442\u044C? diff --git a/src/main/resources/locale_ukr.properties b/src/main/resources/locale_ukr.properties index ef5f099..1a8f80a 100644 --- a/src/main/resources/locale_ukr.properties +++ b/src/main/resources/locale_ukr.properties @@ -1,4 +1,4 @@ -btnFileOpen=\u0412\u0438\u0431\u0440\u0430\u0442\u0438 NSP/XCI/NCA/TIK/XML +btnFileOpen=\u0412\u0438\u0431\u0440\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. tableNumberLbl=\u2116