Thread: Trapping Ctrl Alt Delete

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    24

    Trapping Ctrl Alt Delete

    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.
    Keep smiling, it makes the big guys wonder what you're up to.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Ctrl Alt Del generates a hardware interrupt, which you can't trap AFAIK.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    24

    OK, confused a little...

    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.
    Last edited by emus21; 09-04-2003 at 08:48 PM.
    Keep smiling, it makes the big guys wonder what you're up to.

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    265
    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.

  5. #5
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    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
    Visit entropysink.com - It's what your PC is made for!

  6. #6
    Registered User
    Join Date
    Feb 2003
    Posts
    265
    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

  7. #7
    Registered User
    Join Date
    Jun 2002
    Posts
    24

    "True DOS"

    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
    Keep smiling, it makes the big guys wonder what you're up to.

  8. #8
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    Did you click the link in my post above?
    Visit entropysink.com - It's what your PC is made for!

  9. #9
    Registered User
    Join Date
    Jun 2002
    Posts
    24

    The link...

    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.
    Keep smiling, it makes the big guys wonder what you're up to.

  10. #10
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    Have you tried using in-line asm? With pure dos, you *should* be fine accessing the HW directly.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  11. #11
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    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?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  12. #12
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Assembly is the answer to your problem and all others as well. But youll be getting nitty and gritty with it.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  13. #13
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  14. #14
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

  15. #15
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> Perhaps you could visit flashdaddee.com and ask for a volunteer?

    Ask and ye shall recieve.

    By the way, nice work. I'll try the code out...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to capture CTRL, SHIFT and ALT ?
    By goldenrock in forum C Programming
    Replies: 3
    Last Post: 11-06-2003, 01:20 AM
  2. blocking ctrl + alt + delete
    By Bug in forum Windows Programming
    Replies: 20
    Last Post: 06-30-2003, 04:42 AM
  3. Ctrl + Alt +Delete
    By golfinguy4 in forum Windows Programming
    Replies: 4
    Last Post: 10-27-2002, 07:46 PM
  4. Problem need help
    By Srpurdy in forum C++ Programming
    Replies: 1
    Last Post: 07-24-2002, 12:45 PM
  5. memory management...
    By master5001 in forum Game Programming
    Replies: 24
    Last Post: 01-07-2002, 05:50 PM