mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GP-605: Fix for dbgeng
This commit is contained in:
parent
c481a87ab5
commit
aa18341dca
3 changed files with 31 additions and 23 deletions
|
@ -145,7 +145,8 @@ public class DebugSystemObjectsImpl1 implements DebugSystemObjectsInternal {
|
||||||
ULONG ulHandle = new ULONG(systemId);
|
ULONG ulHandle = new ULONG(systemId);
|
||||||
ULONGByReference pulId = new ULONGByReference();
|
ULONGByReference pulId = new ULONGByReference();
|
||||||
HRESULT hr = jnaSysobj.GetThreadIdBySystemId(ulHandle, pulId);
|
HRESULT hr = jnaSysobj.GetThreadIdBySystemId(ulHandle, pulId);
|
||||||
if (hr.equals(COMUtilsExtra.E_UNEXPECTED) || hr.equals(COMUtilsExtra.E_NOTIMPLEMENTED)) {
|
if (hr.equals(COMUtilsExtra.E_UNEXPECTED) || hr.equals(COMUtilsExtra.E_NOTIMPLEMENTED) ||
|
||||||
|
hr.equals(COMUtilsExtra.E_NOINTERFACE)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
COMUtils.checkRC(hr);
|
COMUtils.checkRC(hr);
|
||||||
|
|
|
@ -28,29 +28,34 @@ import agent.dbgmodel.dbgmodel.debughost.*;
|
||||||
import agent.dbgmodel.dbgmodel.main.ModelObject;
|
import agent.dbgmodel.dbgmodel.main.ModelObject;
|
||||||
import agent.dbgmodel.jna.dbgmodel.DbgModelNative.ModelObjectKind;
|
import agent.dbgmodel.jna.dbgmodel.DbgModelNative.ModelObjectKind;
|
||||||
import ghidra.dbg.util.PathUtils;
|
import ghidra.dbg.util.PathUtils;
|
||||||
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
public class HDMAUtil {
|
public class HDMAUtil {
|
||||||
|
|
||||||
private DataModelManager1 manager;
|
|
||||||
private DebugHost host;
|
|
||||||
private DebugClient client;
|
private DebugClient client;
|
||||||
|
private HostDataModelAccess access;
|
||||||
|
|
||||||
public HDMAUtil(HostDataModelAccess access) {
|
public HDMAUtil(HostDataModelAccess access) {
|
||||||
manager = access.getManager();
|
this.access = access;
|
||||||
host = access.getHost();
|
this.client = access.getClient();
|
||||||
client = access.getClient();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataModelManager1 getManager() {
|
public DataModelManager1 getManager() {
|
||||||
return manager;
|
return access.getManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugHost getHost() {
|
public DebugHost getHost() {
|
||||||
return host;
|
return access.getHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelObject getRootNamespace() {
|
public ModelObject getRootNamespace() {
|
||||||
return getManager().getRootNamespace();
|
ModelObject rootNamespace = getManager().getRootNamespace();
|
||||||
|
if (rootNamespace == null) {
|
||||||
|
Msg.debug(this, "resetting HostDataModelAccess manager/host " + access);
|
||||||
|
access.getDataModel();
|
||||||
|
rootNamespace = getManager().getRootNamespace();
|
||||||
|
}
|
||||||
|
return rootNamespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DebugHostContext getCurrentContext() {
|
public DebugHostContext getCurrentContext() {
|
||||||
|
@ -110,8 +115,8 @@ public class HDMAUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelObject getMethod(List<String> path) {
|
public ModelObject getMethod(List<String> path) {
|
||||||
DebugHostEvaluator2 eval = host.asEvaluator();
|
DebugHostEvaluator2 eval = getHost().asEvaluator();
|
||||||
DebugHostContext context = host.getCurrentContext();
|
DebugHostContext context = getHost().getCurrentContext();
|
||||||
List<String> npath = PathUtils.parent(path);
|
List<String> npath = PathUtils.parent(path);
|
||||||
int last = path.size() - 1;
|
int last = path.size() - 1;
|
||||||
String cmd = path.get(last);
|
String cmd = path.get(last);
|
||||||
|
@ -158,24 +163,23 @@ public class HDMAUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ModelObject evaluatePredicate(ModelObject target, String call) {
|
private ModelObject evaluatePredicate(ModelObject target, String call) {
|
||||||
DebugHostEvaluator2 eval = host.asEvaluator();
|
DebugHostEvaluator2 eval = getHost().asEvaluator();
|
||||||
DebugHostContext context = host.getCurrentContext();
|
DebugHostContext context = getHost().getCurrentContext();
|
||||||
return eval.evaluateExtendedExpression(context, new WString(call), target);
|
return eval.evaluateExtendedExpression(context, new WString(call), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelObject getSession(String id) {
|
public ModelObject getSession(String id) {
|
||||||
ModelObject sessions = getRootNamespace().getKeyValue("Debugger").getKeyValue("Sessions");
|
return getRootNamespace().getKeyValue("Debugger").getKeyValue("Sessions");
|
||||||
return sessions.getChild(manager, string2variant(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelObject getProcess(ModelObject session, String id) {
|
public ModelObject getProcess(ModelObject session, String id) {
|
||||||
ModelObject processes = session.getKeyValue("Processes");
|
ModelObject processes = session.getKeyValue("Processes");
|
||||||
return processes.getChild(manager, string2variant(id));
|
return processes.getChild(getManager(), string2variant(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelObject getThread(ModelObject process, String id) {
|
public ModelObject getThread(ModelObject process, String id) {
|
||||||
ModelObject threads = process.getKeyValue("Threads");
|
ModelObject threads = process.getKeyValue("Threads");
|
||||||
return threads.getChild(manager, string2variant(id));
|
return threads.getChild(getManager(), string2variant(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelObject getSettings() {
|
public ModelObject getSettings() {
|
||||||
|
@ -215,7 +219,7 @@ public class HDMAUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DebugModule> getModuleList() {
|
public List<DebugModule> getModuleList() {
|
||||||
DebugHostSymbols symbols = host.asSymbols();
|
DebugHostSymbols symbols = getHost().asSymbols();
|
||||||
DebugHostSymbolEnumerator enumerator = symbols.enumerateModules(getCurrentContext());
|
DebugHostSymbolEnumerator enumerator = symbols.enumerateModules(getCurrentContext());
|
||||||
List<DebugModule> modules = new ArrayList<DebugModule>();
|
List<DebugModule> modules = new ArrayList<DebugModule>();
|
||||||
DebugHostSymbol1 next;
|
DebugHostSymbol1 next;
|
||||||
|
@ -252,12 +256,12 @@ public class HDMAUtil {
|
||||||
|
|
||||||
public void setCurrentProcess(ModelObject context, String id) {
|
public void setCurrentProcess(ModelObject context, String id) {
|
||||||
VARIANT v = new VARIANT(id);
|
VARIANT v = new VARIANT(id);
|
||||||
context.switchTo(manager, v);
|
context.switchTo(getManager(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentThread(ModelObject context, String id) {
|
public void setCurrentThread(ModelObject context, String id) {
|
||||||
VARIANT v = new VARIANT(id);
|
VARIANT v = new VARIANT(id);
|
||||||
context.switchTo(manager, v);
|
context.switchTo(getManager(), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCtlId(ModelObject object) {
|
public String getCtlId(ModelObject object) {
|
||||||
|
|
|
@ -130,8 +130,7 @@ public class DataModelManagerImpl1 implements DataModelManagerInternal {
|
||||||
public ModelObject createSyntheticObject(DebugHostContext context) {
|
public ModelObject createSyntheticObject(DebugHostContext context) {
|
||||||
Pointer pContext = context.getPointer();
|
Pointer pContext = context.getPointer();
|
||||||
PointerByReference ppObject = new PointerByReference();
|
PointerByReference ppObject = new PointerByReference();
|
||||||
COMUtils.checkRC(
|
COMUtils.checkRC(jnaData.CreateSyntheticObject(pContext, ppObject));
|
||||||
jnaData.CreateSyntheticObject(pContext, ppObject));
|
|
||||||
|
|
||||||
WrapIModelObject wrap = new WrapIModelObject(ppObject.getValue());
|
WrapIModelObject wrap = new WrapIModelObject(ppObject.getValue());
|
||||||
try {
|
try {
|
||||||
|
@ -289,7 +288,11 @@ public class DataModelManagerImpl1 implements DataModelManagerInternal {
|
||||||
PointerByReference ppObject = new PointerByReference();
|
PointerByReference ppObject = new PointerByReference();
|
||||||
COMUtils.checkRC(jnaData.GetRootNamespace(ppObject));
|
COMUtils.checkRC(jnaData.GetRootNamespace(ppObject));
|
||||||
|
|
||||||
WrapIModelObject wrap = new WrapIModelObject(ppObject.getValue());
|
Pointer value = ppObject.getValue();
|
||||||
|
if (value == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
WrapIModelObject wrap = new WrapIModelObject(value);
|
||||||
try {
|
try {
|
||||||
return ModelObjectInternal.tryPreferredInterfaces(wrap::QueryInterface);
|
return ModelObjectInternal.tryPreferredInterfaces(wrap::QueryInterface);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue