Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1288: added system error event logic

d-millarf242f3fc559d
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgInitialBreakpointEvent.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgInitialBreakpointEvent.java
new file mode 100644
index 0000000000..9b428d0c60
--- /dev/null
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgInitialBreakpointEvent.java
@@ -0,0 +1,25 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package agent.dbgeng.manager.evt;
+
+import agent.dbgeng.dbgeng.DebugBreakpoint;
+
+public class DbgInitialBreakpointEvent extends AbstractDbgEvent<DebugBreakpoint> {
+
+ public DbgInitialBreakpointEvent(DebugBreakpoint info) {
+ super(info);
+ }
+}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgInitialModuleLoadEvent.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgInitialModuleLoadEvent.java
new file mode 100644
index 0000000000..b1aaca8d20
--- /dev/null
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgInitialModuleLoadEvent.java
@@ -0,0 +1,25 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package agent.dbgeng.manager.evt;
+
+import agent.dbgeng.dbgeng.DebugModuleInfo;
+
+public class DbgInitialModuleLoadEvent extends AbstractDbgEvent<DebugModuleInfo> {
+
+ public DbgInitialModuleLoadEvent(DebugModuleInfo info) {
+ super(info);
+ }
+}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgSystemErrorEvent.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgSystemErrorEvent.java
new file mode 100644
index 0000000000..8c79fef490
--- /dev/null
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/evt/DbgSystemErrorEvent.java
@@ -0,0 +1,44 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package agent.dbgeng.manager.evt;
+
+/**
+ * The event corresponding with "{@code =thread-selected}"
+ */
+public class DbgSystemErrorEvent extends AbstractDbgEvent<Integer> {
+ private final int error;
+ private final int level;
+
+ /**
+ * The selected error ID must be specified by dbgeng.
+ *
+ * @param error dbgeng-provided id
+ */
+ public DbgSystemErrorEvent(int error, int level) {
+ super(error);
+ this.error = error;
+ this.level = level;
+ }
+
+ public int getError() {
+ return error;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgDebugEventCallbacksAdapter.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgDebugEventCallbacksAdapter.java
index d836efd2d4..034f5ab19a 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgDebugEventCallbacksAdapter.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgDebugEventCallbacksAdapter.java
@@ -132,6 +132,11 @@ public class DbgDebugEventCallbacksAdapter extends DebugEventCallbacksAdapter {
return checkInterrupt(DebugStatus.NO_CHANGE);
}
+ @Override
+ public DebugStatus systemError(int error, int level) {
+ return checkInterrupt(manager.processEvent(new DbgSystemErrorEvent(error, level)));
+ }
+
/*
@Override
public DebugStatus changeDebuggeeState(BitmaskSet<ChangeDebuggeeState> flags, long argument) {
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgManagerImpl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgManagerImpl.java
index e969b3b5a9..8d142cf56c 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgManagerImpl.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/manager/impl/DbgManagerImpl.java
@@ -594,6 +594,7 @@ public class DbgManagerImpl implements DbgManager {
handlerMap.put(DbgStateChangedEvent.class, this::processStateChanged);
handlerMap.put(DbgSessionSelectedEvent.class, this::processSessionSelected);
handlerMap.put(DbgSystemsEvent.class, this::processSystemsEvent);
+ handlerMap.putVoid(DbgSystemErrorEvent.class, this::processSystemErrorEvent);
handlerMap.putVoid(DbgCommandDoneEvent.class, this::processDefault);
handlerMap.putVoid(DbgStoppedEvent.class, this::processDefault);
handlerMap.putVoid(DbgRunningEvent.class, this::processDefault);
@@ -1041,7 +1042,14 @@ public class DbgManagerImpl implements DbgManager {
return statusMap.get(evt.getClass());
}
+ protected void processSystemErrorEvent(DbgSystemErrorEvent evt, Void v) {
+ getEventListeners().fire.eventSelected(evt, evt.getCause());
+ String error = "SystemError " + evt.getError() + ":" + evt.getLevel();
+ getEventListeners().fire.consoleOutput(error, 0);
+ }
+
protected void processConsoleOutput(DbgConsoleOutputEvent evt, Void v) {
+ getEventListeners().fire.eventSelected(evt, evt.getCause());
getEventListeners().fire.consoleOutput(evt.getInfo(), evt.getMask());
}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetEventImpl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetEventImpl.java
index 65eaad2ff8..0559b2cafb 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetEventImpl.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/model/impl/DbgModelTargetEventImpl.java
@@ -126,6 +126,26 @@ public class DbgModelTargetEventImpl extends DbgModelTargetObjectImpl
changeAttributes(List.of(), List.of(), Map.of( //
MODIFIED_ATTRIBUTE_NAME, true), "Refreshed");
}
+ if (event instanceof DbgInitialBreakpointEvent &&
+ getEventIndex() == DebugFilterOrdinals.DEBUG_FILTER_INITIAL_BREAKPOINT.ordinal()) {
+ changeAttributes(List.of(), List.of(), Map.of( //
+ MODIFIED_ATTRIBUTE_NAME, true), "Refreshed");
+ }
+ if (event instanceof DbgInitialModuleLoadEvent &&
+ getEventIndex() == DebugFilterOrdinals.DEBUG_FILTER_INITIAL_MODULE_LOAD.ordinal()) {
+ changeAttributes(List.of(), List.of(), Map.of( //
+ MODIFIED_ATTRIBUTE_NAME, true), "Refreshed");
+ }
+ if (event instanceof DbgSystemErrorEvent &&
+ getEventIndex() == DebugFilterOrdinals.DEBUG_FILTER_SYSTEM_ERROR.ordinal()) {
+ changeAttributes(List.of(), List.of(), Map.of( //
+ MODIFIED_ATTRIBUTE_NAME, true), "Refreshed");
+ }
+ if (event instanceof DbgConsoleOutputEvent &&
+ getEventIndex() == DebugFilterOrdinals.DEBUG_FILTER_DEBUGGEE_OUTPUT.ordinal()) {
+ changeAttributes(List.of(), List.of(), Map.of( //
+ MODIFIED_ATTRIBUTE_NAME, true), "Refreshed");
+ }
}
@Override