mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
1b96e1610c
2 changed files with 36 additions and 17 deletions
|
@ -95,31 +95,51 @@ public class CompareFuncsFromMatchedTokensAction extends AbstractMatchedTokensAc
|
|||
currentPair.rightToken() == null) {
|
||||
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 rightFuncToken = (ClangFuncNameToken) currentPair.rightToken();
|
||||
|
||||
Function leftFunction = getFuncFromToken(leftFuncToken, decompPanel.getLeftProgram());
|
||||
Function rightFunction = getFuncFromToken(rightFuncToken, decompPanel.getRightProgram());
|
||||
|
||||
if (leftFunction == null || rightFunction == null) {
|
||||
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) {
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -460,9 +460,9 @@ public class PackedDecode implements Decoder {
|
|||
curPos.advancePosition(length);
|
||||
return res;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
String res = new String(curPos.array, curPos.current, curLen);
|
||||
buf.append(res);
|
||||
int size = curLen;
|
||||
byte[] buf = new byte[length];
|
||||
System.arraycopy(curPos.array, curPos.current, buf, 0, curLen);
|
||||
length -= curLen;
|
||||
curPos.advancePosition(curLen);
|
||||
while (length > 0) {
|
||||
|
@ -470,13 +470,12 @@ public class PackedDecode implements Decoder {
|
|||
if (curLen > length) {
|
||||
curLen = length;
|
||||
}
|
||||
res = new String(curPos.array, curPos.current, curLen);
|
||||
buf.append(res);
|
||||
System.arraycopy(curPos.array, curPos.current, buf, size, curLen);
|
||||
size += curLen;
|
||||
length -= curLen;
|
||||
curPos.advancePosition(curLen);
|
||||
}
|
||||
res = buf.toString();
|
||||
return res;
|
||||
return new String(buf, 0, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue