Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1288: DebugControl filter additions

d-millarb54012395ce8
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugControl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugControl.java
index 125dee70f6..c7ac845713 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugControl.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugControl.java
@@ -356,4 +356,29 @@ public interface DebugControl extends DebugControlReentrant {
int getExecutingProcessorType();
int getDebuggeeType();
+
+ DebugFilterInformation getNumberEventFilters();
+
+ String getEventFilterText(int index);
+
+ String getEventFilterCommand(int index);
+
+ void setEventFilterCommand(int index, String text);
+
+ DebugSpecificFilterInformation getSpecificFilterParameters(int start, int count);
+
+ void setSpecificFilterParameters(int start, int count, DebugSpecificFilterInformation info);
+
+ String getSpecificFilterArgument(int index);
+
+ void setSpecificFilterArgument(int index, String arg);
+
+ DebugExceptionFilterInformation getExceptionFilterParameters(int start, int[] codes, int count);
+
+ void setExceptionFilterParameters(int count, DebugExceptionFilterInformation info);
+
+ String getExceptionFilterSecondCommand(int index);
+
+ void setExceptionFilterSecondCommand(int index, String cmd);
+
}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugExceptionFilterInformation.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugExceptionFilterInformation.java
new file mode 100644
index 0000000000..252afcdc85
--- /dev/null
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugExceptionFilterInformation.java
@@ -0,0 +1,42 @@
+/* ###
+ * 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.dbgeng;
+
+import agent.dbgeng.jna.dbgeng.DbgEngNative.DEBUG_EXCEPTION_FILTER_PARAMETERS;
+
+public class DebugExceptionFilterInformation {
+
+ private int nParams;
+ private DEBUG_EXCEPTION_FILTER_PARAMETERS[] parameters;
+
+ public DebugExceptionFilterInformation(int nParams,
+ DEBUG_EXCEPTION_FILTER_PARAMETERS[] parameters) {
+ this.nParams = nParams;
+ this.parameters = parameters;
+ }
+
+ public int getNumberOfParameters() {
+ return nParams;
+ }
+
+ public DEBUG_EXCEPTION_FILTER_PARAMETERS getParameter(int paramNumber) {
+ return parameters[paramNumber];
+ }
+
+ public DEBUG_EXCEPTION_FILTER_PARAMETERS[] getParameters() {
+ return parameters;
+ }
+}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugFilterInformation.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugFilterInformation.java
new file mode 100644
index 0000000000..5b22b62212
--- /dev/null
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugFilterInformation.java
@@ -0,0 +1,42 @@
+/* ###
+ * 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.dbgeng;
+
+public class DebugFilterInformation {
+
+ private int nEvents;
+ private int nSpecificExceptions;
+ private int nArbitraryExceptions;
+
+ public DebugFilterInformation(int nEvents, int nSpecificExceptions, int nArbitraryExceptions) {
+ this.nEvents = nEvents;
+ this.nSpecificExceptions = nSpecificExceptions;
+ this.nArbitraryExceptions = nArbitraryExceptions;
+ }
+
+ public int getNumberEvents() {
+ return nEvents;
+ }
+
+ public int getNumberSpecificExceptions() {
+ return nSpecificExceptions;
+ }
+
+ public int getNumberArbitraryExceptions() {
+ return nArbitraryExceptions;
+ }
+
+}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugSpecificFilterInformation.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugSpecificFilterInformation.java
new file mode 100644
index 0000000000..b1cd3e8808
--- /dev/null
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/dbgeng/DebugSpecificFilterInformation.java
@@ -0,0 +1,42 @@
+/* ###
+ * 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.dbgeng;
+
+import agent.dbgeng.jna.dbgeng.DbgEngNative.DEBUG_SPECIFIC_FILTER_PARAMETERS;
+
+public class DebugSpecificFilterInformation {
+
+ private int nParams;
+ private DEBUG_SPECIFIC_FILTER_PARAMETERS[] parameters;
+
+ public DebugSpecificFilterInformation(int nParams,
+ DEBUG_SPECIFIC_FILTER_PARAMETERS[] parameters) {
+ this.nParams = nParams;
+ this.parameters = parameters;
+ }
+
+ public int getNumberOfParameters() {
+ return nParams;
+ }
+
+ public DEBUG_SPECIFIC_FILTER_PARAMETERS getParameter(int paramNumber) {
+ return parameters[paramNumber];
+ }
+
+ public DEBUG_SPECIFIC_FILTER_PARAMETERS[] getParameters() {
+ return parameters;
+ }
+}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/impl/dbgeng/control/DebugControlImpl1.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/impl/dbgeng/control/DebugControlImpl1.java
index 8f5974245a..056ea0a3f6 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/impl/dbgeng/control/DebugControlImpl1.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/impl/dbgeng/control/DebugControlImpl1.java
@@ -31,8 +31,7 @@ import agent.dbgeng.dbgeng.DebugClient.DebugStatus;
import agent.dbgeng.dbgeng.DebugValue.DebugValueType;
import agent.dbgeng.impl.dbgeng.DbgEngUtil;
import agent.dbgeng.impl.dbgeng.breakpoint.DebugBreakpointInternal;
-import agent.dbgeng.jna.dbgeng.DbgEngNative.DEBUG_STACK_FRAME;
-import agent.dbgeng.jna.dbgeng.DbgEngNative.DEBUG_VALUE;
+import agent.dbgeng.jna.dbgeng.DbgEngNative.*;
import agent.dbgeng.jna.dbgeng.breakpoint.IDebugBreakpoint;
import agent.dbgeng.jna.dbgeng.breakpoint.WrapIDebugBreakpoint;
import agent.dbgeng.jna.dbgeng.control.IDebugControl;
@@ -301,4 +300,126 @@ public class DebugControlImpl1 implements DebugControlInternal {
COMUtils.checkRC(jnaControl.GetDebuggeeType(ulClass, ulQualifier));
return ulClass.getValue().intValue();
}
+
+ @Override
+ public DebugFilterInformation getNumberEventFilters() {
+ ULONGByReference ulSpecificEvents = new ULONGByReference();
+ ULONGByReference ulSpecificExceptions = new ULONGByReference();
+ ULONGByReference ulArbitraryExceptions = new ULONGByReference();
+ COMUtils.checkRC(jnaControl.GetNumberEventFilters(ulSpecificEvents, ulSpecificExceptions,
+ ulArbitraryExceptions));
+ return new DebugFilterInformation(
+ ulSpecificEvents.getValue().intValue(),
+ ulSpecificExceptions.getValue().intValue(),
+ ulArbitraryExceptions.getValue().intValue());
+ }
+
+ @Override
+ public String getEventFilterText(int index) {
+ ULONG ulIndex = new ULONG(index);
+ ULONGByReference ulTextSize = new ULONGByReference();
+ COMUtils.checkRC(jnaControl.GetEventFilterText(ulIndex, null, new ULONG(0), ulTextSize));
+ byte[] buffer = new byte[ulTextSize.getValue().intValue()];
+ ULONG ulBufferSize = ulTextSize.getValue();
+ COMUtils.checkRC(jnaControl.GetEventFilterText(ulIndex, buffer, ulBufferSize, null));
+ return Native.toString(buffer);
+ }
+
+ @Override
+ public String getEventFilterCommand(int index) {
+ ULONG ulIndex = new ULONG(index);
+ ULONGByReference ulCommandSize = new ULONGByReference();
+ COMUtils.checkRC(
+ jnaControl.GetEventFilterCommand(ulIndex, null, new ULONG(0), ulCommandSize));
+ byte[] buffer = new byte[ulCommandSize.getValue().intValue()];
+ ULONG ulBufferSize = ulCommandSize.getValue();
+ COMUtils.checkRC(jnaControl.GetEventFilterCommand(ulIndex, buffer, ulBufferSize, null));
+ return Native.toString(buffer);
+ }
+
+ @Override
+ public void setEventFilterCommand(int index, String text) {
+ ULONG ulIndex = new ULONG(index);
+ COMUtils.checkRC(jnaControl.SetEventFilterCommand(ulIndex, text));
+ }
+
+ @Override
+ public DebugSpecificFilterInformation getSpecificFilterParameters(int start, int count) {
+ ULONG ulStart = new ULONG(start);
+ ULONG ulCount = new ULONG(count);
+ DEBUG_SPECIFIC_FILTER_PARAMETERS[] pParams = new DEBUG_SPECIFIC_FILTER_PARAMETERS[count];
+ COMUtils.checkRC(jnaControl.GetSpecificFilterParameters(ulStart, ulCount, pParams));
+ return new DebugSpecificFilterInformation(count, pParams);
+ }
+
+ @Override
+ public void setSpecificFilterParameters(int start, int count,
+ DebugSpecificFilterInformation info) {
+ ULONG ulStart = new ULONG(start);
+ ULONG ulCount = new ULONG(count);
+ COMUtils.checkRC(
+ jnaControl.SetSpecificFilterParameters(ulStart, ulCount, info.getParameters()));
+ }
+
+ @Override
+ public String getSpecificFilterArgument(int index) {
+ ULONG ulIndex = new ULONG(index);
+ ULONGByReference ulArgumentSize = new ULONGByReference();
+ COMUtils.checkRC(
+ jnaControl.GetSpecificFilterArgument(ulIndex, null, new ULONG(0), ulArgumentSize));
+ byte[] buffer = new byte[ulArgumentSize.getValue().intValue()];
+ ULONG ulBufferSize = ulArgumentSize.getValue();
+ COMUtils.checkRC(
+ jnaControl.GetSpecificFilterArgument(ulIndex, buffer, ulBufferSize, null));
+ return Native.toString(buffer);
+ }
+
+ @Override
+ public void setSpecificFilterArgument(int index, String arg) {
+ ULONG ulIndex = new ULONG(index);
+ COMUtils.checkRC(jnaControl.SetSpecificFilterArgument(ulIndex, arg));
+ }
+
+ @Override
+ public DebugExceptionFilterInformation getExceptionFilterParameters(int start, int[] codes,
+ int count) {
+ ULONG ulStart = new ULONG(start);
+ ULONG[] ulCodes = new ULONG[codes.length];
+ for (int i = 0; i < codes.length; i++) {
+ ulCodes[i] = new ULONG(codes[i]);
+ }
+ ULONG ulCount = new ULONG(count);
+ DEBUG_EXCEPTION_FILTER_PARAMETERS[] pParams = new DEBUG_EXCEPTION_FILTER_PARAMETERS[count];
+ COMUtils.checkRC(
+ jnaControl.GetExceptionFilterParameters(ulCount, ulCodes, ulStart, pParams));
+ return new DebugExceptionFilterInformation(count, pParams);
+ }
+
+ @Override
+ public void setExceptionFilterParameters(int count,
+ DebugExceptionFilterInformation info) {
+ ULONG ulCount = new ULONG(count);
+ COMUtils.checkRC(
+ jnaControl.SetExceptionFilterParameters(ulCount, info.getParameters()));
+ }
+
+ @Override
+ public String getExceptionFilterSecondCommand(int index) {
+ ULONG ulIndex = new ULONG(index);
+ ULONGByReference ulCommandSize = new ULONGByReference();
+ COMUtils.checkRC(
+ jnaControl.GetExceptionFilterSecondCommand(ulIndex, null, new ULONG(0), ulCommandSize));
+ byte[] buffer = new byte[ulCommandSize.getValue().intValue()];
+ ULONG ulBufferSize = ulCommandSize.getValue();
+ COMUtils.checkRC(
+ jnaControl.GetExceptionFilterSecondCommand(ulIndex, buffer, ulBufferSize, null));
+ return Native.toString(buffer);
+ }
+
+ @Override
+ public void setExceptionFilterSecondCommand(int index, String cmd) {
+ ULONG ulIndex = new ULONG(index);
+ COMUtils.checkRC(jnaControl.SetExceptionFilterSecondCommand(ulIndex, cmd));
+ }
+
}
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/IDebugControl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/IDebugControl.java
index 5490ad044b..8f3a095a6f 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/IDebugControl.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/IDebugControl.java
@@ -206,7 +206,7 @@ public interface IDebugControl extends IUnknown {
HRESULT SetSpecificFilterArgument(ULONG Index, String Argument);
- HRESULT GetExceptionFilterParameters(ULONG Count, ULONGByReference Codes, ULONG Start,
+ HRESULT GetExceptionFilterParameters(ULONG Count, ULONG[] Codes, ULONG Start,
DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params);
HRESULT SetExceptionFilterParameters(ULONG Count,
diff --git a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/WrapIDebugControl.java b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/WrapIDebugControl.java
index b7268c227f..be19407fb9 100644
--- a/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/WrapIDebugControl.java
+++ b/Ghidra/Debug/Debugger-agent-dbgeng/src/main/java/agent/dbgeng/jna/dbgeng/control/WrapIDebugControl.java
@@ -228,7 +228,7 @@ public class WrapIDebugControl extends UnknownWithUtils implements IDebugControl
}
@Override
- public HRESULT GetExceptionFilterParameters(ULONG Count, ULONGByReference Codes, ULONG Start,
+ public HRESULT GetExceptionFilterParameters(ULONG Count, ULONG[] Codes, ULONG Start,
DEBUG_EXCEPTION_FILTER_PARAMETERS[] Params) {
return _invokeHR(VTIndices.SET_EVENT_FILTER_COMMAND, getPointer(), Count, Codes, Start,
Params);