Tự viết chương trình vô hiệu hóa ổ đĩa mềm bằng C

3 586 7
Tự viết chương trình vô hiệu hóa ổ đĩa mềm bằng C

Đang tải... (xem toàn văn)

Thông tin tài liệu

Tự viết chương trình vô hiệu hóa ổ đĩa mềm bằng C

Tự viết chương trìnhhiệu hoá đĩa mềm bằng C :trang này đã được đọc lần - Chú ý:1.Đừng thay đổi đuôi của chương trình thành .cpp.2.Chương trình này chỉ chạy trong DOS.3.Chương trình này không bao giờ biên dịch trong TC Windows.Bạn phải dùng biên dịch TCC trong DOS .(c:\tc> tcc nofloppy.c).4.Tất cả các file .h;.obj phải để trong thư mục hiện hành.5.File tasm.exe, tlink.exe cũng phải để trong thư mục hiện hành.6.Tốt nhất là copy tất cả các file vào trong thư mục c:>tc.Sau đây là đoạn code:#pragma inline /* dodn't remove this line */#include "dos.h"#include "stdio.h"#include "conio.h"#define SUCCESS 0XC0FF#define FAILURE 0XC000union REGS i,o;void interrupt (*old)();struct INTERRUPT { unsigned bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,fl;};void interrupt disk (struct INTERRUPT);int tsrc;unsigned our_psp;void interrupt our_1c();void interrupt (*prev_1c)();void interrupt our_2f(struct INTERRUPT);void interrupt (*prev_2f)();main(int argc,char *argv[]) { int far *ebptr; strupr(argv[1]); tsrc=strcmp(argv[1],"UNLOAD"); if(tsrc!=0) { i.x.ax=0xc000; int86(0x2f,&i,&o); if(o.x.ax!=SUCCESS) { our_psp=getpsp(); res(); ebptr=MK_FP(our_psp,0x2c); freemem(*ebptr); printf("\Nofloppy v(1.0) Installed Successfully \n"); keep(0,2500); /* if u want to use automatic memory allocation use next line*/ /*keep(0,(_SS+(_SP/16)-_psp));*/ } printf("\nfor unloading nofloppy use -> nofloppy unload \n"); printf("\n Nofloppy v(1.0) already Loaded ."); } else { i.x.ax=0xc000; int86(0x2f,&i,&o); if(o.x.ax==SUCCESS) { i.x.ax=0xc001; int86(0x2f,&i,&o); if(o.x.ax==FAILURE) printf("\nCannot uninstall Nofloppy v(1.0),another program on top\n"); else printf("\nNofloppy ver(1.0) Uninstalled"); } else printf("\nNofloppy ver(1.0) NOT IN MEMORY"); } return 0; } res() { prev_1c=getvect(0x1c); setvect(0x1c,our_1c); prev_2f=getvect(0x2f); setvect(0x2f,our_2f); old=getvect(0x13); setvect(0x13,disk); return 0; } void interrupt disk(struct INTERRUPT r) { if (_DL==0 || _DL==1) { asm clc; asm pushf asm pop r.fl return; } _ES=r.es; _DX=r.dx; _CX=r.cx; _BX=r.bx; _AX=r.ax; (*old)(); asm pushf asm pop r.fl; r.ax=_AX; r.bx=_BX; r.cx=_CX; r.dx=_DX; r.es=_ES; } void interrupt our_1c() { (*prev_1c)(); } void interrupt our_2f(struct INTERRUPT r) { if(r.ax==0xc000) { r.ax=SUCCESS; return; } if(r.ax==0xc001) { r.ax=uninstall(); return; } asm pop bp asm pop di asm pop si asm pop ds asm pop es asm pop dx asm pop cx asm pop bx asm pop ax asm jmp cs:_prev_2f; } int uninstall() { if(our_1c==getvect(0x1c) && our_2f==getvect(0x2f)&&disk==getvect(0x13)) { setvect(0x1c,prev_1c); setvect(0x2f,prev_2f); setvect(0x13,old); freemem(our_psp); return(SUCCESS); } else return(FAILURE); } . Tự viết chương trình vô hiệu hoá ổ đĩa mềm bằng C :trang này đã đư c đ c lần - Chú ý:1.Đừng thay đổi đuôi c a chương trình thành .cpp.2 .Chương trình. này chỉ chạy trong DOS.3 .Chương trình này không bao giờ biên dịch trong TC Windows.Bạn phải dùng biên dịch TCC trong DOS . (c: c> tcc nofloppy .c) .4.Tất

Ngày đăng: 02/11/2012, 14:19

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan