mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 04:09:40 +08:00
@@ -371,7 +371,7 @@ public abstract class GhidraScript extends FlatProgramAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DomainFolder getProjectRootFolder() {
|
public DomainFolder getProjectRootFolder() {
|
||||||
if (isRunningHeadless()) {
|
if (isRunningHeadless()) {
|
||||||
Project project = state.getProject();
|
Project project = state.getProject();
|
||||||
ProjectData projectData = project.getProjectData();
|
ProjectData projectData = project.getProjectData();
|
||||||
|
|||||||
@@ -2473,7 +2473,7 @@ public class FlatProgramAPI {
|
|||||||
* the root domain folder.
|
* the root domain folder.
|
||||||
* @return the root domain folder of the current project
|
* @return the root domain folder of the current project
|
||||||
*/
|
*/
|
||||||
protected DomainFolder getProjectRootFolder() {
|
public DomainFolder getProjectRootFolder() {
|
||||||
Project project = AppInfo.getActiveProject();
|
Project project = AppInfo.getActiveProject();
|
||||||
ProjectData projectData = project.getProjectData();
|
ProjectData projectData = project.getProjectData();
|
||||||
DomainFolder folder = projectData.getRootFolder();
|
DomainFolder folder = projectData.getRootFolder();
|
||||||
|
|||||||
@@ -69,11 +69,6 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||||||
// Setup python cache directory
|
// Setup python cache directory
|
||||||
PythonUtils.setupPythonCacheDir(TaskMonitor.DUMMY);
|
PythonUtils.setupPythonCacheDir(TaskMonitor.DUMMY);
|
||||||
|
|
||||||
// Enable protected java methods to be accessed from python sub-classes.
|
|
||||||
// This is necessary to be able to call protected GhidraScript/FlatProgram API
|
|
||||||
// methods from a python script.
|
|
||||||
System.setProperty("python.security.respectJavaAccessibility", "false");
|
|
||||||
|
|
||||||
// Indicate that we've initialized the python environment, which should
|
// Indicate that we've initialized the python environment, which should
|
||||||
// only happen once.
|
// only happen once.
|
||||||
pythonInitialized = true;
|
pythonInitialized = true;
|
||||||
@@ -348,12 +343,16 @@ public class GhidraPythonInterpreter extends InteractiveInterpreter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add public and protected methods (only once). Ignore inner classes.
|
// Add public methods (only once). Ignore inner classes.
|
||||||
|
//
|
||||||
|
// NOTE: We currently do not have a way to safely add protected methods. Disabling
|
||||||
|
// python.security.respectJavaAccessibility and adding in protected methods in the below
|
||||||
|
// loop caused an InaccessibleObjectException for some users (relating to core Java
|
||||||
|
// modules, not the GhidraScript class hierarchy).
|
||||||
if (!scriptMethodsInjected) {
|
if (!scriptMethodsInjected) {
|
||||||
for (Method method : scriptClass.getDeclaredMethods()) {
|
for (Method method : scriptClass.getDeclaredMethods()) {
|
||||||
if (!method.getName().contains("$") &&
|
if (!method.getName().contains("$") &&
|
||||||
(Modifier.isPublic(method.getModifiers()) ||
|
Modifier.isPublic(method.getModifiers())) {
|
||||||
Modifier.isProtected(method.getModifiers()))) {
|
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
setMethod(script, method);
|
setMethod(script, method);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user