diff --git a/src/main/java/gq/malwarefight/narumiideobfgui/DeobfuscatorGUIController.java b/src/main/java/gq/malwarefight/narumiideobfgui/DeobfuscatorGUIController.java index 4e28dc7..5fd8719 100644 --- a/src/main/java/gq/malwarefight/narumiideobfgui/DeobfuscatorGUIController.java +++ b/src/main/java/gq/malwarefight/narumiideobfgui/DeobfuscatorGUIController.java @@ -16,13 +16,12 @@ import java.io.File; import java.io.FileNotFoundException; +import java.nio.file.Path; import java.util.ArrayList; import java.util.HashMap; public class DeobfuscatorGUIController { - private File inputFile; - private File outputFile; private final HashMap deobfuscatorHashMap = new HashMap<>(); @FXML @@ -39,25 +38,31 @@ public class DeobfuscatorGUIController { protected void chooseInputFile() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(new File(System.getProperty("user.dir"))); + fileChooser.getExtensionFilters().addAll( + new FileChooser.ExtensionFilter("Jar Files", "*.jar", "*.zip"), + new FileChooser.ExtensionFilter("Other Files", "*.*") + ); File input = fileChooser.showOpenDialog(DeobfuscatorGUIApp.stage); if (input == null) { return; } inputName.setText(input.getPath()); - this.inputFile = input; } @FXML protected void chooseOutputFile() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(new File(System.getProperty("user.dir"))); + fileChooser.getExtensionFilters().addAll( + new FileChooser.ExtensionFilter("Jar Files", "*.jar", "*.zip"), + new FileChooser.ExtensionFilter("Other Files", "*.*") + ); File output = fileChooser.showSaveDialog(DeobfuscatorGUIApp.stage); if (output == null) { return; } String path = output.getPath(); outputName.setText(path); - this.outputFile = output; } @FXML @@ -79,7 +84,7 @@ public void initialize() { @FXML protected void deobfuscate() { - if (inputFile == null || outputFile == null){ + if (inputName.getText() == null || outputName.getText() == null || inputName.getText().isBlank() || outputName.getText().isBlank()){ result.setText("You need to specify both input and output files!"); return; } @@ -96,8 +101,8 @@ protected void deobfuscate() { usedTransformers.toArray(transformers); try { Deobfuscator.builder() - .input(inputFile.toPath()) - .output(outputFile.toPath()) + .input(Path.of(inputName.getText())) + .output(Path.of(outputName.getText())) .transformers(transformers) .classReaderFlags(ClassReader.SKIP_FRAMES) .classWriterFlags(0) @@ -105,6 +110,7 @@ protected void deobfuscate() { .build() .start(); } catch (FileNotFoundException e) { + result.setText("One or both of the files don't exist"); return; } result.setText("Deobfuscation complete");