diff --git a/Ghidra/Features/GhidraGo/src/main/java/ghidra/GhidraGo.java b/Ghidra/Features/GhidraGo/src/main/java/ghidra/GhidraGo.java index e37ad4b395..ccbb673523 100644 --- a/Ghidra/Features/GhidraGo/src/main/java/ghidra/GhidraGo.java +++ b/Ghidra/Features/GhidraGo/src/main/java/ghidra/GhidraGo.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -16,6 +16,7 @@ package ghidra; import java.io.IOException; +import java.net.URL; import java.nio.file.Path; import docking.framework.DockingApplicationConfiguration; @@ -58,6 +59,8 @@ public class GhidraGo implements GhidraLaunchable { if (args != null && args.length > 0) { ghidra.framework.protocol.ghidra.Handler.registerHandler(); sender = new GhidraGoSender(); + // check if ghidra url is valid + GhidraURL.getProjectURL(new URL(args[0])); startGhidraIfNeeded(layout); @@ -70,25 +73,26 @@ public class GhidraGo implements GhidraLaunchable { } } else { - throw new IllegalArgumentException( - "A valid GhidraURL locating a program, program name, or path to a program name " + - "must be specified as the first command line argument."); + throw new IllegalArgumentException(); } } + catch (IllegalArgumentException e) { + System.err.println("\n" + "USAGE: ghidraGo \n\n" + + "Ghidra URL Forms (ghidraURL):\n" + + " ghidra://[:]/[/[/]]\n" + + " ghidra:/[/][?/[/]]\n"); + } catch (FailedToStartGhidraException e) { logOrShowError("GhidraGo Start Ghidra Exception", "Failed to start Ghidra from GhidraGo", e); - System.exit(-1); } catch (StopWaitingException e) { - System.exit(-1); + // do nothing } catch (Exception e) { logOrShowError("GhidraGo Exception", "An unexpected exception occurred in GhidraGo", e); - // calling System.exit explicitly is necessary, otherwise the Loading... screen - // persists instead of closing when complete. - System.exit(-1); } + System.exit(-1); } private void logOrShowError(String errorTitle, String errorMessage, Exception e) {