fix: Resolve compilation errors in XrefsEndpoints for Ghidra 11+
- Update reference handling to use arrays instead of iterators - Simplify getCurrentAddress implementation for Ghidra 11+
This commit is contained in:
parent
96788f35fc
commit
5dc59ced59
@ -104,9 +104,8 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
|
|
||||||
// Get references to this address
|
// Get references to this address
|
||||||
if (toAddr != null) {
|
if (toAddr != null) {
|
||||||
ReferenceIterator refsTo = refManager.getReferencesTo(toAddr);
|
Reference[] refsToArray = refManager.getReferencesTo(toAddr);
|
||||||
while (refsTo.hasNext()) {
|
for (Reference ref : refsToArray) {
|
||||||
Reference ref = refsTo.next();
|
|
||||||
if (refTypeStr != null && !ref.getReferenceType().getName().equalsIgnoreCase(refTypeStr)) {
|
if (refTypeStr != null && !ref.getReferenceType().getName().equalsIgnoreCase(refTypeStr)) {
|
||||||
continue; // Skip if type filter doesn't match
|
continue; // Skip if type filter doesn't match
|
||||||
}
|
}
|
||||||
@ -118,9 +117,8 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
|
|
||||||
// Get references from this address
|
// Get references from this address
|
||||||
if (fromAddr != null) {
|
if (fromAddr != null) {
|
||||||
ReferenceIterator refsFrom = refManager.getReferencesFrom(fromAddr);
|
Reference[] refsFromArray = refManager.getReferencesFrom(fromAddr);
|
||||||
while (refsFrom.hasNext()) {
|
for (Reference ref : refsFromArray) {
|
||||||
Reference ref = refsFrom.next();
|
|
||||||
if (refTypeStr != null && !ref.getReferenceType().getName().equalsIgnoreCase(refTypeStr)) {
|
if (refTypeStr != null && !ref.getReferenceType().getName().equalsIgnoreCase(refTypeStr)) {
|
||||||
continue; // Skip if type filter doesn't match
|
continue; // Skip if type filter doesn't match
|
||||||
}
|
}
|
||||||
@ -275,13 +273,7 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
PluginTool tool = getTool();
|
PluginTool tool = getTool();
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
try {
|
try {
|
||||||
// Get the current location service from the tool
|
// Try to get the address from the code browser service (most reliable in Ghidra 11+)
|
||||||
ghidra.app.services.GoToService goToService = tool.getService(ghidra.app.services.GoToService.class);
|
|
||||||
if (goToService != null) {
|
|
||||||
return goToService.getDefaultAddress(program);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to get the address from the code browser service
|
|
||||||
ghidra.app.services.CodeViewerService codeViewerService =
|
ghidra.app.services.CodeViewerService codeViewerService =
|
||||||
tool.getService(ghidra.app.services.CodeViewerService.class);
|
tool.getService(ghidra.app.services.CodeViewerService.class);
|
||||||
if (codeViewerService != null) {
|
if (codeViewerService != null) {
|
||||||
@ -294,13 +286,19 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to get the address from the listing service
|
// Try to get the address from the current listing
|
||||||
ghidra.app.services.ProgramManager programManager =
|
ghidra.app.services.ProgramManager programManager =
|
||||||
tool.getService(ghidra.app.services.ProgramManager.class);
|
tool.getService(ghidra.app.services.ProgramManager.class);
|
||||||
if (programManager != null) {
|
if (programManager != null && programManager.getCurrentProgram() == program) {
|
||||||
ghidra.program.util.ProgramLocation location = programManager.getCurrentLocation();
|
ghidra.program.util.ProgramSelection selection = programManager.getCurrentSelection();
|
||||||
if (location != null && location.getProgram() == program) {
|
if (selection != null && !selection.isEmpty()) {
|
||||||
return location.getAddress();
|
return selection.getMinAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try the current highlight selection
|
||||||
|
selection = programManager.getCurrentHighlight();
|
||||||
|
if (selection != null && !selection.isEmpty()) {
|
||||||
|
return selection.getMinAddress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user