mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Use InjectPayload for segment ops
This commit is contained in:
parent
06de0d46a0
commit
4c3289f09f
7 changed files with 93 additions and 132 deletions
|
@ -599,6 +599,29 @@ public class SleighLanguage implements Language {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseSegmentOp(XmlElement el, XmlPullParser parser) {
|
||||
String name = el.getAttribute("userop");
|
||||
if (name == null) {
|
||||
name = "segment";
|
||||
}
|
||||
name = name + "_pcode";
|
||||
String source = "pspec: " + getLanguageID().getIdAsString();
|
||||
if (parser.peek().isStart()) {
|
||||
if (parser.peek().getName().equals("pcode")) {
|
||||
InjectPayloadSleigh payload =
|
||||
new InjectPayloadSleigh(name, InjectPayload.EXECUTABLEPCODE_TYPE, source);
|
||||
if (additionalInject == null) {
|
||||
additionalInject = new ArrayList<>();
|
||||
}
|
||||
payload.restoreXml(parser);
|
||||
additionalInject.add(payload);
|
||||
}
|
||||
}
|
||||
while (parser.peek().isStart()) {
|
||||
parser.discardSubTree();
|
||||
}
|
||||
}
|
||||
|
||||
private void read(XmlPullParser parser) {
|
||||
Set<String> registerDataSet = new HashSet<>();
|
||||
|
||||
|
@ -775,9 +798,7 @@ public class SleighLanguage implements Language {
|
|||
}
|
||||
}
|
||||
else if (element.getName().equals("segmentop")) {
|
||||
while (parser.peek().isStart()) {
|
||||
parser.discardSubTree();
|
||||
}
|
||||
parseSegmentOp(element, parser);
|
||||
}
|
||||
// get rid of the end tag of whatever we started with at the top of the while
|
||||
parser.end(element);
|
||||
|
|
|
@ -163,29 +163,30 @@ public class BasicCompilerSpec implements CompilerSpec {
|
|||
language.getProperty(GhidraLanguagePropertyKeys.PCODE_INJECT_LIBRARY_CLASS);
|
||||
if (classname == null) {
|
||||
pcodeInject = new PcodeInjectLibrary(language); // This is the default implementation
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Class<?> c = Class.forName(classname);
|
||||
if (!PcodeInjectLibrary.class.isAssignableFrom(c)) {
|
||||
else {
|
||||
try {
|
||||
Class<?> c = Class.forName(classname);
|
||||
if (!PcodeInjectLibrary.class.isAssignableFrom(c)) {
|
||||
Msg.error(this,
|
||||
"Language " + language.getLanguageID() + " does not specify a valid " +
|
||||
GhidraLanguagePropertyKeys.PCODE_INJECT_LIBRARY_CLASS);
|
||||
throw new RuntimeException(classname + " does not implement interface " +
|
||||
PcodeInjectLibrary.class.getName());
|
||||
}
|
||||
Class<? extends PcodeInjectLibrary> injectLibraryClass =
|
||||
(Class<? extends PcodeInjectLibrary>) c;
|
||||
Constructor<? extends PcodeInjectLibrary> constructor =
|
||||
injectLibraryClass.getConstructor(SleighLanguage.class);
|
||||
pcodeInject = constructor.newInstance(language);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Msg.error(this,
|
||||
"Language " + language.getLanguageID() + " does not specify a valid " +
|
||||
GhidraLanguagePropertyKeys.PCODE_INJECT_LIBRARY_CLASS);
|
||||
throw new RuntimeException(classname + " does not implement interface " +
|
||||
PcodeInjectLibrary.class.getName());
|
||||
throw new RuntimeException("Failed to instantiate " + classname + " for language " +
|
||||
language.getLanguageID(), e);
|
||||
}
|
||||
Class<? extends PcodeInjectLibrary> injectLibraryClass =
|
||||
(Class<? extends PcodeInjectLibrary>) c;
|
||||
Constructor<? extends PcodeInjectLibrary> constructor =
|
||||
injectLibraryClass.getConstructor(SleighLanguage.class);
|
||||
pcodeInject = constructor.newInstance(language);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Msg.error(this, "Language " + language.getLanguageID() + " does not specify a valid " +
|
||||
GhidraLanguagePropertyKeys.PCODE_INJECT_LIBRARY_CLASS);
|
||||
throw new RuntimeException(
|
||||
"Failed to instantiate " + classname + " for language " + language.getLanguageID(),
|
||||
e);
|
||||
}
|
||||
List<InjectPayloadSleigh> additionalInject = language.getAdditionalInject();
|
||||
if (additionalInject != null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue