Java Code Examples for ghidra.util.exception.InvalidInputException#printStackTrace()
The following examples show how to use
ghidra.util.exception.InvalidInputException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaskContainer.java From ghidra with Apache License 2.0 | 6 votes |
/** * Returns the bytes and masking merged together, as a binary string. * * @param mask * @param value * @return list containing the value (index 0) and mask (index 1). */ public String toBinaryString() { StringBuilder valueString = new StringBuilder(); StringBuilder maskString = new StringBuilder(); for (int i = 0; i < value.length; i++) { valueString.append(InstructionSearchUtils.toBinaryString(value[i])); } for (int i = 0; i < mask.length; i++) { maskString.append(InstructionSearchUtils.toBinaryString(mask[i])); } String combinedString = ""; try { combinedString = InstructionSearchUtils.formatSearchString(valueString.toString(), maskString.toString()); } catch (InvalidInputException e) { e.printStackTrace(); } return combinedString; }
Example 2
Source File: CliAbstractSig.java From ghidra with Apache License 2.0 | 6 votes |
private String getRepresentation(CliStreamMetadata stream, boolean shortRep) { try { if (stream != null) { CliAbstractTable table = stream.getTable(CliIndexTypeDefOrRef.getTableName(encodedType)); if (table == null) return "[ErrorRetrievingTable]"; CliAbstractTableRow row = table.getRow(CliIndexTypeDefOrRef.getRowIndex(encodedType)); if (row == null) return "[ErrorRetrievingRow]"; if (shortRep) return row.getShortRepresentation(); return row.getRepresentation(); } return "[ErrorRepresentingClassReference]"; } catch (InvalidInputException e) { e.printStackTrace(); } return "[ErrorRepresentingClassReference]"; }
Example 3
Source File: CliAbstractSig.java From ghidra with Apache License 2.0 | 6 votes |
public CliTypeGenericInst(BinaryReader reader, CliElementType typeCode) throws IOException { super(typeCode); firstType = CliElementType.fromInt(reader.readNextByte()); // Should be Class or ValueType long origIndex = reader.getPointerIndex(); encodedType = decodeCompressedUnsignedInt(reader); typeSizeBytes = (int) (reader.getPointerIndex() - origIndex); origIndex = reader.getPointerIndex(); genArgCount = decodeCompressedUnsignedInt(reader); countSizeBytes = (int) (reader.getPointerIndex() - origIndex); for (int i = 0; i < genArgCount; i++) { try { argTypes.add(readCliType(reader)); } catch (InvalidInputException e) { e.printStackTrace(); // Do not add to types } } }
Example 4
Source File: CliSigLocalVar.java From ghidra with Apache License 2.0 | 6 votes |
public CliSigLocalVar(CliBlob blob) throws IOException { super(blob); // Now read our special data from the blob! BinaryReader reader = getContentsReader(); byte id = reader.readNextByte(); if (id != identifier) return; // Freak out? or just return... long origIndex = reader.getPointerIndex(); int typesCount = decodeCompressedUnsignedInt(reader); sizeOfCount = (int) (reader.getPointerIndex() - origIndex); types = new CliParam[typesCount]; // TODO: Does CliParam parse constraints? for (byte i = 0; i < typesCount; i++) { try { types[i] = new CliParam(reader); } catch (InvalidInputException e) { types[i] = null; e.printStackTrace(); } } }
Example 5
Source File: PackDataTypeAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionContext context) { GTree gTree = (GTree) context.getContextObject(); TreePath[] selectionPaths = gTree.getSelectionPaths(); if (selectionPaths.length != 1) { Msg.error(this, "Pack is only allowed on an individual data type."); return; } TreePath treePath = selectionPaths[0]; final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent(); DataType dataType = dataTypeNode.getDataType(); DataTypeManager dataTypeManager = dataType.getDataTypeManager(); if (dataTypeManager == null) { Msg.error(this, "Can't pack data type " + dataType.getName() + " without a data type manager."); return; } int transactionID = -1; boolean commit = false; try { // start a transaction transactionID = dataTypeManager.startTransaction("pack of " + dataType.getName()); packDataType(dataType); commit = true; } catch (InvalidInputException iie) { // TODO Auto-generated catch block iie.printStackTrace(); } finally { // commit the changes dataTypeManager.endTransaction(transactionID, commit); } }
Example 6
Source File: PackSizeDataTypeAction.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionContext context) { GTree gTree = (GTree) context.getContextObject(); TreePath[] selectionPaths = gTree.getSelectionPaths(); TreePath treePath = selectionPaths[0]; final DataTypeNode dataTypeNode = (DataTypeNode) treePath.getLastPathComponent(); DataType dataType = dataTypeNode.getDataType(); DataTypeManager dataTypeManager = dataType.getDataTypeManager(); if (dataTypeManager == null) { Msg.error(this, "Can't pack data type " + dataType.getName() + " without a data type manager."); return; } NumberInputDialog numberInputDialog = new NumberInputDialog("pack alignment", 0, 0, 16); if (!numberInputDialog.show()) { return; } int packSize = numberInputDialog.getValue(); int transactionID = -1; boolean commit = false; try { // start a transaction transactionID = dataTypeManager.startTransaction("pack(" + packSize + ") of " + dataType.getName()); packDataType(dataType, packSize); commit = true; } catch (InvalidInputException iie) { // TODO Auto-generated catch block iie.printStackTrace(); } finally { // commit the changes dataTypeManager.endTransaction(transactionID, commit); } }
Example 7
Source File: CliAbstractSig.java From ghidra with Apache License 2.0 | 5 votes |
private String getRepresentation(CliStreamMetadata stream, boolean shortRep) { String argTypesRep = ""; for (int i = 0; i < genArgCount; i++) { argTypesRep += argTypes.get(i).getRepresentation(); if (i != genArgCount - 1) argTypesRep += ", "; } String typeRep = Integer.toHexString(encodedType); if (stream != null) { try { CliAbstractTableRow row = stream.getTable(CliIndexTypeDefOrRef.getTableName(encodedType)).getRow( CliIndexTypeDefOrRef.getRowIndex(encodedType)); if (shortRep) typeRep = row.getShortRepresentation(); else typeRep = row.getRepresentation(); } catch (InvalidInputException e) { e.printStackTrace(); } } return String.format("%s %s %d %s", firstType.toString(), typeRep, genArgCount, argTypesRep); }
Example 8
Source File: CliAbstractSig.java From ghidra with Apache License 2.0 | 5 votes |
public String getRepresentation(CliStreamMetadata stream, boolean shortRep) { try { CliAbstractTableRow row = stream.getTable(CliIndexTypeDefOrRef.getTableName(encodedType)).getRow( CliIndexTypeDefOrRef.getRowIndex(encodedType)); return "ValueType " + (shortRep ? row.getShortRepresentation() : row.getRepresentation()); } catch (InvalidInputException e) { e.printStackTrace(); } return ""; }
Example 9
Source File: FunctionSignatureStringable.java From ghidra with Apache License 2.0 | 5 votes |
@Override public String getDisplayString() { if (returnInfo == null) { return "undefined " + SHORT_NAME + "()"; } StringBuffer buf = new StringBuffer(); buf.append(getSignatureDisplayString()); if (hasCustomStorage && (program != null)) { try { buf.append(" CustomStorage: "); VariableStorage returnVariableStorage = VariableStorage.deserialize(program, returnInfo.storage); buf.append(returnVariableStorage.toString() + " "); buf.append("("); int numParams = parameterInfos.size(); for (int i = 0; i < numParams; i++) { String parameterStorageString = parameterInfos.get(i).storage; VariableStorage variableStorage = VariableStorage.deserialize(program, parameterStorageString); buf.append(variableStorage.toString()); if ((i < (numParams - 1)) || hasVarargs) { buf.append(", "); } } if (hasVarargs) { buf.append(FunctionSignature.VAR_ARGS_DISPLAY_STRING); } buf.append(")"); } catch (InvalidInputException e) { buf.append("Error getting variable storage."); e.printStackTrace(); } } if (callFixup != null) { buf.append(" " + callFixup); } return buf.toString(); }