FPU patch for bug 586

Ove Kaaven ovehk at ping.uio.no
Tue Jun 11 11:48:46 CDT 2002


On Tue, 11 Jun 2002, admiral coeyman wrote:

> Ove Kaaven,
> > 
> > On Mon, 10 Jun 2002, admiral coeyman wrote:
> > 
> > >       This patch adds the self-modifying code part of the FPU interrupts 34->3b and
> > > moves int 3d into the winedos section.
> > 
> > Oh, I've been meaning to reply, but hadn't got around to it yet... it
> > makes no sense to use MapDosToLinear(MapRealToLinear()). It should be
> > obvious from its name that MapRealToLinear already converted to a linear
> > address, so that's all you need. And MapLinearToDos will probably *not* do
> > what you want, you should change the real-mode pointer directly instead,
> > as in general you just can't convert a linear address back to real mode.
> > Otherwise, the code is probably OK...
> >
> 	I was unsure of the memory handling functions.  Both of these functions report
> that they return linear addresses, but I read one as a dos linear address and
> the other as a wine linear address.  It was a mistake on my part.  I read it as
> though I had to convert the seg:offset code to a dos linear address, then
> convert it to a wine linear address.  It may have made more sense to me if I
> hadn't been worried about the addresses being in the wrong order.

Well, the meanings of these address types are, if I remember right:

Real = 16-bit real mode seg:ofs address
Dos = 32-bit offset from DOSMEM_dosmem (aka DOSMEM_MemoryBase()) (unless
it's above 1MB, then it's considered a linear pointer) (after the DOS
restructure, DOSMEM_dosmem is always 0, which is probably why it worked
for you)
Linear = 32-bit linear pointer that you can dereference in Wine code

I consider the "Dos" memory type pretty useless, there's almost never a
reason to use it instead of linear memory or something...

> 	What I read says that the stack's lowest address contains IP and the word
> above that is the code segment for the return.  IP:CS  I'm not sure that I
> could just point a segment:offset converting function at an address in that
> format and get the linear address.

Well, you can, as long as we stick to x86 (might be trickier if we were to
write a CPU emulator, but I guess there would be lots of places to change 
then anyway).

> 	I've done the reverse conversion be backing IP up 2 bytes.

You have two versions of the Int3dHandler in your patch. One of them isn't
changed...

Anyway, if it helps, here's how I might have written your routine (without
the error checking), if I thought that perhaps these interrupts are also
used by win16 apps (otherwise the second CTX_SEG_OFF_TO_LIN(...) can be
replaced with PTR_REAL_TO_LIN(stack[1], stack[0]))

void FPU_ModifyCode(CONTEXT86 *context, BYTE Opcode) 
{
  WORD *stack = CTX_SEG_OFF_TO_LIN(context, context->SegSs, context->Esp)
  BYTE *code = CTX_SEG_OFF_TO_LIN(context, stack[1], stack[0]);                   
  code[-2] = 0x9b;
  code[-1] = Opcode;
  stack[0] -= 2;
}





More information about the wine-devel mailing list