mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-24 05:02:41 +00:00
GT-2976 - Fixed NPE in Version Tracking hashing
This commit is contained in:
parent
1cc8de3e67
commit
4885e5f8a9
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import generic.stl.Pair;
|
||||
import ghidra.program.model.address.AddressSet;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -46,9 +46,8 @@ public class ExactBytesFunctionHasher extends AbstractFunctionHasher {
|
||||
byte[] buffer = new byte[byteCount];
|
||||
int offset = 0;
|
||||
for (CodeUnit codeUnit : units) {
|
||||
if (monitor.isCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
monitor.checkCanceled();
|
||||
|
||||
try {
|
||||
codeUnit.getBytesInCodeUnit(buffer, offset);
|
||||
}
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -22,9 +22,7 @@ import generic.hash.MessageDigest;
|
||||
import generic.stl.Pair;
|
||||
import ghidra.program.model.lang.IncompatibleMaskException;
|
||||
import ghidra.program.model.lang.Mask;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
import ghidra.program.model.listing.*;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
@ -75,15 +73,14 @@ public class ExactInstructionsFunctionHasher extends AbstractFunctionHasher {
|
||||
byte[] buffer = new byte[byteCount];
|
||||
int offset = 0;
|
||||
for (CodeUnit codeUnit : units) {
|
||||
if (monitor.isCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
monitor.checkCanceled();
|
||||
|
||||
try {
|
||||
codeUnit.getBytesInCodeUnit(buffer, offset);
|
||||
applyMask(buffer, offset, codeUnit);
|
||||
}
|
||||
catch (MemoryAccessException e) {
|
||||
Msg.warn(this, "Could not get code unit bvtes at " + codeUnit.getAddress());
|
||||
Msg.warn(this, "Could not get code unit bytes at " + codeUnit.getAddress());
|
||||
}
|
||||
offset += codeUnit.getLength();
|
||||
}
|
||||
@ -98,15 +95,22 @@ public class ExactInstructionsFunctionHasher extends AbstractFunctionHasher {
|
||||
}
|
||||
|
||||
private static void applyMask(byte[] buffer, int offset, CodeUnit codeUnit) {
|
||||
if (codeUnit instanceof Instruction) {
|
||||
Instruction i = (Instruction) codeUnit;
|
||||
Mask mask = i.getPrototype().getInstructionMask();
|
||||
try {
|
||||
mask.applyMask(buffer, offset, buffer, offset);
|
||||
}
|
||||
catch (IncompatibleMaskException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (!(codeUnit instanceof Instruction)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Instruction i = (Instruction) codeUnit;
|
||||
Mask mask = i.getPrototype().getInstructionMask();
|
||||
if (mask == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
mask.applyMask(buffer, offset, buffer, offset);
|
||||
}
|
||||
catch (IncompatibleMaskException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -13,16 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.util.Msg;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ExactMnemonicsFunctionHasher extends ExactInstructionsFunctionHasher {
|
||||
@SuppressWarnings("hiding")
|
||||
public static final ExactMnemonicsFunctionHasher INSTANCE = new ExactMnemonicsFunctionHasher();
|
||||
@ -36,9 +37,8 @@ public class ExactMnemonicsFunctionHasher extends ExactInstructionsFunctionHashe
|
||||
throws MemoryAccessException, CancelledException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (CodeUnit codeUnit : units) {
|
||||
if (monitor.isCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
monitor.checkCanceled();
|
||||
|
||||
if (codeUnit instanceof Instruction) {
|
||||
Instruction inst = (Instruction) codeUnit;
|
||||
String mnemonic = inst.getMnemonicString();
|
||||
@ -56,7 +56,8 @@ public class ExactMnemonicsFunctionHasher extends ExactInstructionsFunctionHashe
|
||||
}
|
||||
sb.append(chars);
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (MemoryAccessException e) {
|
||||
Msg.warn(this, "Could not get code unit bytes at " + codeUnit.getAddress());
|
||||
sb.append(codeUnit.getAddressString(true, true));
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.util.exception.CancelledException;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -20,7 +19,7 @@
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import generic.stl.Pair;
|
||||
import ghidra.program.model.address.*;
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressSetView;
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -20,7 +19,7 @@
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -14,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Data;
|
@ -1,6 +1,5 @@
|
||||
/* ###
|
||||
* IP: GHIDRA
|
||||
* REVIEWED: YES
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -20,7 +19,7 @@
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import ghidra.program.model.address.Address;
|
||||
|
@ -19,7 +19,7 @@
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
package ghidra.app.plugin.prototype.match;
|
||||
package ghidra.app.plugin.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import ghidra.app.plugin.prototype.match.MatchData;
|
||||
import ghidra.app.plugin.prototype.match.MatchedData;
|
||||
import ghidra.app.plugin.match.MatchData;
|
||||
import ghidra.app.plugin.match.MatchedData;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import ghidra.app.plugin.prototype.match.ExactInstructionsFunctionHasher;
|
||||
import ghidra.app.plugin.match.ExactInstructionsFunctionHasher;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import ghidra.app.plugin.prototype.match.ExactBytesFunctionHasher;
|
||||
import ghidra.app.plugin.match.ExactBytesFunctionHasher;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import ghidra.app.plugin.prototype.match.ExactInstructionsFunctionHasher;
|
||||
import ghidra.app.plugin.match.ExactInstructionsFunctionHasher;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import ghidra.app.plugin.prototype.match.ExactMnemonicsFunctionHasher;
|
||||
import ghidra.app.plugin.match.ExactMnemonicsFunctionHasher;
|
||||
import ghidra.feature.vt.api.main.VTProgramCorrelator;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelatorFactory;
|
||||
import ghidra.feature.vt.api.util.VTOptions;
|
||||
|
@ -19,9 +19,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ghidra.app.plugin.core.entropy.EntropyCalculate;
|
||||
import ghidra.app.plugin.prototype.match.FunctionHasher;
|
||||
import ghidra.app.plugin.prototype.match.MatchFunctions;
|
||||
import ghidra.app.plugin.prototype.match.MatchFunctions.MatchedFunctions;
|
||||
import ghidra.app.plugin.match.FunctionHasher;
|
||||
import ghidra.app.plugin.match.MatchFunctions;
|
||||
import ghidra.app.plugin.match.MatchFunctions.MatchedFunctions;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
@ -17,8 +17,8 @@ package ghidra.feature.vt.api.correlator.program;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import ghidra.app.plugin.prototype.match.MatchSymbol;
|
||||
import ghidra.app.plugin.prototype.match.MatchSymbol.MatchedSymbol;
|
||||
import ghidra.app.plugin.match.MatchSymbol;
|
||||
import ghidra.app.plugin.match.MatchSymbol.MatchedSymbol;
|
||||
import ghidra.feature.vt.api.main.*;
|
||||
import ghidra.feature.vt.api.util.VTAbstractProgramCorrelator;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
@ -93,6 +93,7 @@ ghidra/app/plugin/core/printing/**
|
||||
ghidra/file/formats/**
|
||||
ghidra/file/jad/**
|
||||
ghidra/app/cmd/formats/**
|
||||
ghidra/app/util/bin/format/**
|
||||
mobiledevices/**
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user