Java Code Examples for ghidra.util.exception.InvalidInputException#getMessage()
The following examples show how to use
ghidra.util.exception.InvalidInputException#getMessage() .
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: SetReturnDataTypeCmd.java From ghidra with Apache License 2.0 | 6 votes |
/** * * @see ghidra.framework.cmd.Command#applyTo(ghidra.framework.model.DomainObject) */ @Override public boolean applyTo(DomainObject obj) { Program program = (Program) obj; Function function = program.getListing().getFunctionAt(entry); try { function.setReturnType(dataType, source); if (source == SourceType.DEFAULT) { function.setSignatureSource(SourceType.DEFAULT); } } catch (InvalidInputException e) { status = e.getMessage(); return false; } return true; }
Example 2
Source File: AddLabelCmd.java From ghidra with Apache License 2.0 | 6 votes |
/** * * @see ghidra.framework.cmd.Command#applyTo(ghidra.framework.model.DomainObject) */ @Override public boolean applyTo(DomainObject obj) { SymbolTable st = ((Program) obj).getSymbolTable(); if (namespace == null && useLocalNamespace) { namespace = st.getNamespace(addr); } try { symbol = st.createLabel(addr, name, namespace, source); return true; } catch (InvalidInputException e) { if ((name == null) || (name.length() == 0)) { errorMsg = "You must enter a valid label name"; } else { errorMsg = "Invalid name: " + e.getMessage(); } } return false; }
Example 3
Source File: CreateNamespacesCmd.java From ghidra with Apache License 2.0 | 6 votes |
/** * @see ghidra.framework.cmd.Command#applyTo(ghidra.framework.model.DomainObject) */ @Override public boolean applyTo(DomainObject obj) { try { leafNamespace = NamespaceUtils.createNamespaceHierarchy(namespacesString, rootNamespace, (Program) obj, source); if (leafNamespace != null) { return true; } } catch (InvalidInputException e) { // this means that a name was not of a valid format, // so let's bounce that back to the user statusMsg = e.getMessage(); return false; } statusMsg = "Unable to create namespaces from namespace " + "string: " + namespacesString; return false; }
Example 4
Source File: MappedEntry.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void restoreXML(XmlPullParser parser) throws PcodeXMLException { HighFunction function = symbol.function; Program program = function.getFunction().getProgram(); AddressFactory addrFactory = function.getAddressFactory(); XmlElement addrel = parser.start("addr"); int sz = symbol.type.getLength(); if (sz == 0) { throw new PcodeXMLException( "Invalid symbol 0-sized data-type: " + symbol.type.getName()); } try { Address varAddr = Varnode.readXMLAddress(addrel, addrFactory); AddressSpace spc = varAddr.getAddressSpace(); if ((spc == null) || (spc.getType() != AddressSpace.TYPE_VARIABLE)) { storage = new VariableStorage(program, varAddr, sz); } else { storage = function.readXMLVarnodePieces(addrel, varAddr); } } catch (InvalidInputException e) { throw new PcodeXMLException("Invalid storage: " + e.getMessage()); } parser.end(addrel); parseRangeList(parser); }
Example 5
Source File: SetVariableDataTypeCmd.java From ghidra with Apache License 2.0 | 5 votes |
/** * * @see ghidra.framework.cmd.Command#applyTo(ghidra.framework.model.DomainObject) */ @Override public boolean applyTo(DomainObject obj) { if (!(obj instanceof Program)) { return false; } Program p = (Program) obj; Function f = p.getFunctionManager().getFunctionAt(fnEntry); if (f == null) { status = "Function not found"; return false; } Symbol s = p.getSymbolTable().getParameterSymbol(varName, f); if (s == null) { s = p.getSymbolTable().getLocalVariableSymbol(varName, f); } if (s == null) { status = "Variable not found"; return false; } DataType dt = dataType; if (dataType instanceof FunctionDefinition || (dataType instanceof TypeDef && ((TypeDef) dataType).getDataType() instanceof FunctionDefinition)) { dt = new PointerDataType(dataType); } Variable var = (Variable) s.getObject(); isParm = var instanceof Parameter; try { var.setDataType(dt, align, force, source); } catch (InvalidInputException e) { status = e.getMessage(); return false; } return true; }
Example 6
Source File: Varnode.java From ghidra with Apache License 2.0 | 4 votes |
/** * Build a varnode from a SAX parse tree node * * @param parser the parser * @param factory pcode factory used to create valid pcode * * @return new varnode element based on info in the XML. * * @throws PcodeXMLException */ public static Varnode readXML(XmlPullParser parser, PcodeFactory factory) throws PcodeXMLException { XmlElement el = parser.start(); try { if (el.getName().equals("void")) { return null; } Varnode vn; String attrstring = el.getAttribute("ref"); int ref = -1; if (attrstring != null) { ref = SpecXmlUtils.decodeInt(attrstring); // If we have a reference vn = factory.getRef(ref); // The varnode may already exist if (vn != null) { return vn; } } Address addr = readXMLAddress(el, factory.getAddressFactory()); if (addr == null) { return null; } int sz; attrstring = el.getAttribute("size"); if (attrstring != null) { sz = SpecXmlUtils.decodeInt(attrstring); } else { sz = 4; } if (ref != -1) { vn = factory.newVarnode(sz, addr, ref); } else { vn = factory.newVarnode(sz, addr); } AddressSpace spc = addr.getAddressSpace(); if ((spc != null) && (spc.getType() == AddressSpace.TYPE_VARIABLE)) { // Check for a composite Address try { factory.readXMLVarnodePieces(el, addr); } catch (InvalidInputException e) { throw new PcodeXMLException("Invalid varnode pieces: " + e.getMessage()); } } attrstring = el.getAttribute("grp"); if (attrstring != null) { short val = (short) SpecXmlUtils.decodeInt(attrstring); factory.setMergeGroup(vn, val); } attrstring = el.getAttribute("persists"); if ((attrstring != null) && (SpecXmlUtils.decodeBoolean(attrstring))) { factory.setPersistant(vn, true); } attrstring = el.getAttribute("addrtied"); if ((attrstring != null) && (SpecXmlUtils.decodeBoolean(attrstring))) { factory.setAddrTied(vn, true); } attrstring = el.getAttribute("unaff"); if ((attrstring != null) && (SpecXmlUtils.decodeBoolean(attrstring))) { factory.setUnaffected(vn, true); } attrstring = el.getAttribute("input"); if ((attrstring != null) && (SpecXmlUtils.decodeBoolean(attrstring))) { vn = factory.setInput(vn, true); } return vn; } finally { parser.end(el); } }