🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1411

Get program out of memory (C++ Dos)

#1411
From: The ChaoTix
Date: Tue, 30 Jan 2001 17:48
80 lines
3838 bytes
Hi all,

like i asked before, i need to know how to get a program out of the memory.
I
have a little explample of that kind of program. This program will "bind"
his own
function to the timer interrupt (18 times per second). My question to you
all, is
who can make this program so, that you can enable it like "Start.exe -E" or
disable it
"Start.exe -D". Here's the program that is just from C++ help. This programs
runs btw under
full dos mode, and has nothing to do with windows. Be sure that you run this
program in
dos, and not in C++, because c++ locks his interrupts.

Example:
============================================================

  #include <dos.h>      /* The clock tick interrupt */
  #define INTR 0x1C  /* Screen attribute (blue on grey) */
  #define ATTR 0x7900

  #ifdef __cplusplus
      #define __CPPARGS ...
  #else
      #define __CPPARGS
  #endif

  extern unsigned _heaplen = 1024;
  extern unsigned _stklen  = 512;

  void interrupt ( *oldhandler)(__CPPARGS);
  typedef unsigned int (far *s_arrayptr);

  void interrupt handler(__CPPARGS)
  { s_arrayptr screen[80];
     static int count;
     screen[0] = (s_arrayptr) MK_FP(0xB800,0);

  /* increase the counter and keep it within 0 to 9 */
     count++;
     count %= 10;

  /* put the number on the screen */
     screen[0][79] = count + '0' + ATTR;

  /* call the old interrupt handler */
     oldhandler();
  }


  int main(void)
  {
  /* get the address of the current clock tick interrupt */
  oldhandler = getvect(INTR);

/* install the new interrupt handler */
  setvect(INTR, handler);

  /* _psp is the starting address of the
     program in memory.  The top of the stack
     is the end of the program.  Using _SS and
     _SP together we can get the end of the
     stack.  You may want to allow a bit of
     saftey space to insure that enough room
     is being allocated ie:
     (_SS + ((_SP + safety space)/16) - _psp)
  */
  keep(0, (_SS + (_SP/16) - _psp));
  return 0;
}

=========================================================

Everybody thats has tried, thanks a lot. Anyone who has the
answer, pleaaaassseeeeee please please please please send me, and
of cource, Thanks a MORE lot!! =)

ChaoTix
Technical Details
Message-ID: <y7Dd6.277393$8r2.5304182@nlnews00.chello.com>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!212.74.64.35!colt.net!easynet-quince!easynet.net!news1.carrier1.net!amsnews01.chello.com!nlnews00.chello.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f6aa,88e59f72df81b779,start
X-Google-Attributes: gid10f6aa,public
X-Google-Thread: fcea4,88e59f72df81b779,start
X-Google-Attributes: gidfcea4,public
X-Google-Thread: 1145b7,88e59f72df81b779,start
X-Google-Attributes: gid1145b7,public
X-Google-Thread: fe885,88e59f72df81b779,start
X-Google-Attributes: gidfe885,public
X-Google-Thread: 102bfa,88e59f72df81b779,start
X-Google-Attributes: gid102bfa,public
X-Google-Thread: fa7a6,88e59f72df81b779,start
X-Google-Attributes: gidfa7a6,public
X-Google-ArrivalTime: 2001-01-30 18:01:50 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!212.74.64.35!colt.net!easynet-quince!easynet.net!news1.carrier1.net!amsnews01.chello.com!nlnews00.chello.com.POSTED!not-for-mail
From: "The ChaoTix" <The_ChaoTix@chello.nl>
Newsgroups: alt.msdos.programmer,be.comp.programming,comp.games.development.programming.misc,comp.os.msdos.programmer,comp.programming.contests,no.it.programmering.c++
Subject: Get program out of memory (C++ Dos)
Lines: 83
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <y7Dd6.277393$8r2.5304182@nlnews00.chello.com>
Date: Tue, 30 Jan 2001 17:48:14 GMT
NNTP-Posting-Host: 212.187.118.76
X-Complaints-To: abuse@chello.nl
X-Trace: nlnews00.chello.com 980876894 212.187.118.76 (Tue, 30 Jan 2001 16:48:14 GMT)
NNTP-Posting-Date: Tue, 30 Jan 2001 16:48:14 GMT
Organization: chello broadband