®å ¸n tèt nghiÖp Phô lôc. liÖt kª ch¬ng tr×nh nguån File 1: Testvir.C #include <stdio.h> #include <dos.h> #include <conio.h> #include <alloc.h> #include <string.h> #include <stdlib.h> extern int test_mem(void); extern int test_vir_mem(void); extern int test_vir_mb(void); extern int khoi_phuc_mb(void); extern int giai_ma_oh(void); extern int de_mb_chuan(void); extern int test_file(void); extern int save_screen(void); extern int store_screen(void); char far * buff_track; char mota[80], duongdan[80], tenfile[80]; /*--------------------*/ int main(int argc, char *argv[]) 1 ®å ¸n tèt nghiÖp { int gttest_mem,gttest_vmem; int gttest_vmb; int loop=1; char *doi,cont; int i=0; textbackground(1); textcolor(15); clrscr(); trinh_bay(); if(argc==1) { huongdan(); return 0; } doi=strupr(argv[1]); while (*doi!='\0') { mota[i]=duongdan[i]=tenfile[i]=*doi; doi++; i++; } if(mota[i-1]!='\\') { duongdan[i]=tenfile[i]=mota[i]='\\'; i++; } duongdan[i]=tenfile[i]='\0'; mota[i] = '*'; mota[i+1] = '.'; mota[i+2] = '*'; mota[i+3] = '\0'; gttest_vmem=test_vir_mem(); 2 ®å ¸n tèt nghiÖp if(gttest_vmem==1 || gttest_vmem==3) return 1; else { gttest_mem=test_mem(); switch(gttest_mem) { case 1: cont=f_message(1," Vung nho khong du 640K !", " Co tiep tuc khong <Y/N>? "); break; case 2: cont=f_message(1," Dia chi Int21h sai !", "Co tiep tuc khong <Y/N> ? "); break; case 3: cont=f_message(1,"Vung nho khong du 640K va dia chi Int21h bi sai!", "\n Co tiep tuc khong <Y/N> ? "); break; default: f_message(0,"Kiem tra thay Memory tot!", "Press any key to continue"); cont='Y'; } if(cont=='N'||cont=='n') return 1; } do { gttest_vmb=test_vir_mb(); switch(gttest_vmb) { case 1: /* Phat hien ra VR */ 3 ®å ¸n tèt nghiÖp cont=f_message(1,"Master Boot nhiem virus One Half", "Co giai ma phan thong tin bi virus OH ma hoa khong <Y/N> ? "); if(cont=='Y' || cont=='y') { printf("\n Giai ma thong tin tren dia : \n"); buff_track=(char *)malloc(32256); /*63 sector*/ if(buff_track==NULL) exit(1); giai_ma_oh(); free((void *)buff_track); } cont=f_message(1,"","Co khoi phuc Master Boot khong <Y/N> ?"); if(cont=='Y'||cont=='y') { khoi_phuc_mb(); loop=1; } else loop=0; break; case 2: /* Not OK song khong phat hien ra VR*/ cont=f_message(1,"Master Boot khong chuan,", "Co de Master Boot chuan khong <Y/N> ? "); if(cont==1) { de_mb_chuan(); printf("\n Da khoi phuc xong Master Boot\n\n"); } loop=0; break; case 3: 4 ®å ¸n tèt nghiÖp f_message(0,"Loi doc dia","Press any key to continue ."); return 1; default: f_message(0,"Master Boot OK!", "Press any key to continue ."); printf("\n Master Boot OK \n\n"); loop=0; } } while (loop>0); printf(" Test File \n\n"); test_file(); return 0; } /*---------------------------*/ f_message(int ques, char *mess1, char *mess2) { int length,left,top,right,bottom,space=10; int row_cursor,column_cursor; char ch; int l1,l2; save_screen(); column_cursor=wherex(); row_cursor=wherey(); l1=strlen(mess1); l2=strlen(mess2); length=l1; if(length<l2) length=l2; length+=space; 5 ®å ¸n tèt nghiÖp left=(80-length)/2; top=11; right=left+length-1; bottom=14; window(left,top,right,bottom); textbackground(MAGENTA); clrscr(); gotoxy((length-l1)/2,2); puts(mess1); gotoxy((length-l2)/2,3); puts(mess2); if(ques==1) while(1) { ch=getch(); if(ch=='Y'||ch=='y'||ch=='N'||ch=='n') break; } else ch=getch(); store_screen(); window(1,1,80,25); gotoxy(column_cursor,row_cursor); return ch; } /*--------------------------------*/ int huongdan() { printf("\n Command:"); 6 ®å ¸n tèt nghiÖp printf("\n Testvir <drive:>[path]"); printf("\n For example:"); printf("\n Testvir C:"); printf("\n Testvir C:\\DOS"); return 1; } /*---------------------*/ int trinh_bay() { printf("\n TESTVIR Ver 1.0 04.1996"); printf("\n Copyright by Nguyen The Hong Luc - DHBK Ha noi"); printf("\n -----------------------------------------------"); return 1; } 7 ®å ¸n tèt nghiÖp File 2: testmem.asm .model small .data int21_620 dw 40F8h dw 0019h adr_int21 equ 084h int13_620 dw 0774h dw 0070h adr_int13 equ 04Ch adr_totalmem equ 0413h vir_mem db 19h dup(0) file_vmem db 'VMEM.DAT',0 message_read_file_error db 'File VMEM.DAT not found! $' message_lost_mem db 'Vung nho dos DOS quan ly khong du 640 KB $' message_error_ver db 'Khong kiem tra duoc dia chi ngat 21h ung voi ver nay$' message_error_ver1 db 'Hay khoi dong bang dia kiem tra nay (dos 6.20) roi testvir$' message_press_any_key db 'An phim bat ky de tiep tuc . $' message_virus_in_mem db 'Trong memory co virus : $' 8 ®å ¸n tèt nghiÖp .code extrn xuong_dong : proc extrn write_screen : proc extrn press_any_key : proc extrn hoi : proc public _test_mem _test_mem proc push es push ds mov ax,@data mov ds,ax xor ax,ax mov es,ax ; es=0 push ax mov bx,adr_totalmem mov ax,es:[bx] cmp ax,0280h ; Co du 640K hay khong pop ax jz test_int ; Neu du thi test_interupt mov dx,OFFSET message_lost_mem call write_screen call xuong_dong mov ax,1 ; jmp vir_in_memory test_int: ; mov bx,adr_int13 ; les ax,es:[bx] ; ax=offset_int13, es=seg_int13 ; cmp ax,off_int13 9 ®å ¸n tèt nghiÖp ; jnz vir_in_memory ; mov ax,es ; cmp ax,seg_int13 ; jnz vir_in_memory push ax mov ah,30h int 21h ver_620: cmp ax,1406h ; DOS 6.20 jnz ver_other mov dx,OFFSET int21_620 jmp continue ver_other: mov dx,OFFSET message_error_ver call write_screen call xuong_dong mov dx,OFFSET message_press_any_key call write_screen call xuong_dong call press_any_key mov ax,0FFFFh push ax mov ax,0 push ax retf continue: xor ax,ax mov es,ax mov bx,OFFSET adr_int21 les ax,es:[bx] 10