tags:

views:

712

answers:

6

I want to disable CTRL+ALT+DEL in Windows XP in my ANSI-C code. Is it possible to do it?

+7  A: 

No.

The Windows Alt+Ctrl+Delete functionality is designed to be impossible to interfere with so that users can trust it to bring up genuine dialogs that they can trust with their password.

David Dorward
How come this got +7? This is completely wrong. Nothing is impossible to interfere with. -1 for misleading answer. Just say you don't want to help because there's no good reason to disable ctrl + alt + delete, but don't say it's impossible.
IVlad
It's intentionally unsupported, and please don't try to do it, especially to other users who might install your software
Paul Betts
This answer is misleading. It is possible to disable it at least in XP, I have posted an answer detailing how with reference.
Indeera
+1  A: 

Why do all the answers say it isn't possible? It is very much possible, for example here's how to enable it in case a virus has disabled it:

Click Start
Click Run
Enter gpedit.msc in the Open box and click OK
In the Group Policy settings window

Select User Configuration
Select Administrative Templates
Select System
Select Ctrl+Alt+Delete options
Select Enable Task Manager

How to make this disable it and how to do it from code I'll let you figure out (hint: you'll probably want to edit some registry keys) as this question is pretty fishy.

You can also install various keyboard hooks that alter the functionality of ctrl + alt + delete.

You can read about the registry API here.

If you want NOTHING to happen when you press ctrl alt delete, look into windows hooks and windows API hooking. Those are not easy to code; if you want API hooking then I suggest this library - you might be able to do this with classic windows hooks however. You'll need to write your own msgina.dll to rigurously hook this function. If you don't absolutely have to cut off any response to this command (and you probably don't), then you can most likely get away with simpler methods.

IVlad
Maybe semantics but that doesn't disable CTRL+ALT+DEL it just changes what happens when you press it!
Martin Smith
@Martin: yes, semantics. Unless you physically break the keyboard, then you truly can't disable it. Changing what happens when you press it is what the question is **most likely** about.
IVlad
No, this does *not* disable Ctrl-Alt-Del; it just changes what is displayed in the dialog which C-A-D pops up.
sleske
That controls the availability of Task Manager. Ctrl + Alt + Delete has nothing to do with the Task Manager in Vista and newer, it is just a command handled by winlogon.exe and displays a menu. The Task Manager is brought up using Ctrl + Shift + Esc.
iconiK
Again, it depends on your definition of disable. So, how do you define disable? Make it so the OS doesn't respond to the keypresses? You can use a device driver to hook keypresses, but arguably the device driver is part of the OS, so the OS still responds to the keypresses. EVERYTHING just changes what is displayed, except for hitting the keyboard with a hammer. I am guessing the OP is interested in disabling taskmanager; if not, he'll have to resort to advanced hooks anyway.
IVlad
That's why we need the OP to explain his end goal. Why he is trying to do it. e.g. If it is to disable certain options that come up in a domain environment there are supported ways of doing it.
Martin Smith
You can not trap SAS with keyboard hooks.
Indeera
+7  A: 

First of all, Trapping Ctrl-Alt-Del (Secure Attention Sequence) and disabling it is two different things. Despite misconceptions of many it is possible to disable SAS.

Here are 3 ways to do it:

  1. Set HKCU/Software/Microsoft/Windows/CurrentVersion/Policies/System/DisableTaskMgr = 1

  2. Replace msgina.dll with your own or write a keyboard driver.

  3. Go to the Start menu, select Run, and type "gpedit.msc" to run the Group Policy editor. Look in User Configuration | Administrative Templates | System and you'll find a section called Ctrl+Alt+Del Options - "Remove Task Manager"

In order to trap SAS, you could write a GINA stub, create a keyboard driver or replace TaskMgr.exe

These requirements arise mainly for embedded systems and you have control over how the WinXP image is made.

Reference: MSDN Mag Sept 2002

Indeera
Finally someone else who isn't saying this is impossible!
IVlad
Ya, it's definitely possible. +1 for quoting MSDN.
George Edison
You haven't disabled Control-Alt-Delete, you've only disabled the task manager. You can still do things like shutdown the system using that sequence.
Billy ONeal
Billy ONeal: You should read the post completly before commenting (I have listed 3 ways to do it, not just diabling task manager[which does disable SAS]), and also read the link provided for further information. Mind you this is for WinXP only.
Indeera
+2  A: 

Putting hooks into the keyboard system is not going to do the trick, despite what some here are saying.

The keyboard system works by issuing a particular hardware interrupt. The OS traps this interrupt and responds to it appropriately. This would be the thing affected by keyboard hooks.

The sequence CTRL-ALT-DEL issues a separate hardware interrupt from the other keys. This was done originally so that the reboot command would be available even when the other keyboard commands were frozen. (Although a terminate-stay-resident application in MS-DOS could still trap and handle the interrupt.)

The reason the key sequence is used now for log-in is because of this behavior. Since it issues a separate hardware interrupt, the sequence is used to verify that some other application hasn't put its hooks in. This is to prevent spoofing the login prompt.

I am not saying that it is impossible to trap this interrupt and modify its behavior. I don't know that it's not. But it will not be as simple as putting hooks into the keyboard handling code.

Jeffrey L Whitledge
It's definitely not easy but definitely possible. There is even some documentation out there about writing your own msgina.dll. Unless you really need to completely cut off any response to those keys though, you should consider simpler, less-rigurous methods though (@moon).
IVlad
+1  A: 

Winlogon just calls SetWindowsHookEx on the default desktop to trap CAD. Since only a thread that called SetWindowsHookEx can unregister the hook, it is made sure that no other process can steal it. In additon the keybboard hook only works on the process desktop. You can try to switch to a new desktop and hit CAD. Some internal info you'll find here.

ChristianWimmer
Winlogon does not provide the Control Alt Delete hook -- it works even outside of winlogon. The Secure Attention Sequence is provided directly by the Kernel.
Billy ONeal
You are wrong for XP. Read this article: http://www.remkoweijnen.nl/blog/2008/12/23/locking-a-workstation-part-2/And there is no outside of winlogon. If a user can control a session, then there is winlogon.
ChristianWimmer
A: 

This is in response to what the OP wants to do, not the question itself...

The easiest way accomplish your goal would be to write a keyboard filter driver, which discards all input. (This is really the only correct way of disabling all input I can think of, and is the method used by products such as LogMeIn)

Billy ONeal