fix: Update XrefsEndpoints.java for Ghidra 11 API compatibility
- Fix reference handling using ReferenceIterator - Use proper Ghidra 11 services for current address retrieval - Implement location tracking via LocationService and SelectionService
This commit is contained in:
parent
5dc59ced59
commit
2b1fe6c4e1
@ -104,8 +104,9 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
|
|
||||||
// Get references to this address
|
// Get references to this address
|
||||||
if (toAddr != null) {
|
if (toAddr != null) {
|
||||||
Reference[] refsToArray = refManager.getReferencesTo(toAddr);
|
ReferenceIterator refsTo = refManager.getReferencesTo(toAddr);
|
||||||
for (Reference ref : refsToArray) {
|
while (refsTo.hasNext()) {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
@ -117,8 +118,9 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
|
|
||||||
// Get references from this address
|
// Get references from this address
|
||||||
if (fromAddr != null) {
|
if (fromAddr != null) {
|
||||||
Reference[] refsFromArray = refManager.getReferencesFrom(fromAddr);
|
ReferenceIterator refsFrom = refManager.getReferencesFrom(fromAddr);
|
||||||
for (Reference ref : refsFromArray) {
|
while (refsFrom.hasNext()) {
|
||||||
|
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
|
||||||
}
|
}
|
||||||
@ -286,19 +288,28 @@ public class XrefsEndpoints extends AbstractEndpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to get the address from the current listing
|
// Try to get the address from the current listing using LocationService
|
||||||
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 && programManager.getCurrentProgram() == program) {
|
if (programManager != null && programManager.getCurrentProgram() == program) {
|
||||||
ghidra.program.util.ProgramSelection selection = programManager.getCurrentSelection();
|
// In Ghidra 11+, use the current cursor location
|
||||||
if (selection != null && !selection.isEmpty()) {
|
ghidra.app.services.LocationService locationService =
|
||||||
return selection.getMinAddress();
|
tool.getService(ghidra.app.services.LocationService.class);
|
||||||
|
if (locationService != null) {
|
||||||
|
ghidra.program.util.ProgramLocation location = locationService.getLocation();
|
||||||
|
if (location != null && location.getProgram() == program) {
|
||||||
|
return location.getAddress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try the current highlight selection
|
// Try selection service as a last resort
|
||||||
selection = programManager.getCurrentHighlight();
|
ghidra.app.services.SelectionService selectionService =
|
||||||
if (selection != null && !selection.isEmpty()) {
|
tool.getService(ghidra.app.services.SelectionService.class);
|
||||||
return selection.getMinAddress();
|
if (selectionService != null) {
|
||||||
|
ghidra.program.util.ProgramSelection selection = selectionService.getCurrentSelection();
|
||||||
|
if (selection != null && !selection.isEmpty()) {
|
||||||
|
return selection.getMinAddress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user