delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2005/10/08/16:00:19

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Rod Pemberton <donthave AT noreply DOT bit>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need to hook INT 21h from a DJGPP TSR
Date: Sat, 8 Oct 2005 19:47:00 +0000 (UTC)
Organization: cyberjustice.org
Lines: 113
Message-ID: <di97nk$5nc$1@sadr.dfn.de>
References: <cone DOT 1128591471 DOT 368325 DOT 13774 DOT 0 AT digisoft> <di47pc$lfa$1 AT sadr DOT dfn DOT de> <cone DOT 1128678305 DOT 262815 DOT 30667 DOT 0 AT digisoft> <di6nfr$8bl$1 AT sadr DOT dfn DOT de> <di6ouv$8to$1 AT sadr DOT dfn DOT de> <di72gs$clu$1 AT sadr DOT dfn DOT de> <1128790995 DOT 160422 DOT 143560 AT g44g2000cwa DOT googlegroups DOT com>
NNTP-Posting-Host: server1.imagine-host.com
Mime-Version: 1.0
X-Trace: sadr.dfn.de 1128800820 5868 66.28.207.11 (8 Oct 2005 19:47:00 GMT)
X-Complaints-To: usenet AT sadr DOT dfn DOT de
NNTP-Posting-Date: Sat, 8 Oct 2005 19:47:00 +0000 (UTC)
X-User-Real-E-Mail: nobody AT no DOT where DOT com
User-Agent: http://www.cyberjustice.org
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> It can lead to many undesirable "PM" -> "RM" -> "PM Again"
> chain loops.

That's probably the problem.  The following code shows how to work
around it for int 0x21,ax=0x4b00 to ax=0x4b05.  Like I stated
before it works for PMODE/DJ w/RM and PM apps.  For CWSDPMI, it
only works for RM apps, giving the "Page Fault ... in RMCB" for PM
apps.  I don't know exactly what memory needs to be locked for
CWSDPMI.

Rod Pemberton


#include <stdio.h>
#include <stdlib.h>
#include <dpmi.h>
#include <go32.h>
#include <crt0.h>
#include <sys/farptr.h>
#include <string.h>
#include <pc.h>
#include <io.h>

#define hexch(x) (((x)<0x0A)?(0x30+(x)):(0x37+(x)))
extern int __djgpp_base_address; /* crt0.s */

int _crt0_startup_flags = _CRT0_FLAG_LOCK_MEMORY;
//                         |_CRT0_FLAG_NONMOVE_SBRK;

char ** __crt0_glob_function(char *arg) { return (char **)0; }
void   __crt0_load_environment_file(char *app_name) {}
void   __crt0_setup_arguments (void) {}

_go32_dpmi_registers r;
_go32_dpmi_seginfo rmint,rmold;

#if 0
__dpmi_meminfo lck;
#endif

void color_rot(unsigned char x)
{
  unsigned offset = ScreenPrimary+(2*80-2*x+1-20);
  _farpokeb(_dos_ds,offset,1+_farpeekb(_dos_ds,offset));
}

void intcore(_go32_dpmi_registers *r)
{
  unsigned offset = ScreenPrimary+(2*80-2*7-20);
  char ch[6];
  int i;

  ch[0] = hexch(2); // int21
  ch[1] = hexch(1);
  ch[2] = hexch(r->h.ah>>4);
  ch[3] = hexch(r->h.ah&0x0F);
  ch[4] = hexch(r->h.al>>4);
  ch[5] = hexch(r->h.al&0x0F);

  for (i=0;i<6;i++) {
   _farpokeb(_dos_ds,offset+i*2,ch[i]);
   _farpokeb(_dos_ds,offset+i*2+1,0x6F);
  }
  color_rot(1);
}

void inttrm(_go32_dpmi_registers *r)
{
  intcore(r);
  if ((r->h.ah == 0x4b) && (r->h.al < 0x05))
  {
      _go32_dpmi_set_real_mode_interrupt_vector(0x21, &rmold);
      _go32_dpmi_simulate_int(0x21,r);
      _go32_dpmi_set_real_mode_interrupt_vector(0x21, &rmint);
  }
  else
  {
      r->x.cs = rmold.rm_segment;
      r->x.ip = rmold.rm_offset;
      _go32_dpmi_simulate_fcall_iret(r);
  }
}

int main(void)
{
   memset(&r,0,sizeof(r));

  _go32_dpmi_get_real_mode_interrupt_vector(0x21, &rmold);
   rmint.pm_offset = (unsigned long)&inttrm;
  _go32_dpmi_allocate_real_mode_callback_iret(&rmint,&r);
  _go32_dpmi_set_real_mode_interrupt_vector(0x21, &rmint);

#if 0
  lck.size=(unsigned long);
  lck.address=(unsigned long);
  __dpmi_lock_linear_region(&lck);
#endif

   _write(2,"Installing DJGPP TSR\r\n",22);

   r.x.ax = 0x3100;
   r.x.dx = (131072)  / 16;         /* paragraphs (16 bytes) */
                                    /* file size + 100 for PSP */
   r.x.cs = rmold.rm_segment;
   r.x.ip = rmold.rm_offset;

  _go32_dpmi_simulate_fcall_iret(&r);

exit(0);
}

--
Posted via: http://www.cyberjustice.org

- Raw text -


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