Ghidra is a software reverse engineering (SRE) framework
init
Ryan Kurtz69d6495b60de
diff --git a/Ghidra/Features/Base/ghidra_scripts/VSCodeProjectScript.java b/Ghidra/Features/Base/ghidra_scripts/VSCodeProjectScript.javaindex 6572858e5f..e805374144 100644--- a/Ghidra/Features/Base/ghidra_scripts/VSCodeProjectScript.java+++ b/Ghidra/Features/Base/ghidra_scripts/VSCodeProjectScript.java@@ -107,6 +107,7 @@ public class VSCodeProjectScript extends GhidraScript {File settingsFile = new File(vscodeDir, "settings.json");String gradleVersion = Application.getApplicationProperty(ApplicationProperties.APPLICATION_GRADLE_MIN_PROPERTY);+ String pythonInterpreterPath = System.getProperty("pyghidra.sys.prefix", null);// Build settings json objectJsonObject json = new JsonObject();@@ -138,6 +139,9 @@ public class VSCodeProjectScript extends GhidraScript {json.addProperty("python.analysis.stubPath",new File(installDir, "docs/ghidra_stubs/typestubs").getAbsolutePath());+ if (pythonInterpreterPath != null) {+ json.addProperty("python.defaultInterpreterPath", pythonInterpreterPath);+ }// Write settings json objectif (!FileUtilities.mkdirs(settingsFile.getParentFile())) {@@ -183,6 +187,8 @@ public class VSCodeProjectScript extends GhidraScript {json.addProperty("version", "0.2.0");JsonArray configurationsArray = new JsonArray();json.add("configurations", configurationsArray);++ // Ghidra launcherJsonObject ghidraConfigObject = new JsonObject();configurationsArray.add(ghidraConfigObject);ghidraConfigObject.addProperty("type", "java");@@ -198,6 +204,33 @@ public class VSCodeProjectScript extends GhidraScript {vmArgsArray.add("-Dghidra.external.modules=${workspaceFolder}");vmArgs.forEach(vmArgsArray::add);+ // PyGhidra launcher+ JsonObject pyghidraConfigObject = new JsonObject();+ configurationsArray.add(pyghidraConfigObject);+ pyghidraConfigObject.addProperty("type", "debugpy");+ pyghidraConfigObject.addProperty("name", "PyGhidra");+ pyghidraConfigObject.addProperty("request", "launch");+ pyghidraConfigObject.addProperty("module", "pyghidra.ghidra_launch");+ pyghidraConfigObject.addProperty("args", GhidraRun.class.getName());+ JsonArray argsArray = new JsonArray();+ pyghidraConfigObject.add("args", argsArray);+ argsArray.add("--install-dir");+ argsArray.add(installDir.getAbsolutePath());+ argsArray.add("-g");+ argsArray.add(GhidraRun.class.getName());+ JsonObject envObject = new JsonObject();+ pyghidraConfigObject.add("env", envObject);+ envObject.addProperty("PYGHIDRA_DEBUG", "1");++ // PyGhidra Java Attach+ JsonObject pyghidraAttachObject = new JsonObject();+ configurationsArray.add(pyghidraAttachObject);+ pyghidraAttachObject.addProperty("type", "java");+ pyghidraAttachObject.addProperty("name", "PyGhidra Java Attach");+ pyghidraAttachObject.addProperty("request", "attach");+ pyghidraAttachObject.addProperty("hostName", "localhost");+ pyghidraAttachObject.addProperty("port", 18001);+// Write launch json objectif (!FileUtilities.mkdirs(launchFile.getParentFile())) {throw new IOException("Failed to create: " + launchFile.getParentFile());diff --git a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.pyindex c31919d3a9..70ca192bd9 100644--- a/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py+++ b/Ghidra/Features/PyGhidra/src/main/py/src/pyghidra/launcher.py@@ -216,14 +216,19 @@ class PyGhidraLauncher:raise Exception("org.eclipse.jdt.launching.VM_ARGUMENTS not found")def _jvm_args(self) -> List[str]:++ properties = [+ f"-Dpyghidra.sys.prefix={sys.prefix}",+ f"-Dpyghidra.sys.executable={sys.executable}"+ ]+if self._dev_mode and self._java_home:- return self._parse_dev_args()+ return properties + self._parse_dev_args()suffix = "_" + platform.system().upper()if suffix == "_DARWIN":suffix = "_MACOS"option_pattern: re.Pattern = re.compile(fr"VMARGS(?:{suffix})?=(.+)")- properties = []root = self._install_dir