GP-5329 fixed bug in LocalBsimQueryScript

This commit is contained in:
ghidragon 2025-01-30 17:13:06 -05:00 committed by ghidra1
parent 1d57b129b3
commit def22c5e19

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -57,6 +57,10 @@ public class LocalBSimQueryScript extends GhidraScript {
popup("This script cannot be run headlessly."); popup("This script cannot be run headlessly.");
return; return;
} }
if (currentProgram == null) {
popup("This script requires a program to be open in the tool");
return;
}
Set<Function> sourceFuncs = new HashSet<>(); Set<Function> sourceFuncs = new HashSet<>();
if (currentSelection == null) { if (currentSelection == null) {
@ -341,7 +345,6 @@ public class LocalBSimQueryScript extends GhidraScript {
class CompareMatchesExecutor implements TableChooserExecutor { class CompareMatchesExecutor implements TableChooserExecutor {
private FunctionComparisonService compareService; private FunctionComparisonService compareService;
private MatchedFunctionComparisonModel model;
public CompareMatchesExecutor() { public CompareMatchesExecutor() {
compareService = state.getTool().getService(FunctionComparisonService.class); compareService = state.getTool().getService(FunctionComparisonService.class);
@ -355,11 +358,7 @@ public class LocalBSimQueryScript extends GhidraScript {
@Override @Override
public boolean execute(AddressableRowObject rowObject) { public boolean execute(AddressableRowObject rowObject) {
LocalBSimMatch match = (LocalBSimMatch) rowObject; LocalBSimMatch match = (LocalBSimMatch) rowObject;
if (model == null) { compareService.createComparison(match.getSourceFunc(), match.getTargetFunc());
model = new MatchedFunctionComparisonModel();
compareService.createCustomComparison(model, null);
}
model.addMatch(match.getSourceFunc(), match.getTargetFunc());
return false; return false;
} }
} }