home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1989 / USER1189.MSA / VIRUS.C < prev    next >
C/C++ Source or Header  |  1989-09-03  |  2KB  |  124 lines

  1. /*    Virus Killer
  2.     By R.A.Waddilove
  3.     Last altered 27/08/89
  4. */
  5.  
  6. #include <obdefs.h>
  7. #include <osbind.h>
  8.  
  9. #define SHOW 257
  10. #define HIDE 256
  11. #define POINTER 0
  12. #define BEE 2
  13.  
  14. #define DIALOGUE    0
  15. #define QUIT         5
  16. #define TEST        6
  17. #define BOX            7
  18. #define KILL        8
  19.  
  20. int    contrl[12],
  21.     intin[128],
  22.     intout[128],
  23.     ptsin[128],
  24.     ptsout[128],
  25.     work_in[12],
  26.     work_out[57];
  27.  
  28. int    handle,
  29.     hchar,
  30.     wchar,
  31.     dx,dy,dw,dh,
  32.     drive;
  33.  
  34. char buffer[1100];
  35.  
  36. OBJECT *dialog;
  37.  
  38. gem_on()
  39. {
  40.     int i;
  41.     appl_init();
  42.     handle = graf_handle(&wchar,&hchar,&i,&i);
  43.     for ( i=0; i<10; work_in[i++]=1);
  44.     work_in[10] = 2;
  45.     return (v_opnvwk(work_in,&handle,work_out));
  46. }
  47.  
  48. gem_off()
  49. {
  50.     rsrc_free();
  51.     v_clsvwk(handle);
  52.     appl_exit();
  53. }
  54.  
  55. main()
  56. {
  57.     if ( gem_on()==0)
  58.         gem_off();
  59.     if ( !rsrc_load("virus.rsc") )
  60.         gem_off();
  61.     rsrc_gaddr(0,DIALOGUE,&dialog);
  62.     form_center(dialog,&dx,&dy,&dw,&dh);
  63.     dx = 8*(dx/8);    dialog->ob_x = dx;
  64.     dy = 8*(dy/8);    dialog->ob_y = dy;
  65.     drive = Dgetdrv();
  66.     if ( drive>1 ) drive = 0;
  67.     do_dialog();
  68.     gem_off();
  69. }
  70.  
  71. do_dialog()
  72. {
  73.     register int result;
  74.     graf_mouse(POINTER,0);
  75.     graf_mouse(HIDE,0);
  76.     form_dial(0,0,0,0,0,dx,dy,dw,dh);
  77.     objc_draw(dialog,0,32767,dx,dy,dw,dh);
  78.     do {
  79.         graf_mouse(SHOW,0);
  80.         do {
  81.             result = form_do(dialog,0);
  82.         } while ( result<1 || result>8 );
  83.         graf_mouse(HIDE,0);
  84.         objc_draw(dialog,BOX,0,dx,dy,dw,dh);
  85.         if ( result == TEST )    check_disc();
  86.         if ( result == KILL )    kill_virus();
  87.         dialog[result].ob_state ^= SELECTED;
  88.         objc_draw(dialog,result,0,dx,dy,dw,dh);
  89.     } while ( result!=QUIT );
  90.     form_dial(3,0,0,0,0,dx,dy,dw,dh);
  91.     graf_mouse(SHOW,0);
  92. }
  93.  
  94. check_disc()
  95. {
  96.     register int x,y;
  97.     x = dx+wchar*3;
  98.     y = dy+hchar*13;
  99.     Floprd(buffer,0L,drive,1,0,0,1);
  100.     if ( buffer[0] == 0x60 ) {
  101.         v_gtext(handle,x,y,"Boot sector program present.");
  102.         v_gtext(handle,x,y+hchar,"If this disc shouldn't have");
  103.         v_gtext(handle,x,y+2*hchar,"one it might be a virus.");
  104.         return;
  105.     }
  106.     if ( buffer[0]+buffer[1] == 0 ) {
  107.         v_gtext(handle,x,y,"Standard boot sector.");
  108.         v_gtext(handle,x,y+hchar,"This disc is ok.");
  109.     }
  110.     else {
  111.         v_gtext(handle,x,y,"Non-standard boot sector.");
  112.         v_gtext(handle,x,y+hchar,"Might be a virus.");
  113.     }
  114. }
  115.  
  116. kill_virus()
  117. {
  118.     Floprd(buffer,0L,drive,1,0,0,1);
  119.     buffer[0] = 0;
  120.     buffer[1] = 0;
  121.     Flopwr(buffer,0L,drive,1,0,0,1);
  122.     check_disc();
  123. }
  124.