Fix DPMI Event Checking in K32WowCallback16Ex

Jukka Heinonen jhei at
Sun Sep 26 13:00:11 CDT 2004

Robert Shearman:
> The first fix is to bail from the event check if we are inside the 
> system as we should do an event check when we go back to 16-bit code anyway.
> The second fix is thanks to Jukka's suggestion that iret is only 
> emulated in bad cases. In this case it was due to stack corruption 
> caused by using a stale (1 or 2 DWORDs may have been added to it) stack 
> point in K32WowCallback16Ex. The fix was to always keep the stack 
> variable up-to-date.

Well, this patch looks rather good, except for the following fragment,
which I believe to be wrong. The reason for this is that, as far as I
understand it, wine_call_to_16_regs replaces both context->SegSs and
context->Esp with TEB.cur_stack casted into SEGPTR. So these registers
can be thrashed without problems. In order to make insert_event_check
simpler I decided to use them for passing a pointer to 16-bit stack
and being lazy I decided to use linear addressing since I believe
that wine_get_ds should return a linear data segment under this context.

> @@ -653,7 +661,6 @@ BOOL WINAPI K32WOWCallback16Ex( DWORD vp
>               */
>              if (NtCurrentTeb()->dpmi_vif)
>              {
> -                context->SegSs = wine_get_ds();
>                  context->Esp   = (DWORD)stack;
>                  insert_event_check( context );
>                  cbArgs += (DWORD)stack - context->Esp;

Jukka Heinonen <>

More information about the wine-patches mailing list