精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>C/C++>>DOS编程>>DOS中断驻留框架(5/6)

主题:DOS中断驻留框架(5/6)
发信人: riffle()
整理人: wenbobo(2002-08-13 10:45:45), 站内信件
/* author : *** */
/*--------------------------------------------------------------------
--*/

// TSRINTER.CPP

// 本模块和TEST.CPP、TSRINT.CPP、TSR框架LIB一起做一个project,在large或

// huge模式下编译生成EXE文件以后,就具有驻留及退出驻留的功能了。

// 该模块还可以用于其它使用该驻留程序提供的软中断的project。

#include <DOS.H>
#include <STDIO.H>
#include "ITSR.H"

// IITSR.H中的定义如下
/*const unsigned int INSTALLEDSIGN = 0x474D;     // 'GM'

const int INTERFACEINT = 0xA8;

const unsigned int REMOVECMD = 0x01;
const unsigned int CHECKINTCMD = 0x02;*/

#include "TSRINTER.H"
// TSRINTER.H 中的定义如下

/*
int IsTsrInstalled( void );
int RemoveTsr( void );
*/

/*--------------------------------------------------------------------
--*/

static unsigned char ucTsrChecked = 0;
static int iTsrHaveInstalled = 0;

/*--------------------------------------------------------------------
--*/
/*********************************************************************
***/
int IsTsrInstalled( void )
{
  if ( ucTsrChecked )
    if ( getvect( INTERFACEINT ) != NULL )
      return iTsrHaveInstalled;

  ucTsrChecked = 1;

  union REGS inregs;
  union REGS outregs;
  if ( getvect( INTERFACEINT ) != NULL )
    {
      inregs.x.ax = CHECKINTCMD;
      // 调用软中断检查,是否已经驻留。
      int86( INTERFACEINT, &inregs, &outregs );

      if ( outregs.x.ax == INSTALLEDSIGN );
        iTsrHaveInstalled = 1;
    }
  else
    iTsrHaveInstalled = 0;

  return iTsrHaveInstalled;
}
/*********************************************************************
***/

/*********************************************************************
***/
int RemoveTsr( void )
{
  union REGS inregs;
  union REGS outregs;

  if ( IsTsrInstalled() )
    {
      inregs.x.ax = REMOVECMD;
      // 调用软中断执行退出驻留的命令。
      int86( INTERFACEINT, &inregs, &outregs );
      if ( outregs.x.ax == 0xFFFF )
return 0;
    }
  return 1;
}
/*********************************************************************
***/
/*********************************************************************
***/
/*********************************************************************
***/

--
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.104.39.56]

[关闭][返回]