Executing code
With the execute command you can make a program execute
your code. You can either provide assembly instructions that will then
get assembled into bytecode or you can provide the bytecode yourself,
maybe hand-written or assembled by your favorite assembler.
If you wanted to execute instructions from an assembly file on a
program whose PID is 12345, the command would look like this:
$ proctal execute --pid=12345 < code.asm
The given instructions will be embedded at some place in memory and
executed in a new stack frame in the context of the main thread. The
other threads will be paused. Your code is free to modify any registers
because they will be restored to their original values. Control will
be given back to the program after the last instruction is executed.
The instructions cannot rely on where they will be placed in memory.
The instructions are expected to be separated by new lines. The
; character can be used to start a comment that spans to
the end of the line.
The --architecture option allows you to set the CPU
architecture. By default it's the same architecture that the tool was
compiled in. At the moment the available values are x86,
x86-64, arm, sparc,
powerpc and mips.
The --endianness options allows you to set the
endianness of the instructions. This can be little or
big. By default the endianness of your system is used if
support.
The --x86-syntax option allows you to change the
syntax for x86 assembly. By default it's set to intel.
You can switch to att if you prefer.
The --x86-mode option lets you set whether to work with
the 16-bit, 32-bit or 64-bit versions of the x86 instruction set.
The --arm-mode option lets you choose between
a32, t32 and a64.
The --sparc-mode option lets you choose between
32 and 64.
The --powerpc-mode option lets you choose
between 32, 64.
The --mips-mode option lets you choose between
32 and 64.
You can execute bytecode by passing the --format option
with the value bytecode.
Here's how you would execute bytecode from a binary file:
$ proctal execute --pid=12345 --format=bytecode < code.bin