覆盖默认INT 9H [英] Override default INT 9h

查看:324
本文介绍了覆盖默认INT 9H的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图覆盖默认中断时,关键是pssed $ P $。
这里是我的code:我不明白为什么它不工作,它的工作原理与他人INT数字(43H为例)

  MOV人,9H
MOV啊,25H
MOV BX,赛格int9h
MOV DS,BX
MOV DX,偏移int9h
INT 21H

(凡int9h在我的code标签)
有谁知道如何连接中断时,关键是pressed?
谢谢 !

编辑:

  MOV AX,2509h
MOV DX,偏移int9h
INT 21Hint9h PROC
    ;做一些东西
    IRET
int9h ENDP


解决方案

我会尝试,并再次回答这个问题 - 在一个有点啰嗦的方式

在视窗成为prevalent,DOS统治了电脑。为了扩展其功能,人们习惯写TSR(终止并驻留)程序;这些方案将挂接各种中断功能(如时钟和键盘),终止再留驻留在内存中。其结果是,在给定的中断发生时,这些实用程序的常驻code将处理中断,可能调用原始中断处理程序。

这样的计划将有两个部分组成的结构:瞬态部分和驻地的一部分。瞬态部分将是code这将在程序从从命令行调用运行;这将检查是否驻留部分已经安装。如果住宅部分的中有的安装,该程序会简单地退出,但如果这是第一次调用,程序会先保存当前的中断处理程序的地址,然后再安装自己的code作为新的中断处理程序,然后作出一个特殊的DOS调用这将使处理器code在内存中。

其中已示出的code是其中新的中断处理程序安装到中断表瞬态方案的一部分。这code应该永远只运行一次,当然是的不可以新的中断处理程序本身。一部分

TSR程序变得过时的时候使用的Windows成为wides $ P $垫。从某种意义上说,每一个Windows下运行的程序是TSR程序,什么是键盘中断处理程序code现在在'安其preSS功能成为其处理的键盘事件(在德尔福为例)

以下code改变中断表

  MOV AX,2509h
MOV DX,偏移kb_handler
INT 21H

在code,其起点在地址* kb_handler *是实际的中断处理程序。

你在做重复设置中断处理程序的地址,而不是处理中断。你上面code应该只安装了程序本身时运行一次;中断处理程序code会被调用很多次。

我希望这使事情变得更清晰。

你所不写是的为什么要这么做

I'm trying to override the default interruption when a key is pressed. Here is my code : I don't understand why it doesn't work, it works with others INT numbers (43h for example)

mov al,9h
mov ah,25h
mov bx,seg int9h
mov ds,bx
mov dx,offset int9h
int 21h

(Where int9h is a label in my code) Does anyone know how to hook the interruption when a key is pressed ? Thanks !

EDIT:

mov     ax,2509h
mov     dx,offset int9h
int     21h            

int9h PROC
    ;do some stuff
    IRET 
int9h ENDP

解决方案

I'll try and answer this again - in a somewhat long-winded fashion.

Before Windows became prevalent, DOS ruled the computer. In order to extend its functionality, people used to write TSR (terminate and stay resident) programs; these programs would hook various interrupt functions (such as the clock and the keyboard), terminate and then stay resident in memory. As a result, when the given interrupt occurred, the resident code of these utilities would handle the interrupt, possibly calling the original interrupt handler.

Such programs would have a structure composed of two sections: the transient part and the resident part. The transient part would be the code which would run when the program was invoked from the command line; this would check whether the resident part had already been installed. If the resident part had been installed, the program would simply exit, but if this was the first invocation, the program would first save the address of the current interrupt handler, then install its own code as the new interrupt handler and then make a special DOS call which would leave the handler code in memory.

The code which you have shown is part of the transient program where the new interrupt handler is installed into the interrupt table. This code should only ever run once and is certainly not part of the new interrupt handler itself.

TSR programs became obsolete when the use of Windows became widespread. In a sense, every program run under Windows is a TSR program, and what was the keyboard interrupt handler code now becomes a keyboard event which is handled (in Delphi, for example) in an 'OnKeyPress' function.

The following code changes the interrupt table

mov ax, 2509h
mov dx, offset kb_handler
int 21h

The code which begins at the address *kb_handler* is the actual interrupt handler.

What you are doing is repeatedly setting the address of the interrupt handler as opposed to handling the interrupt. Your above code should be run only once when the program itself is installed; the interrupt handler code will be called many times.

I hope that this makes things clearer.

What you haven't written is why you are doing this.

这篇关于覆盖默认INT 9H的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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