home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
C
/
ISC365
/
ISC.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-15
|
6KB
|
130 lines
////////////////////////////////////////////////////////////////////////////
// //
// File: Isc.h //
// started on: 5/2/92 //
// //
////////////////////////////////////////////////////////////////////////////
// //
// V3.6 //
// ---------- //
// //
////////////////////////////////////////////////////////////////////////////
// //
// - There is a tendency of using int86, int86x in TSRs and ISC //
// derivitives, these functions are bugful, try and avoid them (even //
// inline assembly is reccomended over them). //
// //
// - while this is true in BC3.0 I'm not so sure about BC3.1 //
// //
// - DO not use the TINY memory model. //
// //
////////////////////////////////////////////////////////////////////////////
// //
// new in V3.0:- the dispatch method has been moved to mostly C code. //
// //
// new in V3.5:- the assembler part has been optimized significantly. //
// + An example of stack frame management has been added. //
// //
// new in V3.6:- the stack frame has been integrated into ISC itself. //
// + the way of calculating how much space the program takes has been//
// updated to ensure that no heap blocks may be forgotten (that //
// may of happened in the V3.5-- method!). //
// //
////////////////////////////////////////////////////////////////////////////
// //
// by Ofer Laor (AKA LeucroTTA) //
// //
////////////////////////////////////////////////////////////////////////////
#ifndef __ISC_H
#define __ISC_H
#if (__BORLANDC__< 0x300)
#error Fatal: ISC will only work on BC++ versions 3.0 and up!!!
#endif
#pragma option -k // standard stack frame from now on...
#include <stddef.h>; // NULL, size_t.
// 16 bit regs (PREPERATION FOR 32 bit support underway!!!).
struct IBYTEREGS {
unsigned char al, ah, bl, bh,
cl, ch, dl, dh;
};
struct IWORDREGS {
unsigned int ax, bx, cx, dx,
si, di, ds, es, cs, flags, ip, bp;
};
union IREGS {
struct IWORDREGS x;
struct IBYTEREGS h;
};
extern "C" void interrupt ISCDispatch(unsigned bp, unsigned di, unsigned si,
unsigned ds, unsigned es, unsigned dx,
unsigned cx, unsigned bx, unsigned ax,
unsigned ip, unsigned cs, unsigned flags
);
class ISC {
protected:
virtual void isr (IREGS ®s);
virtual void isr (void);
char* NewServerPtr;
unsigned char InitFlag;
int interrupt_num;
void interrupt (*old_vect)(...);
friend void interrupt ISCDispatch(unsigned bp, unsigned di, unsigned si,
unsigned ds, unsigned es, unsigned dx,
unsigned cx, unsigned bx, unsigned ax,
unsigned ip, unsigned cs, unsigned flags);
virtual void far * GetLocalRoutine(void);
static char *StackFrame;
static unsigned long StackFrameLen;
static int ISCcount;
ISC (void);
~ISC (void);
public:
void activate(const int int_num); // call this function if you want to
// hook an interrupt, and you didn't
// do it through the constructor.
void deactivate(void); // call this function to unhook the interrupt.
static int TSR(const int exit_code= 0, const unsigned long extraheaplen= 0);
// call this function to remain TSR,
// exit code ususaly is 0 (unless
// you change it), extraheaplen is
// the amount of heap you want to
// remain on top of what's already
// allocated... (makes the TSR
// longer in that many bytes...).
static int is_TSR(const char* app_name);
// checks to see if this program is
// already resident.
// it checks for another TSR that
// called the is_TSR with the same
// app_name...
static int reallocStack(unsigned StackLen);
// reallocates the stack frame.
// HAS to be called BEFORE any ISC
// is active!!!
};
#endif /* __ISC_H */