Call Gates and Parameters
Posted: Wed Oct 12, 2005 12:47 pm
Reading up on call gates in the system programmer's manual I found the stack arrangement after a call through said gates. First (or never if there is no privilege change) the old ss and esp are pushed onto the stack, followed by X dwords, where X was specified by the gate descriptor, followed finally by the old CS and EIP. ESP is set to where EIP was pushed.
However, looking at the assembly produced by compiling any old function it would seem that this assembly only works for near calls, because EBP is set to the old ESP and then subsequently used with negative numbers (for example -4(EBP)) to access parameters passed to the routine.
Is there a way to have parameter accesses to work with far calls without having to patch my compiler's 32-bit mode to support far? Lacking that, is there any way to patch source code to transparently support far calls?
However, looking at the assembly produced by compiling any old function it would seem that this assembly only works for near calls, because EBP is set to the old ESP and then subsequently used with negative numbers (for example -4(EBP)) to access parameters passed to the routine.
Is there a way to have parameter accesses to work with far calls without having to patch my compiler's 32-bit mode to support far? Lacking that, is there any way to patch source code to transparently support far calls?