delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/01/22/02:52:23

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Date: Tue, 22 Jan 2002 09:51:29 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "Joel Saunders" <jbs30000 AT aol DOT com>
Message-Id: <2110-Tue22Jan2002095129+0200-eliz@is.elta.co.il>
X-Mailer: emacs 21.2.50 (via feedmail 8 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <8f6731259c2274809aa909fd0438bd8e.62691@mygate.mailgate.org>
(jbs30000 AT aol DOT com)
Subject: Re: DJGPP TSR
References: <8f6731259c2274809aa909fd0438bd8e DOT 62691 AT mygate DOT mailgate DOT org>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Joel Saunders" <jbs30000 AT aol DOT com>
> Newsgroups: comp.os.msdos.djgpp
> Date: Tue, 22 Jan 2002 05:33:42 +0000 (UTC)
> 
> What I'd like to ask is, is it possible to DJGPP program that will stay
> resident in protected mode after it ends and the computer goes back to
> real mode?

Yes, but it's a bit tricky.  There's a working example of such a TSR
on SimTel.NET, in the v2tk/djgpptsr.zip file.

However, I'd suggest to avoid a true TSR if you can.  For example, if
you can spawn a subsidiary COMMAND.COM instead of going TSR, that
would be easier to program and debug, and your program will be more
portable to different DPMI servers.

> For instance, I made a program that has the real mode mouse
> interrupt 33h call a DGJPP routine when the right mouse button is
> pushed, and that routine is supposed to make the computer beep.  But
> when I run my program, nothing happens.

I'm not sure a __dpmi_int call from a real-mode callback is supposed
to work.  So I suggest to do something simpler first: instead of
beeping, set some global variable and return.  Then in your main
program check whether that variable's value changed; if it did not,
you will know that something is wrong with the way you hook the mouse
handler.

If the simple program does work, then you could proceed to calling
interrupts from the handler.

> Here's my program, if anybody call tell me what I'm doing wrong, or, if
> it's impossible to do what I want, I'd appreciate it.  Thanks.

Well, one thing your program does not do is to unhook the handler and
deallocate it.  A footnote in the FAQ says:

  (1) If you are using this example in your program, don't forget to disable
  the handler at program's exit by calling the same function 0Ch of Int 33h
  with a zero mask in the CX register, and then deallocate the callback by
  calling the `_go32_dpmi_free_real_mode_callback' library function.  Also,
  remember that all code and data touched by the handler must be locked,
  otherwise it will crash under some DPMI servers, such as CWSDPMI.

Given enough times you run your program, the unhooked service could
give you all kinds of trouble that are unrelated to the problem you
are trying to solve.

>         r.x.ax = 0x3100;
>         r.x.dx = 4;
>         __dpmi_int(0x21, &r);

This is an absolute no-no: you can't call the DOS TSR funcion from
protected mode.  The DPMI spec disallows that.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019