home *** CD-ROM | disk | FTP | other *** search
/ Hacker 2 / HACKER2.mdf / virus / st0.c < prev    next >
C/C++ Source or Header  |  1995-01-03  |  2KB  |  84 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3. #include <conio.h>
  4. #include <process.h>
  5. #include <stdlib.h>
  6. #include <alloc.h>
  7. #include <io.h>
  8. #include <bios.h>
  9.  
  10.  /*
  11.   * This program will save your hard disk's track zero data.  It is
  12.   * specifically designed to provide a remedy against the the so-called
  13.   * "Columbus day" virus. 
  14.   *
  15.   * This program may be freely copied. 
  16.   *
  17.   * Author:  John Clason, KZ1O [70441,2456] 
  18.   *
  19.   */
  20.  
  21. void error(int code)
  22. {
  23.     switch (code) {
  24.     case 1:
  25.      fprintf(stderr, "Unable to allocate enough memory\n");
  26.     break;
  27.     case 2:
  28.     fprintf(stderr, "Unable to create file A:TRACK.000\n");
  29.     break;
  30.     case 4:
  31.     fprintf(stderr, "Unable to complete writing to floppy disk\n");
  32.     break;
  33.     default:
  34.     fprintf(stderr, "Unknown error occurred: %d\n", code);
  35.     break;
  36.     }
  37.     exit(code);
  38. }
  39.  
  40. int main(void)
  41. {
  42.     char *buffer;
  43.  
  44.     unsigned cx, dx;
  45.     int maxhead, maxsectors, h;
  46.     int fd;
  47.     unsigned bytes;
  48.  
  49.     printf("Saving hard disk track zero onto A:TRACK.000\n"
  50.     "More public domain software from J. Clason [70441,2456]\n");
  51.  
  52.     _DL = 0x80;
  53.     _AH = 8;
  54.     geninterrupt(0x13);        /* get params */
  55.  
  56.     cx = _CX;
  57.     dx = _DX;
  58.  
  59.     maxhead = dx >> 8;
  60.     maxsectors = cx & 0x3f;
  61.  
  62. #ifndef ALLCYLINDER
  63.     maxhead=0;
  64. #endif
  65.  
  66.     buffer = calloc(bytes = (maxsectors * 512), 1);
  67.     if (buffer == NULL)
  68.     error(1);
  69.  
  70.     fd = _creat("a:track.000", 0);
  71.     if (fd < 0)
  72.     error(2);
  73.  
  74.     for (h = 0; h <= maxhead; h++) {
  75.     biosdisk(2, 0x80, h, 0, 1, maxsectors, buffer);
  76.     if (_write(fd, buffer, bytes) != bytes)
  77.         error(4);
  78.     }
  79.     close(fd);
  80.     return 0;
  81. }
  82.  
  83. Downloaded From P-80 International Information Systems 304-744-2253
  84.