-
I need the functions I create at runtime to be unwindable (e.g. by To my mind, the nicest way to emit these unwind codes would be something along the lines of: var asm = new Assembler(64, rip);
var codes = new List<UnwindCode>();
void uw(UnwindOp op, byte operand)
{
codes.Add(new UnwindCode(asm.IP - rip, op, operand));
}
asm.push(rax);
uw(UWOP_PUSH_NONVOL, rax);
asm.push(rcx);
uw(UWOP_PUSH_NONVOL, rcx);
asm.push(rdx);
uw(UWOP_PUSH_NONVOL, rdx);
asm.push(rbx);
uw(UWOP_PUSH_NONVOL, rbx);
// Etc...
asm.Assemble(...);
codes.Reverse();
// Register unwind info... Of course, there's no such thing as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You could use labels, then after you've assembled the code, you can get the IP of those labels. Iced will try to use the shortest instructions. If you must guarantee that some instruction encoding is used, it's probably better to use Instruciton.create(), unless you know there's only one possible encoding that will be used. Eg. if it's 'push rax', iced won't use the longer push r/m instruction, but of course the 1-byte opcode. |
Beta Was this translation helpful? Give feedback.
You could use labels, then after you've assembled the code, you can get the IP of those labels.
Iced will try to use the shortest instructions. If you must guarantee that some instruction encoding is used, it's probably better to use Instruciton.create(), unless you know there's only one possible encoding that will be used. Eg. if it's 'push rax', iced won't use the longer push r/m instruction, but of course the 1-byte opcode.