Windows support
Brought to you by:
bartoldeman
dosemu's dpmi host (cvs version) has problems with
routing int 23h to protected mode. The routing itself
works, but it seems to me that some register
information gets lost when returning to real-mode, for
example the contents of the floating-point registers
change to "random" values.
There are other odd things, but possibly these look
better once this problem is resolved.
Logged In: YES
user_id=501371
Where is your glorious test-case?
Does the information gets lost when you do retf/CF, or also
even when you just do iret?
Anyway, see the attached patch. It should handle the
termination case (retf/CF) better.
Logged In: YES
user_id=501371
Could you please also provide the test-case for the
windows binaries relocation problem? (when more than
one stripped binary started) I wonder why you haven't
told us about that problem before. It is not something
that we can't quickly fix I suppose.
Logged In: YES
user_id=982058
I attached the simple test case for int 23h. It's the binary
and the asm source code (though you wont be able to assemble
it, its meant as info only).
escape key
if you run this app and DON'T press ctrl-c, it should
display "no changes..."
if you run it and press ctrl-c before pressing escape it
displays an error with dosemu. on other platforms still
displays "no changes...".
In my eyes that is not a bug, it's just a missing feature of
dosemu. It would require dosemu to provide something like
the DPMI V1.0 feature "virtual machines" (multiple address
contexts). I thought this would be too sophisticated for the
moment. And if in the near future dosemu will run windows
95, this feature will have been implemented anyway ;-).
Logged In: YES
user_id=501371
Logged In: YES
user_id=982058
Sounds great. But there is the problem that no dpmi API is
defined to start an application in a new address context.
With HX I do it simply by hiding the current dpmi server
instance (for that real mode int 2f, ax=1687h is
intercepted). So another server will have to be loaded if a
new client wants to start. But how to implement anything
similiar in dosemu? Would one have to define a proprietary
API for that? Setting an environment variable? Or an option
in .dosemurc?
Logged In: YES
user_id=501371
Logged In: YES
user_id=982058
I thought the problem was:
info and the same image base), the first calling the second.
This doesn't work with dosemu because there is one address
space only to be shared by all dpmi clients, so the first
will be loaded and run, the second fails to load when trying
to alloc memory with 0x504.
But what would you - or dosemu - do then when/after function
0x504 failed?
Possibly I should remind you that this thread is about int
23h errors and loosing floating point register values.
Logged In: YES
user_id=501371
Btw, I figured out the problem with 32rtm (which you
probably haven't ever triggered under dosemu). It will
silently disappear soon, noone will even notice.
Still trying to get krnl286 running when int2f reports
standard mode. krnl386 already works, but no luck
with the 286 one...
Logged In: YES
user_id=501371
Logged In: YES
user_id=982058
I got the current cvs.
The test with the "IRET" int 23h handler now works and
doesn't trash registers.
I can also confirm that an int 23h handler which returns
with
STC
RETF ;only RETF, not RETF 2/4,as it is described in RBIL!
activates dosemu's automatic termination. This work fine -
as long as no special cleanup work has to be done by the
client. But one should be aware that this termination method
is supported by dosemu only, not by winxp or win9x hosts.
calls
int 21h, ah=4Ch has problems, especially if it isn't the
primary
client who is terminating. Here win9x does a good job, but
winxp has its own problems with this variant.
Personally I think this thing now works good enough.
Logged In: YES
user_id=501371
Logged In: YES
user_id=982058
IIRC I said it wouldn't help with the WD problem.
But with "primary client" I meant simply the first client
starting in this dos box. Your suggestion was, IIRC, to
check if it is the "active" client (the last one started in
the box) which is terminating and do a better clean-up work
if it is NOT.
Logged In: YES
user_id=982058
That sounds a bit hazardous. I doubt that you can determine
in the host if the memory region can be safely "moved away".
The best I can currently imagine for dosemu is to optionally
start a new "virtual machine" when a new client starts, with
the conventional memory being a shared region (so not really
a VM). The previous client's extended memory, IDT, LDT, IVT?
and real-mode callbacks have to be saved, initialized and
later restored. In fact, this is just a little bit more than
what is done for a DPMI V1.0 client.
Logged In: YES
user_id=501371
So you might be confused.
<pedantic mode="" off="">
Logged In: YES
user_id=982058
But since - at least for 0.9 servers - a new client inherits
the IDT/LDT of the previous (or "inactive") client, how
could you be sure that in the memory you just moved away
there is no code of the inactive client to be executed?
I'm afraid I am misunderstanding something.
Logged In: YES
user_id=501371
Logged In: YES
user_id=501371
Of course if some idiot will activate another client with the
far calls, then I think my technique will screw up. But is
this really ever happens in the real world?
Logged In: YES
user_id=982058
I think yes. Example:
new client installs handler for int 21h, which may look
like this:
cmp ah, xx ;wants to catch xx function
jz domywork
jmp fword ptr cs:[oldint21] ;jmp to previous handler
domywork:
....
iret
That's usual coding, and in this trivial case you already
have this far jump. Not to mention pointer parameters, which
would require yet another API translation layer.
Logged In: YES
user_id=501371
Logged In: YES
user_id=501371
A bit of cheating, and you can attach (the win32 testcases)
to the "Windows support" thread.
Logged In: YES
user_id=982058
before doing win32 stuff I would suggest to fix win16 bugs.
There is at least one causing TDW.EXE to not work under
win311 in dosemu. I once wrote another win31 debugger, and
it doesnt work either - as long as it uses toolhelp.dll,
which is used by TDW as well. If it bypasses tooolhelp by
installing its own exception handlers, everything works.
So I examined toolhelp a bit and found:
Using interrupt handlers instead of exception handlers
should work for exceptions 0-7 according to dpmi specs. The
default handlers for these exceptions should switch back to
the application stack and then call the appropriate interrupt.
I suspect that dosemu doesn't do this, so toolhelp isn't
notified about int 1 and int 3, and therefore TDW is unable
to work.
BTW: since the dpmi specs also says that protected mode
interrupts should be routed to real mode, the exceptions may
finally be reported to the real-mode interrupt handlers. One
may argue if this is useful. Anyway, the win9x host (and
hdpmi) are doing it.
As usual I attached a simple test app. I should mention that
the test fails not only on dosemu, but also with dosx on winxp.
Logged In: YES
user_id=501371
Logged In: YES
user_id=982058
all dpmi hosts I know - including dosx of winxp, the one
exception is dosemu - route exceptions to protected mode
ints. On the other hand, routing from pm ints to real-mode
ints is sometimes implemented for int 1 and 3, but never for
int 0 and 6 (the others I dont know). IMHO this is just a
typo in the docs, because what sense would it make to route
int 00 to real-mode? The app would be terminated in
real-mode, leaving the client with an invalid PSP and the
system crashes.
I was a bit tired I have to admit, but not confused.
If the real-world looks different, one may possibly ignore
the docs :-)
it was an int 3, not int 6!
No, dosx is ill. The test-case is bad only because it uses
exception 3, so it is hard to debug. With a similiar
test-case for exception 0 it can easily be shown that dosx
(eip + cs +eflags should be on the stack, but dosx pushes
eip + eflags + eflags!). So the IRET fails.
Exception 00 is a far better case to watch, especially with
win31, because it can be seen that the exception handler is
installed by GDI (to silently cure GDI exceptions), but the
pm interrupt handler is installed from krnl386, which in
turn signals divide errors to the apps. If exceptions were
routed directly to real-mode, this cannot work. So making a
simple win16 test app should prove that dosemu is failing.
Logged In: YES
user_id=982058
In case it was confusing: with "dosx" in the last post I
meant windows xp's dosx, not win31's dosx:
Logged In: YES
user_id=982058
I made and attached this test app. If the exc -> pm int
routing works finally, this app will no longer crash dosemu