Package ghidra.program.model.lang
Class InjectPayloadSleigh
java.lang.Object
ghidra.program.model.lang.InjectPayloadSleigh
- All Implemented Interfaces:
- InjectPayload
- Direct Known Subclasses:
- InjectPayloadCallfixup,- InjectPayloadCallother,- InjectPayloadJumpAssist,- InjectPayloadSegment
InjectPayloadSleigh defines an InjectPayload of p-code which is defined via
 a String passed to the sleigh compiler- 
Nested Class SummaryNested classes/interfaces inherited from interface ghidra.program.model.lang.InjectPayloadInjectPayload.InjectParameter
- 
Field SummaryFieldsFields inherited from interface ghidra.program.model.lang.InjectPayloadCALLFIXUP_TYPE, CALLMECHANISM_TYPE, CALLOTHERFIXUP_TYPE, EXECUTABLEPCODE_TYPE
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedInjectPayloadSleigh(ConstructTpl pcode, int tp, String nm) Constructor for a dummy payload, given just a nameprotectedInjectPayloadSleigh(ConstructTpl pcode, InjectPayloadSleigh failedPayload) Constructor for partial clone of another payload whose p-code failed to parseprotectedInjectPayloadSleigh(String sourceName) Constructor for use where restoreXml is overridden and provides name and typeInjectPayloadSleigh(String nm, int tp, String sourceName) Provide basic form, restoreXml fills in the rest
- 
Method SummaryModifier and TypeMethodDescriptionvoidEncode configuration parameters as a<pcode>element to streamstatic ConstructTplgetDummyPcode(AddressFactory addrFactory) Build a dummy p-code sequence to use in place of a normal parsed payload.getInput()getName()intPcodeOp[]getPcode(Program program, InjectContext con) A convenience function wrapping the inject method, to produce the final set of PcodeOp objects in an arrayintgetType()voidinject(InjectContext context, PcodeEmit emit) Given a context, send the p-code payload to the emitterbooleanDetermine if this InjectPayload and another instance are equivalent (have the same name and generate the same p-code)booleanIf parsing a payload (from XML) fails, a placeholder payload may be substituted and this method returns true for the substitute.booleanbooleanprotected voidAll input and output parameters must have a unique index.voidrestoreXml(XmlPullParser parser, SleighLanguage language) Restore the payload from an XML stream.protected voidprotected voidprotected voidsetTemplate(ConstructTpl ctl) 
- 
Field Details- 
name
- 
typeprotected int type
- 
source
 
- 
- 
Constructor Details- 
InjectPayloadSleighConstructor for partial clone of another payload whose p-code failed to parse- Parameters:
- pcode- is substitute p-code to replace the failed parse
- failedPayload- is the failed payload
 
- 
InjectPayloadSleighConstructor for a dummy payload, given just a name- Parameters:
- pcode- is the dummy p-code sequence
- tp- is the type of injection
- nm- is the name of the injection
 
- 
InjectPayloadSleighConstructor for use where restoreXml is overridden and provides name and type- Parameters:
- sourceName- is string describing the source of this payload
 
- 
InjectPayloadSleighProvide basic form, restoreXml fills in the rest- Parameters:
- nm- must provide formal name
- tp- must provide type
- sourceName- is a description of the source of this payload
 
 
- 
- 
Method Details- 
getName- Specified by:
- getNamein interface- InjectPayload
- Returns:
- formal name for this injection
 
- 
getTypepublic int getType()- Specified by:
- getTypein interface- InjectPayload
- Returns:
- the type of this injection: CALLFIXUP_TYPE, CALLMECHANISM_TYPE, etc.
 
- 
getSource- Specified by:
- getSourcein interface- InjectPayload
- Returns:
- a String describing the source of this payload
 
- 
getParamShiftpublic int getParamShift()- Specified by:
- getParamShiftin interface- InjectPayload
- Returns:
- number of parameters from the original call which should be truncated
 
- 
setInputParameters
- 
setOutputParameters
- 
getInput- Specified by:
- getInputin interface- InjectPayload
- Returns:
- array of any input parameters for this inject
 
- 
getOutput- Specified by:
- getOutputin interface- InjectPayload
- Returns:
- array of any output parameters for this inject
 
- 
isErrorPlaceholderpublic boolean isErrorPlaceholder()Description copied from interface:InjectPayloadIf parsing a payload (from XML) fails, a placeholder payload may be substituted and this method returns true for the substitute. In all other cases, this returns false.- Specified by:
- isErrorPlaceholderin interface- InjectPayload
- Returns:
- true if this is a placeholder for a payload with parse errors.
 
- 
injectpublic void inject(InjectContext context, PcodeEmit emit) throws UnknownInstructionException, MemoryAccessException, IOException, NotFoundException Description copied from interface:InjectPayloadGiven a context, send the p-code payload to the emitter- Specified by:
- injectin interface- InjectPayload
- Parameters:
- context- is the context for injection
- emit- is the object accumulating the final p-code
- Throws:
- UnknownInstructionException- if there is no underlying instruction being injected
- MemoryAccessException- for problems establishing the injection context
- IOException- for problems while emitting the injection p-code
- NotFoundException- if an expected aspect of the injection is not present in context
 
- 
getPcodepublic PcodeOp[] getPcode(Program program, InjectContext con) throws UnknownInstructionException, MemoryAccessException, IOException, NotFoundException Description copied from interface:InjectPayloadA convenience function wrapping the inject method, to produce the final set of PcodeOp objects in an array- Specified by:
- getPcodein interface- InjectPayload
- Parameters:
- program- is the Program for which injection is happening
- con- is the context for injection
- Returns:
- the array of PcodeOps
- Throws:
- UnknownInstructionException- if there is no underlying instruction being injected
- MemoryAccessException- for problems establishing the injection context
- IOException- for problems while emitting the injection p-code
- NotFoundException- if an expected aspect of the injection is not present in context
 
- 
isFallThrupublic boolean isFallThru()- Specified by:
- isFallThruin interface- InjectPayload
- Returns:
- true if the injected p-code falls thru
 
- 
isIncidentalCopypublic boolean isIncidentalCopy()- Specified by:
- isIncidentalCopyin interface- InjectPayload
- Returns:
- true if this inject's COPY operations should be treated as incidental
 
- 
orderParametersprotected void orderParameters()All input and output parameters must have a unique index. Order them so that inputs come first, then outputs
- 
encodeDescription copied from interface:InjectPayloadEncode configuration parameters as a<pcode>element to stream- Specified by:
- encodein interface- InjectPayload
- Parameters:
- encoder- is the stream encoder
- Throws:
- IOException- for errors writing to the underlying stream
 
- 
restoreXmlDescription copied from interface:InjectPayloadRestore the payload from an XML stream. The root expected document is the<pcode>tag, which may be wrapped with another tag by the derived class.- Specified by:
- restoreXmlin interface- InjectPayload
- Parameters:
- parser- is the XML stream
- language- is used to resolve registers and address spaces
- Throws:
- XmlParseException- for badly formed XML
 
- 
setTemplate
- 
isEquivalentDescription copied from interface:InjectPayloadDetermine if this InjectPayload and another instance are equivalent (have the same name and generate the same p-code)- Specified by:
- isEquivalentin interface- InjectPayload
- Parameters:
- obj- is the other payload
- Returns:
- true if they are equivalent
 
- 
getDummyPcodeBuild a dummy p-code sequence to use in place of a normal parsed payload. A ConstructTpl is built out of Varnode and PcodeOp templates that can be assigned directly to the pcodeTemplate field of the payload. The sequence itself is non-empty, consisting of a single operation: tmp = tmp + 0;- Parameters:
- addrFactory- is used to construct temp and constant Varnodes
- Returns:
- the final dummy template
 
 
-