Skip to content

Ghidra is a software reverse engineering (SRE) framework

osig status -> osgi state, and it's actually the osgi state

Jason P. Leasuredd82dc5f24e1
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
index 373fab27e8..b3ed9433b2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/BundleStatusTableModel.java
@@ -25,6 +25,8 @@ import java.util.stream.Collectors;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
+import org.osgi.framework.Bundle;
+
import docking.widgets.table.*;
import generic.jar.ResourceFile;
import generic.util.Path;
@@ -402,22 +404,24 @@ public class BundleStatusTableModel
private class OSGiStatusColumn extends Column<String> {
OSGiStatusColumn() {
- super("OSGi Status");
+ super("OSGi State");
}
@Override
public String getValue(BundleStatus status, Settings settings, List<BundleStatus> data,
ServiceProvider serviceProvider0) throws IllegalArgumentException {
if (!status.isEnabled()) {
- return "";
- }
- if (status.isBusy()) {
- return "...";
+ return "(disabled)";
}
- if (status.isActive()) {
- return "Active";
+ GhidraBundle bundle = bundleHost.getExistingGhidraBundle(status.getFile());
+ if (bundle != null) {
+ Bundle osgiBundle = bundle.getOSGiBundle();
+ if (osgiBundle != null) {
+ return OSGiUtils.getStateString(osgiBundle);
+ }
+ return "uninstalled";
}
- return "Inactive";
+ return "(enabled)";
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/OSGiUtils.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/OSGiUtils.java
index f22ed26246..2e37e79306 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/OSGiUtils.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/osgi/OSGiUtils.java
@@ -74,6 +74,25 @@ public class OSGiUtils {
}
}
+ static String getStateString(Bundle bundle) {
+ switch (bundle.getState()) {
+ case Bundle.UNINSTALLED:
+ return "UNINSTALLED";
+ case Bundle.INSTALLED:
+ return "INSTALLED";
+ case Bundle.RESOLVED:
+ return "RESOLVED";
+ case Bundle.STARTING:
+ return "STARTING";
+ case Bundle.STOPPING:
+ return "STOPPING";
+ case Bundle.ACTIVE:
+ return "ACTIVE";
+ default:
+ return "unknown state";
+ }
+ }
+
/**
* parse Import-Package string from a bundle manifest
*
@@ -126,10 +145,10 @@ public class OSGiUtils {
static Stream<Path> getClasspathElements() {
String classpathStr = System.getProperty("java.class.path");
return Collections.list(new StringTokenizer(classpathStr, File.pathSeparator))
- .stream()
- .map(String.class::cast)
- .map(Paths::get)
- .map(Path::normalize);
+ .stream()
+ .map(String.class::cast)
+ .map(Paths::get)
+ .map(Path::normalize);
}
static void collectPackagesFromDirectory(Path dirPath, Set<String> packages) {
@@ -137,9 +156,9 @@ public class OSGiUtils {
Files.walk(dirPath).filter(p -> p.toString().endsWith(".class")).forEach(path -> {
String relativePath = dirPath.relativize(path).toString();
int lastSlash = relativePath.lastIndexOf(File.separatorChar);
- packages
- .add(lastSlash > 0 ? relativePath.substring(0, lastSlash).replace(File.separatorChar, '.')
- : "");
+ packages.add(lastSlash > 0
+ ? relativePath.substring(0, lastSlash).replace(File.separatorChar, '.')
+ : "");
});
}
@@ -154,7 +173,8 @@ public class OSGiUtils {
j.stream().filter(entry -> entry.getName().endsWith(".class")).forEach(jarEntry -> {
String entryName = jarEntry.getName();
int lastSlash = entryName.lastIndexOf('/');
- packages.add(lastSlash > 0 ? entryName.substring(0, lastSlash).replace('/', '.') : "");
+ packages.add(
+ lastSlash > 0 ? entryName.substring(0, lastSlash).replace('/', '.') : "");
});
}
}