mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-4354 fix comparing callees and thunks
This commit is contained in:
parent
5513be7146
commit
5ee04b24d0
1 changed files with 30 additions and 10 deletions
|
@ -95,31 +95,51 @@ public class CompareFuncsFromMatchedTokensAction extends AbstractMatchedTokensAc
|
||||||
currentPair.rightToken() == null) {
|
currentPair.rightToken() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FunctionComparisonService service = tool.getService(FunctionComparisonService.class);
|
|
||||||
if (service == null) {
|
|
||||||
Msg.error(this, "Function Comparison Service not found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FunctionComparisonProvider comparisonProvider = service.createFunctionComparisonProvider();
|
|
||||||
comparisonProvider.removeAddFunctionsAction();
|
|
||||||
|
|
||||||
ClangFuncNameToken leftFuncToken = (ClangFuncNameToken) currentPair.leftToken();
|
ClangFuncNameToken leftFuncToken = (ClangFuncNameToken) currentPair.leftToken();
|
||||||
ClangFuncNameToken rightFuncToken = (ClangFuncNameToken) currentPair.rightToken();
|
ClangFuncNameToken rightFuncToken = (ClangFuncNameToken) currentPair.rightToken();
|
||||||
|
|
||||||
Function leftFunction = getFuncFromToken(leftFuncToken, decompPanel.getLeftProgram());
|
Function leftFunction = getFuncFromToken(leftFuncToken, decompPanel.getLeftProgram());
|
||||||
Function rightFunction = getFuncFromToken(rightFuncToken, decompPanel.getRightProgram());
|
Function rightFunction = getFuncFromToken(rightFuncToken, decompPanel.getRightProgram());
|
||||||
|
|
||||||
if (leftFunction == null || rightFunction == null) {
|
if (leftFunction == null || rightFunction == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
comparisonProvider.getModel().compareFunctions(leftFunction, rightFunction);
|
FunctionComparisonService service = tool.getService(FunctionComparisonService.class);
|
||||||
|
if (service == null) {
|
||||||
|
Msg.error(this, "Function Comparison Service not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FunctionComparisonProvider comparisonProvider = service.createFunctionComparisonProvider();
|
||||||
|
comparisonProvider.removeAddFunctionsAction();
|
||||||
|
comparisonProvider.getModel().compareFunctions(leftFunction, rightFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function getFuncFromToken(ClangFuncNameToken funcToken, Program program) {
|
private Function getFuncFromToken(ClangFuncNameToken funcToken, Program program) {
|
||||||
Address callTarget = funcToken.getPcodeOp().getInput(0).getAddress();
|
Address callTarget = funcToken.getPcodeOp().getInput(0).getAddress();
|
||||||
return program.getFunctionManager().getFunctionAt(callTarget);
|
Function func = program.getFunctionManager().getFunctionAt(callTarget);
|
||||||
|
if (func == null) {
|
||||||
|
Msg.showWarn(this, null, "Unable to Compare Callees",
|
||||||
|
"Can't compare callees - null Function for " + funcToken.getText());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (func.isExternal()) {
|
||||||
|
Msg.showWarn(this, null, "Unable to Compare Callees",
|
||||||
|
"Can't compare callees - " + func.getName() + " is external");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!func.isThunk()) {
|
||||||
|
return func;
|
||||||
|
}
|
||||||
|
func = func.getThunkedFunction(true);
|
||||||
|
if (func.isExternal()) {
|
||||||
|
Msg.showWarn(this, null, "Unable to Compare",
|
||||||
|
"Can't compare callees - " + func.getName() + " is external");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return func;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue