mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-4883 fix null exception in PropagateExternalParamsScript
This commit is contained in:
parent
0e558caa3d
commit
ecf5fca015
1 changed files with 17 additions and 7 deletions
|
@ -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.
|
||||||
|
@ -31,6 +31,8 @@ import ghidra.program.model.symbol.*;
|
||||||
public class PropagateExternalParametersScript extends GhidraScript {
|
public class PropagateExternalParametersScript extends GhidraScript {
|
||||||
private List<PushedParamInfo> results = new ArrayList<>();
|
private List<PushedParamInfo> results = new ArrayList<>();
|
||||||
|
|
||||||
|
private static final boolean PRINT_OPTYPE = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
Listing listing = currentProgram.getListing();
|
Listing listing = currentProgram.getListing();
|
||||||
|
@ -147,9 +149,9 @@ public class PropagateExternalParametersScript extends GhidraScript {
|
||||||
while (tempIter.hasNext()) {
|
while (tempIter.hasNext()) {
|
||||||
Reference thunkRef = tempIter.next();
|
Reference thunkRef = tempIter.next();
|
||||||
Address thunkRefAddr = thunkRef.getFromAddress();
|
Address thunkRefAddr = thunkRef.getFromAddress();
|
||||||
|
|
||||||
CodeUnit cu = listing.getCodeUnitAt(thunkRefAddr);
|
CodeUnit cu = listing.getCodeUnitAt(thunkRefAddr);
|
||||||
if(cu == null) {
|
if (cu == null) {
|
||||||
// println("Referenced CodeUnit is null: " + thunkRefAddr);
|
// println("Referenced CodeUnit is null: " + thunkRefAddr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -300,10 +302,18 @@ public class PropagateExternalParametersScript extends GhidraScript {
|
||||||
numSkips--;
|
numSkips--;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
// if option is true add the value of the optype to the EOL comment
|
||||||
|
String opType = "";
|
||||||
|
if (PRINT_OPTYPE) {
|
||||||
|
opType = " " + toHexString(currentProgram.getListing()
|
||||||
|
.getInstructionAt(cu.getMinAddress())
|
||||||
|
.getOperandType(0),
|
||||||
|
false, true);
|
||||||
|
}
|
||||||
setEOLComment(cu.getMinAddress(), params[index].getDataType().getDisplayName() +
|
setEOLComment(cu.getMinAddress(), params[index].getDataType().getDisplayName() +
|
||||||
" " + params[index].getName() + " for " + extFuncName);
|
" " + params[index].getName() + " for " + extFuncName + opType);
|
||||||
// add the following to the EOL comment to see the value of the optype
|
|
||||||
// + " | " + ghidra.program.model.lang.OperandType.toString(currentProgram.getListing().getInstructionAt(cu.getMinAddress()).getOperandType(0))
|
|
||||||
addResult(params[index].getName(), params[index].getDataType(),
|
addResult(params[index].getName(), params[index].getDataType(),
|
||||||
cu.getMinAddress(), extFuncName);
|
cu.getMinAddress(), extFuncName);
|
||||||
index++;
|
index++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue