如何从 C++ 修改键盘中断(在 Windows XP 下)程序?
我们得到了一个小项目(作为我的操作系统课程的一部分)来制作一个修改键盘输入的 Windows 程序,以便将输入的任何小写字符转换为大写字符(不使用大写锁定)!因此,当您在键盘上输入时,您会看到您输入的内容已转换为大写!
我已经使用 Turbo C 通过调用 geninterrupt() 并使用变量 _AH、_AL 轻松完成了此操作,我必须使用以下方法读取字符:
_AH = 0x07; // 读取一个字符,不带回显 生成中断(0x21); // Dos中断
然后要将其转换为大写字母,我必须使用以下方法屏蔽第 5 位:
_AL = _AL & 0xDF; // 用11011111屏蔽输入的字符
然后我将使用任何输出例程显示该字符。
现在,这个解决方案只能在旧的 C DOS 编译器下工作。但我们打算做的是通过使用 Windows XP 下的任何现代 C/C++ 编译器来对此进行接近或类似的解决方案!我首先想到的是修改键盘 ISR,以便它屏蔽任何输入字符的第五位,将其变成大写!但我不知道具体该怎么做。其次,我想创建一个 Win32 控制台程序来执行相同的解决方案(但要 无济于事)或制作一个与Windows兼容的解决方案,但我仍然不知道要使用哪些功能! 第三,我想制作一个直接修改ISR的Windows程序来满足我的需要!我仍在寻找如何做到这一点!
所以请,如果您能帮助我解决这个问题,我将不胜感激!
先感谢您 !
(我在 intel X86 上使用带有 mingw-GCC 编译器的 Windows XP。)
We have been given a little project (As part of my OS course) to make a Windows program that modifies keyboard input, so that it transforms any lowercase character entered into an uppercase one (without using caps-lock) ! so when you type on the keyboard you'll see what you're typing transformed into uppercase !
I have done this quite easily using Turbo C by calling geninterrupt() and using variables _AH, _AL, i had to read a character using:
_AH = 0x07; // Reading a character without echo
geninterrupt(0x21); // Dos interruptThen to transform it into an Upercase letter i have to mask the 5th bit by using:
_AL = _AL & 0xDF; // Masking the entered character with 11011111
and then i will display the character using any output routine.
Now, this solution will only work under old C DOS compilers. But what we intend to do is to make a close or similar solution to this by using any modern C/C++ compiler under Windows XP ! What i have first thought of is modifying the Keyboard ISR so that it masks the fifth bit of any entered character to turn it uppercase ! But i do not know how exactly to do this. Second, I wanted to create a Win32 console program to either do the same solution (but to no avail) or make a windows-compatible solution, still i do not know which functions to use !
Third I thought to make a windows program that modifies the ISR directly to suit my needs ! and i'm still looking for how to do this !
So please, If you could help me out on this, I would greatly appreciate it !
Thank you in advance !
(I'm using Windows XP on intel X86 with mingw-GCC compiler.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非编写 Ring 0 设备驱动程序,否则无法访问键盘 ISR。您最好研究一下 Windows Hook API。这些完成同样的事情。
从这里开始: http://msdn.microsoft .com/en-us/library/ms644990%28v=VS.85%29.aspx
You can't get access to the Keyboard ISR unless you write a Ring 0 device driver. You are better off investigating the Windows Hook APIs. These accomplish the same thing.
Start here: http://msdn.microsoft.com/en-us/library/ms644990%28v=VS.85%29.aspx
你计划多久毕业?希望您有时间,Windows 不再这样工作了。您需要使用 WDK 编写键盘过滤驱动程序。它在 src\input\kbfiltr 目录中提供了示例实现。你不能使用你熟悉的工具,WDK包括编译器和内核调试器。免费提供,转到此处开始使用。
How soon do you plan to graduate? Hopefully you'll have time, Windows doesn't work this way anymore. You'll need to write a keyboard filter driver using the WDK. It comes with a sample implementation in the src\input\kbfiltr directory. You can't use the tools you're familiar with, the WDK includes a compiler and a kernel debugger. Available at no cost, go here to get started.