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

This commit is contained in:
Markus Amsler 2004-10-18 22:34:02 +00:00 committed by Alexandre Julliard
parent 3be4f5d2f6
commit f56618a281
3 changed files with 27 additions and 34 deletions

View File

@ -136,6 +136,11 @@ extern struct DPMI_segments *DOSVM_dpmi_segments;
LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \ LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs ) 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 */ /* Macros for easier access to i386 context registers */
#define AX_reg(context) ((WORD)(context)->Eax) #define AX_reg(context) ((WORD)(context)->Eax)

View File

@ -392,8 +392,6 @@ void DOSVM_HardwareInterruptPM( CONTEXT86 *context, BYTE intnum )
} }
else else
{ {
WORD *stack;
TRACE( "invoking hooked interrupt %02x at %04x:%04x\n", TRACE( "invoking hooked interrupt %02x at %04x:%04x\n",
intnum, SELECTOROF(addr), OFFSETOF(addr) ); intnum, SELECTOROF(addr), OFFSETOF(addr) );
@ -401,11 +399,9 @@ void DOSVM_HardwareInterruptPM( CONTEXT86 *context, BYTE intnum )
DOSVM_PrepareIRQ( context, FALSE ); DOSVM_PrepareIRQ( context, FALSE );
/* Push the flags and return address on the stack */ /* Push the flags and return address on the stack */
stack = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp); PUSH_WORD16( context, LOWORD(context->EFlags) );
*(--stack) = LOWORD(context->EFlags); PUSH_WORD16( context, context->SegCs );
*(--stack) = context->SegCs; PUSH_WORD16( context, LOWORD(context->Eip) );
*(--stack) = LOWORD(context->Eip);
ADD_LOWORD( context->Esp, -6 );
/* Jump to the interrupt handler */ /* Jump to the interrupt handler */
context->SegCs = HIWORD(addr); context->SegCs = HIWORD(addr);
@ -506,7 +502,6 @@ void DOSVM_HardwareInterruptRM( CONTEXT86 *context, BYTE intnum )
else else
{ {
/* the interrupt is hooked, simulate interrupt in DOS space */ /* the interrupt is hooked, simulate interrupt in DOS space */
WORD* stack = PTR_REAL_TO_LIN( context->SegSs, context->Esp );
WORD flag = LOWORD( context->EFlags ); WORD flag = LOWORD( context->EFlags );
TRACE( "invoking hooked interrupt %02x at %04x:%04x\n", TRACE( "invoking hooked interrupt %02x at %04x:%04x\n",
@ -518,10 +513,10 @@ void DOSVM_HardwareInterruptRM( CONTEXT86 *context, BYTE intnum )
else else
flag &= ~IF_MASK; flag &= ~IF_MASK;
*(--stack) = flag; PUSH_WORD16( context, flag );
*(--stack) = context->SegCs; PUSH_WORD16( context, context->SegCs );
*(--stack) = LOWORD( context->Eip ); PUSH_WORD16( context, LOWORD( context->Eip ));
context->Esp -= 6;
context->SegCs = SELECTOROF( handler ); context->SegCs = SELECTOROF( handler );
context->Eip = OFFSETOF( handler ); context->Eip = OFFSETOF( handler );

View File

@ -168,7 +168,6 @@ void DOSVM_RelayHandler( CONTEXT86 *context )
*/ */
void DOSVM_BuildCallFrame( CONTEXT86 *context, DOSRELAY relay, LPVOID data ) void DOSVM_BuildCallFrame( CONTEXT86 *context, DOSRELAY relay, LPVOID data )
{ {
WORD *stack;
WORD code_sel = DOSVM_dpmi_segments->relay_code_sel; WORD code_sel = DOSVM_dpmi_segments->relay_code_sel;
/* /*
@ -176,33 +175,27 @@ void DOSVM_BuildCallFrame( CONTEXT86 *context, DOSRELAY relay, LPVOID data )
*/ */
RELAY_MakeShortContext( context ); RELAY_MakeShortContext( context );
/*
* Get stack pointer after RELAY_MakeShortContext.
*/
stack = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp);
/* /*
* Build call frame. * Build call frame.
*/ */
*(--stack) = HIWORD(data); /* argument.hiword */ PUSH_WORD16( context, HIWORD(data) ); /* argument.hiword */
*(--stack) = LOWORD(data); /* argument.loword */ PUSH_WORD16( context, LOWORD(data) ); /* argument.loword */
*(--stack) = context->SegCs; /* STACK16FRAME.cs */ PUSH_WORD16( context, context->SegCs ); /* STACK16FRAME.cs */
*(--stack) = LOWORD(context->Eip); /* STACK16FRAME.ip */ PUSH_WORD16( context, LOWORD(context->Eip) ); /* STACK16FRAME.ip */
*(--stack) = LOWORD(context->Ebp); /* STACK16FRAME.bp */ PUSH_WORD16( context, LOWORD(context->Ebp) ); /* STACK16FRAME.bp */
*(--stack) = HIWORD(relay); /* STACK16FRAME.entry_point.hiword */ PUSH_WORD16( context, HIWORD(relay) ); /* STACK16FRAME.entry_point.hiword */
*(--stack) = LOWORD(relay); /* STACK16FRAME.entry_point.loword */ PUSH_WORD16( context, LOWORD(relay) ); /* STACK16FRAME.entry_point.loword */
*(--stack) = 0; /* STACK16FRAME.entry_ip */ PUSH_WORD16( context, 0 ); /* STACK16FRAME.entry_ip */
*(--stack) = HIWORD(RELAY_RelayStub); /* STACK16FRAME.relay.hiword */ PUSH_WORD16( context, HIWORD(RELAY_RelayStub) ); /* STACK16FRAME.relay.hiword */
*(--stack) = LOWORD(RELAY_RelayStub); /* STACK16FRAME.relay.loword */ PUSH_WORD16( context, LOWORD(RELAY_RelayStub) ); /* STACK16FRAME.relay.loword */
*(--stack) = 0; /* STACK16FRAME.module_cs.hiword */ PUSH_WORD16( context, 0 ); /* STACK16FRAME.module_cs.hiword */
*(--stack) = code_sel; /* STACK16FRAME.module_cs.loword */ PUSH_WORD16( context, code_sel ); /* STACK16FRAME.module_cs.loword */
*(--stack) = 0; /* STACK16FRAME.callfrom_ip.hiword */ PUSH_WORD16( context, 0 ); /* STACK16FRAME.callfrom_ip.hiword */
*(--stack) = 0; /* STACK16FRAME.callfrom_ip.loword */ 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->SegCs = wine_get_cs();
context->Eip = (DWORD)__wine_call_from_16_regs; context->Eip = (DWORD)__wine_call_from_16_regs;
} }