如何禁用通过组装code中的键盘和鼠标 [英] How to disable the keyboard and mouse via assembly code

查看:119
本文介绍了如何禁用通过组装code中的键盘和鼠标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个程序集code挂键盘和鼠标(我现在尝试用键盘)。我搜索在海内外近(参考文献和文​​章以及老话题在这里也可以),几乎都显示通过获取INT 9的地址,并创建新的中断后使其被称作而不是原来的中断(9同一code )。这是我的code我写的:

  .MODEL微小
.STACK 100H
。数据
    old_ISR DD?
。code
主要PROC远
    MOV啊,35H;获得中断向量
    MOV人,09;对于int 9
    INT 21H
    MOV字PTR old_ISR,BX;原来INT9地址保存
    MOV字PTR old_ISR,ES;在ES:BX
    MOV啊,25H;设置中断向量
    MOV人,09H;对于int 9
    MOV DX,偏移ISR是指向我的ISR
    INT 21H    MOV AX,3100H;让我的程序驻留
    MOV DX,1;在存储器
    INT 21H
ISR PROC
    推斧
    NOP;没做什么
    流行斧
    IRET
ISR ENDP

在ISR我什么都不做,因为主要目标,我的目标就是让原来的INT9没有指向中断包含INT9而是指向我的ISR则扫描code会错过量表,这就是我想....不幸的是我,code根本不能很好地工作,我不知道为什么!
谢谢指教。

****************一些修改**********

  .MODEL微小
.STACK 100H
。数据
    old_ISR DD?
。code
主要PROC远
    MOV AX; @data;新的修改
    MOV DS,AX;新的修改    MOV啊,35H;获得中断向量
    MOV人,09;对于int 9
    INT 21H
    MOV字PTR old_ISR,BX;原来INT9地址保存
    MOV字PTR old_ISR,ES;在ES:BX
    MOV啊,25H;设置中断向量
    MOV人,09H;对于int 9
    MOV DX,偏移ISR是指向我的ISR
    INT 21H    MOV AX,3100H;让我的程序驻留
    MOV DX,1;在存储器
    INT 21H
主要ENDP;新的修改ISR PROC
    推斧
    NOP;没做什么
    流行斧
    IRET
ISR ENDP
结束 ;新的修改


解决方案

有关MSDOS / DOSBOX:

  CLI
MOV人,2;禁用IRQ 1
出21H,人
STI; -------------主回路
P1:在人,64H;获取状态
测试人,1
JZ短NOKEY
测试人,20H;从PS2鼠标字节?
JNZ短NOKEY
在人,60H
十二月人;如果退出ESC键pressed
JZ HOME
;占位符检查用密钥表多个键
NOKEY:JMP P1
; ------------------------
家:
CLI
异人,人;使IRQ 1
出21H,人
STI
MOV啊,1;清键盘缓冲区
INT 16H
;占位符终止程序

I have tried to write an assembly code to hang the keyboard and mouse (I try with keyboard now) . I searched in everywhere nearly (in references and articles and the old topic here also) and almost all show the same code by fetch the address of INT 9 and create new interrupt then make it be called rather than the original interrupt(9) . That is my code i had written:

.model tiny    
.stack 100h
.data
    old_ISR dd ?
.code
main proc far
    mov ah,35h                ; get interrupt vector
    mov al,09                 ; for int 9  
    INT 21h  
    mov word ptr old_ISR,BX   ; address of original int9 saved  
    mov word ptr old_ISR,ES   ; in ES:BX
    mov ah,25h                ; set interrupt vector
    mov al,09h                ; for int 9
    mov DX,offset ISR         ;is pointing to my ISR
    INT 21h 

    mov ax,3100h       ; to make my program resident 
    mov dx,1           ; in the memory
    int 21h


ISR proc  
    push ax
    nop      ; do nothing
    pop  ax
    iret
ISR endp    

In ISR I do nothing because the main goal I aim to is to make the original int9 don't point to interrupt vector table that contain int9 but point to my ISR then the scancode will missed and that's what I want.... unfortunately for me that code does not work well at all and I don't know why! thanks for advise.

**************** Some modification ********************

.model tiny    
.stack 100h
.data
    old_ISR dd ?
.code
main proc far
    mov ax;@data  ;new modification
    mov ds,ax     ;new modification

    mov ah,35h                ; get interrupt vector
    mov al,09                 ; for int 9  
    INT 21h  
    mov word ptr old_ISR,BX   ; address of original int9 saved  
    mov word ptr old_ISR,ES   ; in ES:BX
    mov ah,25h                ; set interrupt vector
    mov al,09h                ; for int 9
    mov DX,offset ISR         ;is pointing to my ISR
    INT 21h 

    mov ax,3100h       ; to make my program resident 
    mov dx,1           ; in the memory
    int 21h
main endp  ; new modification

ISR proc  
    push ax
    nop      ; do nothing
    pop  ax
    iret
ISR endp
end          ; new modification

解决方案

For MSDOS/DOSBOX:

cli
mov al,2     ; disable IRQ 1
out 21h,al
sti

;------------- Main loop
P1:

in   al, 64h  ; get status
test al, 1
jz short NOKEY
test al, 20h  ; byte from PS2 mouse?
jnz short NOKEY
in   al, 60h
dec  al       ; exit if escape key pressed
jz HOME
; placeholder for checking more keys using a table of keys
NOKEY:

jmp P1
;------------------------
HOME:
cli
xor al, al    ; enable IRQ 1
out 21h, al
sti
mov ah, 1     ; clear keyboard buffer
int 16h
; placeholder for terminate program

这篇关于如何禁用通过组装code中的键盘和鼠标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆