GP-2467: Change SleighProgramCompiler to use String (text block) instead of List<String>

This commit is contained in:
Dan 2022-09-12 09:03:54 -04:00
parent 6a2cd80550
commit 9d6f278f39
48 changed files with 730 additions and 613 deletions

View file

@ -22,7 +22,6 @@
//@toolbar
import java.nio.charset.Charset;
import java.util.List;
import ghidra.app.plugin.assembler.*;
import ghidra.app.plugin.processors.sleigh.SleighLanguage;
@ -102,10 +101,10 @@ public class StandAloneEmuExampleScript extends GhidraScript {
*/
byte[] hw = "Hello, World!\n".getBytes(UTF8);
emulator.getSharedState().setVar(dyn, 0xdeadbeefL, hw.length, true, hw);
PcodeProgram init = SleighProgramCompiler.compileProgram(language, "init", List.of(
"RIP = 0x" + entry + ";",
"RSP = 0x00001000;"),
library);
PcodeProgram init = SleighProgramCompiler.compileProgram(language, "init", String.format("""
RIP = 0x%s;
RSP = 0x00001000;
""", entry), library);
thread.getExecutor().execute(init, library);
thread.overrideContextWithDefault();
thread.reInitialize();
@ -114,9 +113,10 @@ public class StandAloneEmuExampleScript extends GhidraScript {
* Inject a call to our custom print userop. Otherwise, the language itself will never
* invoke it.
*/
emulator.inject(injectHere, List.of(
"print_utf8(RCX);",
"emu_exec_decoded();"));
emulator.inject(injectHere, """
print_utf8(RCX);
emu_exec_decoded();
""");
/*
* Run the experiment: This should interrupt on the second SYSCALL, because any value other