PDA

View Full Version : Trapping Ctrl Alt Delete



emus21
09-04-2003, 07:47 PM
I need to know of a way to trap Ctrl Alt Del in DOS, without restarting the computer,

I am currently using a simple getch() function to access 2 byte keyboard codes but when I hit SHIFT, CONTROL, or ALT it doesn't do anything.

XSquared
09-04-2003, 08:02 PM
Ctrl Alt Del generates a hardware interrupt, which you can't trap AFAIK.

emus21
09-04-2003, 08:30 PM
If it is a hardware interupt that can't be trapped then how does

DOS trap it ro restart the computer

or

Windows trap it for the task manager and/or restart

or

Windows NT for its login..

This confuses me, if it can't be trapped, how can these examples occur..

perhaps I am not using the correct term.. let explain an example of what I want to do...

Pressing Ctrl + Alt + Delete accesses a menu in my dos program.

DeepBlackMagic
09-04-2003, 08:32 PM
Clearly the OS can trap the signal. Im trying to think at what level the system would recieve it. Clearly you would have to below the winblows API to get to it though, as windows isnt about to notify processes like yours that the event has happened. You might be looking at a kernel mode device driver before the night is through. I do know these are prety much the end-all in power. If they cant do it, few things can. I do know that processes in FreeBSD (my native OS) can in fact trap ctrl alt del. It would be a terrible security breach if somebody could simply walk up to a server and ctrl-alt-delete it at the login prompt. Although if they have LPA (local physical access) to it anyways, its fairly hard to keep them out.

RobR
09-05-2003, 09:02 AM
Originally posted by DeepBlackMagic
Clearly you would have to below the winblows API to get to it though, as windows isnt about to notify processes like yours that the event has happened.

The question was specifically about DOS - and this is a DOS board!

Google is your friend (http://www.snippets.org/snippets/dos/snip_lister.php3?fname=KBTRAP.C)

DeepBlackMagic
09-05-2003, 01:51 PM
I havent seen a single pooter running true dos for at least 3 years. If they are auctually running dos, im sorry, then im wrong, however if they are simply posting here because its a console application, running in 2k,xp, and whatnot, then im correct =P

emus21
09-05-2003, 08:25 PM
No problems there, I am programming a DOS Application using Borland C++ 4.52, 16 DOS,,

I dislike the newer version of the MS Windows OSes, they are
so "User Friendly" it keeps a person used to being STUPID..

That's just my opinion, so many people I talk to hate the new Windows OSes because of their annoying "User Friendly" interface..

I personally use Win95 of Win98, nothing newer..

MS DOS 6.22 is fun to program in/for.. I do it for recreation, also I am learning things I need to know to make my GUI for DOS,

I can get info from mouse, run custom graphics routines with an assemly library I downloaded that has helped emensely. I intend also to learn how to use assembly within my C source code to optimize my App's performance in key functions...

Now back to my question, Trapping Ctrl Alt Del, HOW? and if it isn't possible with C C++, what language should I learn, aside from Assembly, which at this point is way out of my league.

Any info related to my question is greatly appreciated. Thanks

emus21

RobR
09-06-2003, 01:14 PM
Did you click the link in my post above?

emus21
09-08-2003, 01:50 AM
Sorry, my bad, I should have looked more closely, I'll have to check that out, thank you for the info.. And sorry for my inefficient browsing skills.. no sarcasm, it's the truth.

ronin
09-09-2003, 01:28 PM
Have you tried using in-line asm? With pure dos, you *should* be fine accessing the HW directly.

Sebastiani
09-12-2003, 12:17 AM
Dunno for DOS, but for windows 9X, all keybord input is processed thru Cmd.exe before making it's way back to your app, but you may be able to capture WM_SYSKEYUP and WM_SYSKEYDOWN messages from these OS's. As far as DOS goes, it's probably going to have to be assembly. Perhaps you could visit flashdaddee.com and ask for a volunteer? :D

Jeremy G
09-12-2003, 12:32 AM
Assembly is the answer to your problem and all others as well. But youll be getting nitty and gritty with it.

VirtualAce
09-16-2003, 09:17 AM
To trap CTRL ALT DELETE you should write your own interrupt handler for interrupt 09h.

I will attach my handler code and header file for you. All you need to know is what key code the CTRL ALT DELETE combo will generate and you can trap it.

If you do not require an automatic install/uninstall of the handler or do not like my mechanism, simply do not define _HANDLER_NEEDED_. If you do this, you must register an exit() function using atexit(). Failure to do this will cause the system to become unstable because the INT 09h vector will not be restored.

If you have problems using and/or reading this code please contact me via the board and I'll be more than happy to assist you. This code has been tested under Win9x but not under WinXP or Win2000. It is coded for real mode, but is taken from code samples for DJGPP keyboard handlers so it can be used in protected mode with a few modifications.

This code is not an original concept of mine nor do I take credit for it. However, I did code it from scratch so it is my work, just not my idea.

VirtualAce
09-16-2003, 09:19 AM
The keyboard handler is designed to be used in a C++ environment, but it can be used in a C environment as well. Check your documentation on the getvect(), setvect(), and interrupt functions/keywords for more info.

Sebastiani
09-17-2003, 12:10 PM
>> Perhaps you could visit flashdaddee.com and ask for a volunteer?

Ask and ye shall recieve. :D

By the way, nice work. I'll try the code out...