/* * vtest.acc * * this accessory tests a disk to see if it is a possible boot virus- * infected disk. * * version 1.0, 3/31/88 * * greg lindahl * * this program is in the public domain. it may be copied freely, * distributed, and even sold if you can find a sucker who's willing * to buy it. * */ #include #include #include #define Getbpb(a) bios(7,a) /* missing from my osbind.h */ #define WORD int /* alcyon version of these */ #define BYTE char #define LONG long extern WORD gl_apid; /* declared extern to work around Alcyon binding bug */ WORD menu_id ; /* our menu id */ WORD phys_handle; /* physical workstation handle */ WORD handle; /* virtual workstation handle */ WORD foo; WORD contrl[12]; WORD intin[128]; WORD ptsin[128]; WORD intout[128]; WORD ptsout[128]; WORD work_in[11]; /* Input to GSX parameter array */ WORD work_out[57]; /* Output from GSX parameter array */ WORD pxyarray[10]; /* input point array */ open_vwork() { int i; for( i = 0 ; i < 10 ; work_in[i++] = 1 ) ; work_in[10] = 2; handle = phys_handle; v_opnvwk( work_in, &handle, work_out ); } main() { appl_init(); /* result returned as global */ phys_handle = graf_handle(&foo,&foo,&foo,&foo); open_vwork(); menu_id = menu_register(gl_apid," Virus Test"); if( menu_id == -1 ) /* too many accessories */ return; multi(); /* never returns */ } multi() { WORD msgbuf[8]; /* 16 byte buffer */ while (TRUE) { evnt_mesag( msgbuf ); if( msgbuf[0] == AC_OPEN ) { if( msgbuf[4] == menu_id ) { test_disk(); } } } } test_disk() { char buf[512]; register int dno; register long reply; dno = form_alert( 3, "[0][Virus Test 1.0 (3/31/88)| |Test which floppy drive?][A|B|Cancel]" ); if( ( dno == 3 ) || ( dno == 0 ) ) return; dno--; reply = Rwabs( 0, buf, 1, 0, dno ); #define AE_CHNG (-14) if( reply == AE_CHNG ) { reply = Getbpb( dno ); reply = Rwabs( 0, buf, 1, 0, dno ); } if( reply ) { form_alert( 1, "[2][Error reading floppy disk!][Cancel]" ); return; } /* * GEMDOS disks are bootable if they checksum to the magic number 0x1234. * This is more accurate than looking for a bsr in the first byte. */ if( checksum( buf, 0x100 ) != 0x1234 ) { form_alert( 1, "[1][Disk is not bootable...|Probably not infected.][Whew!]" ); } else { form_alert( 1, "[2][Disk is bootable...|Could be infected by boot virus.][Oh No!]" ); } } int checksum( ptr, cnt ) register WORD *ptr; register int cnt; { register i; for( i = 0 ; cnt-- ; ) i += *ptr++; return( i ); }