Category : Utilities for DOS and Windows Machines
Archive   : GRABINT.ZIP
Filename : GRABINT.C

 
Output of file : GRABINT.C contained in archive : GRABINT.ZIP
/*
Grab the interrupt vector requested and write it to a disk
file in a format that can be read later on and resotred.


 Caveat: This program can be very dangerous if used improperly!!



Version 1.0 10dec86 mgm - initial release
1.1 30jul87 mgm - cleanup

*/


#include
#include
#include
#include




char *psyntax[] = {
"GRABINT version 1.1",
" ",
"",
" Caveat: This program can be very dangerous if used improperly! ",
"",
" ",
" Syntax: grabint filespec n1 n2 ... nn",
" ",
" where filespec is the name of the file to save the vectors in,",
" or read the vectors from.",
" n1 n2 ... nn are the interrupt vectors to save.",
" ",
" To save vectors, specify the filename and the vectors to save.",
" To restore saved vectors, just specify the filename. All vectors",
" saved in the file are restored.",
" ",
" ",
" Example: grabint c:\\five.int 5",
" will save the vector for interrupt 5 in c:\\five.int",
" ",
" grabint c:\\five.int",
" will restore all vectors stored in c:\\five.int",
""
};


byte buf[256];

struct {
unsigned int num;
unsigned int segment;
unsigned int offset;
} inttbl[256];

union REGSS reg;


void main (argc, argv)
int argc;
char *argv[];
{
int i;
int cnt;
int intcnt;
FILE *pfint;



if (argc == 1) {
for (i = 0; *psyntax[i] != '\0'; i++) {
printf ("%s\n", psyntax[i]);
} /* for (i = 0... */
exit (1);
} /* if (argc... */

printf ("%s\n", psyntax[0]);


if (argc == 2) { /* only filespec, restore ints */

pfint = fopen (argv[1], "ra");
if (pfint == NULL) {
printf ("Unable to open file \"%s\", does it exist?\n",
argv[1]);
exit (2);
} /* if (pfint... */

intcnt = 0;
while (NULL != fgets (buf, sizeof (buf), pfint)) { /* read vectors */

if (*(stpblk (buf)) == '*') continue; /* comment */

cnt = sscanf (buf, "%x %x %x",
&inttbl[intcnt].num, &inttbl[intcnt].segment,
&inttbl[intcnt].offset);

if (cnt != 3) {
printf ("Error in syntax of restore file.\n");
printf ("No vectors restored.\n");
fclose (pfint);
exit (3);
} /* if (cnt != 3) */

intcnt++;
} /* while (NULL != ... */

fclose (pfint);

for (i = 0; i < intcnt; i++) { /* restore vectors */
printf (" Restoring interrupt %02X to %04X:%04X.\n",
inttbl[i].num, inttbl[i].segment, inttbl[i].offset);

reg.h.ah = 0x25;
reg.h.al = (byte)inttbl[i].num;
reg.x.ds = inttbl[i].segment;
reg.x.dx = inttbl[i].offset;
intdoss (®, ®);

} /* for (i = 0... */

} /* if (argc == 2) */




else { /* get and save vectors */

for (intcnt = 0; intcnt < argc-2; intcnt++) { /* get vectors */

if (strlen (argv[intcnt+2]) != stch_i (argv[intcnt+2],
&inttbl[intcnt].num)) {
printf ("Invalid interrupt number: %s.\n",
argv[intcnt+2]);
printf ("No interrupts saved.\n");
exit (4);
} /* if (strlen... */

printf (" Interrupt vector %02X:", inttbl[intcnt].num);

reg.h.ah = 0x35;
reg.h.al = inttbl[intcnt].num;
intdoss (®, ®);
inttbl[intcnt].segment = reg.x.es;
inttbl[intcnt].offset = reg.x.bx;

printf (" %04X:%04X.\n", inttbl[intcnt].segment,
inttbl[intcnt].offset);

} /* for (intcnt = 0... */

pfint = fopen (argv[1], "wa");
if (pfint == NULL) {
printf ("Unable to create file \"%s\".\n", argv[1]);
exit (2);
} /* if (pfint... */

fputs ("* Interrupt save file.\n", pfint);

for (i = 0; i < intcnt; i++) {
fprintf (pfint, "%02X %04X %04X\n",
inttbl[i].num, inttbl[i].segment, inttbl[i].offset);
} /* for ; ... */

fclose (pfint);
} /* else */

exit (0);

} /* void main (argc, argv) */


  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : GRABINT.ZIP
Filename : GRABINT.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/