;改變int9中斷例程改變它的中斷處理程序assume cs:codestack segment db 128 dup(0)stack endscode segment start: mov ax,stack mov ss,ax mov sp,128 call cpy_new_int9 ;復制自定義的int9程序 call save_int9 ;保存原有的int9程序的入口地址:cs:ip call set_new_int9 ;設置中斷向量表loopInput: mov ax,100h jmp loopInput call set_old_int9 ;原來的int9的中斷程序入口地址恢復 mov ax,4c00h int 21h;======================================================== ;恢復int9本來的中斷向量表set_old_int9: mov ax,0 mov es,ax cli mov Word ptr es:[9*4],[200h] mov word ptr es:[9*4+2],[202h] sti ret;======================================================== ;設置新的中斷向量表set_new_int9: push ax push es mov ax,0 mov es,ax cli ;屏蔽外中斷 mov word ptr es:[9*4],7E00h mov word ptr es:[9*4+2],0 sti pop es pop ax ret;======================================================== ;保存原來的int9中斷程序的地址,ip與cs到0000:0200處save_int9: push ax push es mov ax,0 mov es,ax cli push es:[9*4] pop es:[200h] push es:[9*4+2] pop es:[202h] sti pop es pop ax ret;======================================================== ;新的int9中斷處理程序new_int9: push ax in al,60h ;讀取60h號端口接受到的一個掃描碼 pushf call dword ptr cs:[200h] ;因為這段代碼是要復制到0000:0200h,所以cs = 0000,將原來的int9的中斷處理程序的地址保存到棧中 cmp al,3Bh ;按下的是否是F1鍵 jne new_int9Ret call change_colornew_int9Ret: pop ax iret ;pop ip,pop cs,popf ,執行完這句,cs:ip = 0000:0200h,程序其實就去執行int9的中斷處理程序去了 ;========================================================change_color: push ax push es push cx push bx mov ax,0B800h mov es,ax mov cx,2000 mov bx,1changeColor: inc byte ptr es:[bx] add bx,2 loop changeColor pop bx pop cx pop es pop ax retnew_int9End: nop ;======================================================== ;復制int9程序,將ds:si處的程序復制到es:di處,cpy_new_int9: mov ax,cs mov ds,ax mov si,offset new_int9 mov di,7E00h mov ax,0 mov es,ax mov cx, offset new_int9End - offset new_int9 ;復制的次數 cld ;cf = 0 ,每次操作后si、di遞增 rep movsb ret;======================================================== code endsend start
新聞熱點
疑難解答
圖片精選