Been doing some reading of the Intel manuals, and here's the code I've come up with....
Code: Select all
char *isr_wrapper = {
/* pusha, push gs, fs, es, ds */
0x60, 0x0F, 0xA8, 0x0F, 0xA0, 0x06, 0x1E,
/* push parameter 2 onto stack */
0x68, 0x00, 0x00, 0x00, 0x00,
/* push parameter 1 onto stack */
0x68, 0x00, 0x00, 0x00, 0x00,
/* call function */
0x9A, 0x00, 0x00, 0x00, 0x00,
/* pop ds, es, fs, gs, popa, iret */
0x1F, 0x07, 0x0F, 0xA1, 0x0F, 0x09, 0x61, 0xCF
};
Where I'd replace the first lot of 0x00s with address of Val_unit, the second lot with address of *closure, and the last with address of the function `callback'.
It's just the call that I'm a little confused about, since there are a few different opcodes. From the Intel manual, I decided to use:
Opcode: 9A
cd, Instruction: CALL
ptr16:16, Description: Call far, absolute, address given in operand.
Assuming that's all correct, I'd just have to write the code to actually do all this work.