16 位实模式下改变中断

发布于 2024-08-08 16:47:46 字数 330 浏览 9 评论 0原文

我正在尝试更改中断表以接管键盘中断。我的最终目标是编写新的中断例程,将自己复制到 RAM 中并使实模式中断表指向我。

我在网上找到了随机 示例代码 但缺少解释关于如何获取原始中断的地址。它们只是在其位置上放置了变量,以及如何将其自身放入内存中。

所以我的问题是如何找出实模式中断表或将其打印到屏幕上?

和/或如果有人有任何好的代码示例来执行此操作以禁用某些键或在某些键上发出蜂鸣声,我将非常感激。

谢谢!

I'm trying to alter my interrupt table to take over the keyboard interrupt. My end goal is to write my new interrupt routine, copy myself into RAM and make the real-mode interrupt table point to me.

I have found random sample code online but it is missing explanations on how to get the address of the original interrupt. They simply have variables in their place, and how to put itself into memory.

So my question is how do I figure out or print to my screen the real mode interrupt table?

And/OR if someone has any good code examples of doing this to either disable certain keys or beep on certain keys I'd really appreciate it.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谜泪 2024-08-15 16:47:46

在 16 位实模式下,中断表从地址 0 开始,有 256 个 4 字节条目。 256 个中断向量中的每一个都在该表中获得一个 4 字节地址(段 + 偏移量)。

http://en.wikipedia.org/wiki/Interrupt_descriptor_table 有更多详细信息。

In 16-bit real mode, the interrupt table starts at address 0, with 256 4 byte entries. Each of the 256 interrupt vectors gets a 4 byte address (segment + offset) in that table.

http://en.wikipedia.org/wiki/Interrupt_descriptor_table has some more detail.

Bonjour°[大白 2024-08-15 16:47:46

如果您的程序在 DOS 下运行,您可以(并且可能应该)使用 DOS 提供的 API:

  MOV  AH,35H    ; function 35H is Get Vector
  MOV  Al,9      ; slot in IDT for keyboard interrupt
  INT  21H       ; call DOS, contents of old vector in ES:BX (save them somewhere)
   .
   .
  MOV  AH,25H    ; function 25H is Set Vector
  MOV  AL,9
  PUSH CS        ; the new vector is passed in DS:DX, so copy CS to DS
  POP  DS        :  (assuming your new handler is in the same seg as other code)
  MOV  DX,NewHandler
  INT 21H

If your program is running under DOS, you can (and probably should) use the DOS-provided API:

  MOV  AH,35H    ; function 35H is Get Vector
  MOV  Al,9      ; slot in IDT for keyboard interrupt
  INT  21H       ; call DOS, contents of old vector in ES:BX (save them somewhere)
   .
   .
  MOV  AH,25H    ; function 25H is Set Vector
  MOV  AL,9
  PUSH CS        ; the new vector is passed in DS:DX, so copy CS to DS
  POP  DS        :  (assuming your new handler is in the same seg as other code)
  MOV  DX,NewHandler
  INT 21H
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文