Hi everybody,
I hope this one proves somewhat interesting. First, let me give you a
short bit of background history to understand what I'm trying to do.
I'm in the process of writing a wrapper for an old game (Ultima VII). This
game uses special protected mode instructions which are incompatible with
nearly everything else, including in particular any protected mode OS, so
I'm trying to replace these instruction and make it possible to run the
game under modern hardware. I intended to use Dosemu for testing and
debugging, so that I don't have to reboot every time I make a mistake.
The way this wrapper will work is by replacing all access beyond real-mode
memory, i.e. all those instructions which have the operand-size prefix
(0x67) by a software interrupt instruction which will then emulate the
protected mode memory. For example, instead of
66 67 8b 1e MOV EBX,[ESI]
I would have
66 cd a0 xx INT A0
This may look a bit weird, but it is necessary to do what I need to do.
The CPU will ignore all prefixes to an int call, and the interrupt handler
can then look at them and emulate the instruction accordingly. xx is a
special code for interrupt handler determining the exact instruction, and
is not executed when returning from the interrupt by manipulating the IP on
the stack.
So far, so good. It seems to work pretty well in a Windows 95 DOS box as
well as in real DOS. However, these are a pain to develop under, and when
I try to run this in Dosemu, I get a segmentation violation for all
interrupts with a prefix. The unprefixed interrupts, for example in the
case where I replace
67 8a 06 MOV AL,[ESI]
with
cd a0 xx INT A0
work fine, but any time there is a prefix, dosemu crashes with a segfault.
Now, I understand that this is a pretty unique problem, so I'm very much
willing to fix it myself and hopefully supply a patch to the dosemu team,
but I've been looking through the source code and tried to understand why
or where the crash happens, but unfortunately I didn't get very far. I'm
not even sure where exactly I'd have to look.
So, does anybody have any idea why this is happening, and what I can do to
fix it? Why does a prefixed int xx cause a segfault when a regular one
works fine?
Oh, and if anybody wants to look at the source code of my wrapper, it's
available here: http://publish.uwo.ca/~jdrexler/ultima/u7patch/ . It's
written in Borland C++ 3.1. (I can't use DJGPP because it has to be real
mode.) You'd also need Ultima VII to test it, though.
I would welcome and very much appreciate any help I could get on this.
Ultima VII is considered by many to be a classic, and it's a shame that you
have to jump through hoops to make it run on today's hardware. But
developing the wrapper under Win95 is tedious. I'd much prefer if I could
use dosemu under Linux, then I wouldn't have to reboot every few minutes...
Thanks again for reading this and for all comments you can give.
--
Josef Drexler ([EMAIL PROTECTED])
http://publish.uwo.ca/~jdrexler/