Commit f56618a2 authored by Markus Amsler's avatar Markus Amsler Committed by Alexandre Julliard

Push on stack in 16 bit mode with segment wrap around.

parent 3be4f5d2
......@@ -136,6 +136,11 @@ extern struct DPMI_segments *DOSVM_dpmi_segments;
LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
/* pushing on stack in 16 bit needs segment wrap around */
#define PUSH_WORD16(context,val) \
*((WORD*)CTX_SEG_OFF_TO_LIN((context), \
(context)->SegSs, ADD_LOWORD( context->Esp, -2 ) )) = (val)
/* Macros for easier access to i386 context registers */
#define AX_reg(context) ((WORD)(context)->Eax)
......
......@@ -392,8 +392,6 @@ void DOSVM_HardwareInterruptPM( CONTEXT86 *context, BYTE intnum )
}
else
{
WORD *stack;
TRACE( "invoking hooked interrupt %02x at %04x:%04x\n",
intnum, SELECTOROF(addr), OFFSETOF(addr) );
......@@ -401,11 +399,9 @@ void DOSVM_HardwareInterruptPM( CONTEXT86 *context, BYTE intnum )
DOSVM_PrepareIRQ( context, FALSE );
/* Push the flags and return address on the stack */
stack = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp);
*(--stack) = LOWORD(context->EFlags);
*(--stack) = context->SegCs;
*(--stack) = LOWORD(context->Eip);
ADD_LOWORD( context->Esp, -6 );
PUSH_WORD16( context, LOWORD(context->EFlags) );
PUSH_WORD16( context, context->SegCs );
PUSH_WORD16( context, LOWORD(context->Eip) );
/* Jump to the interrupt handler */
context->SegCs = HIWORD(addr);
......@@ -506,7 +502,6 @@ void DOSVM_HardwareInterruptRM( CONTEXT86 *context, BYTE intnum )
else
{
/* the interrupt is hooked, simulate interrupt in DOS space */
WORD* stack = PTR_REAL_TO_LIN( context->SegSs, context->Esp );
WORD flag = LOWORD( context->EFlags );
TRACE( "invoking hooked interrupt %02x at %04x:%04x\n",
......@@ -518,10 +513,10 @@ void DOSVM_HardwareInterruptRM( CONTEXT86 *context, BYTE intnum )
else
flag &= ~IF_MASK;
*(--stack) = flag;
*(--stack) = context->SegCs;
*(--stack) = LOWORD( context->Eip );
context->Esp -= 6;
PUSH_WORD16( context, flag );
PUSH_WORD16( context, context->SegCs );
PUSH_WORD16( context, LOWORD( context->Eip ));
context->SegCs = SELECTOROF( handler );
context->Eip = OFFSETOF( handler );
......
......@@ -168,7 +168,6 @@ void DOSVM_RelayHandler( CONTEXT86 *context )
*/
void DOSVM_BuildCallFrame( CONTEXT86 *context, DOSRELAY relay, LPVOID data )
{
WORD *stack;
WORD code_sel = DOSVM_dpmi_segments->relay_code_sel;
/*
......@@ -177,32 +176,26 @@ void DOSVM_BuildCallFrame( CONTEXT86 *context, DOSRELAY relay, LPVOID data )
RELAY_MakeShortContext( context );
/*
* Get stack pointer after RELAY_MakeShortContext.
*/
stack = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp);
/*
* Build call frame.
*/
*(--stack) = HIWORD(data); /* argument.hiword */
*(--stack) = LOWORD(data); /* argument.loword */
*(--stack) = context->SegCs; /* STACK16FRAME.cs */
*(--stack) = LOWORD(context->Eip); /* STACK16FRAME.ip */
*(--stack) = LOWORD(context->Ebp); /* STACK16FRAME.bp */
*(--stack) = HIWORD(relay); /* STACK16FRAME.entry_point.hiword */
*(--stack) = LOWORD(relay); /* STACK16FRAME.entry_point.loword */
*(--stack) = 0; /* STACK16FRAME.entry_ip */
*(--stack) = HIWORD(RELAY_RelayStub); /* STACK16FRAME.relay.hiword */
*(--stack) = LOWORD(RELAY_RelayStub); /* STACK16FRAME.relay.loword */
*(--stack) = 0; /* STACK16FRAME.module_cs.hiword */
*(--stack) = code_sel; /* STACK16FRAME.module_cs.loword */
*(--stack) = 0; /* STACK16FRAME.callfrom_ip.hiword */
*(--stack) = 0; /* STACK16FRAME.callfrom_ip.loword */
PUSH_WORD16( context, HIWORD(data) ); /* argument.hiword */
PUSH_WORD16( context, LOWORD(data) ); /* argument.loword */
PUSH_WORD16( context, context->SegCs ); /* STACK16FRAME.cs */
PUSH_WORD16( context, LOWORD(context->Eip) ); /* STACK16FRAME.ip */
PUSH_WORD16( context, LOWORD(context->Ebp) ); /* STACK16FRAME.bp */
PUSH_WORD16( context, HIWORD(relay) ); /* STACK16FRAME.entry_point.hiword */
PUSH_WORD16( context, LOWORD(relay) ); /* STACK16FRAME.entry_point.loword */
PUSH_WORD16( context, 0 ); /* STACK16FRAME.entry_ip */
PUSH_WORD16( context, HIWORD(RELAY_RelayStub) ); /* STACK16FRAME.relay.hiword */
PUSH_WORD16( context, LOWORD(RELAY_RelayStub) ); /* STACK16FRAME.relay.loword */
PUSH_WORD16( context, 0 ); /* STACK16FRAME.module_cs.hiword */
PUSH_WORD16( context, code_sel ); /* STACK16FRAME.module_cs.loword */
PUSH_WORD16( context, 0 ); /* STACK16FRAME.callfrom_ip.hiword */
PUSH_WORD16( context, 0 ); /* STACK16FRAME.callfrom_ip.loword */
/*
* Adjust stack and code pointers.
* Adjust code pointer.
*/
ADD_LOWORD( context->Esp, -28 );
context->SegCs = wine_get_cs();
context->Eip = (DWORD)__wine_call_from_16_regs;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment