Solved

Trapping CTRL-ALT-DEL in Win95

Posted on 1998-08-27
18
276 Views
Last Modified: 2013-12-03
I would like to know what method would reliably trap a CTRL-ALT-DEL request by the user before Windows 95 picks it up.  (And displays the "Close Program" dialog box) Would it be through a virtual key handler or revectoring the interrupt?  We don't want to suck up more than 0.5% system resources doing it either.  Obviously, code samples would be helpful.
0
Comment
Question by:wsaitoh
  • 4
  • 3
  • 3
  • +7
18 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1414019
There is no way to trap it, only to disable it. If you want me to post here code to disable it, leave a comment
0
 
LVL 14

Expert Comment

by:waty
ID: 1414020
As MikeP told, here is code to disable CTRL_ALT_DEL

' *** Disabling Ctrl-Alt-Delete and Ctrl-Esc
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

Sub DisableCtrlAltDelete(bDisabled As Boolean)
   ' *** Sub DisableCtrlAltDelete(bDisabled As Boolean)
   ' *** To disable Ctrl-Alt-Delete:
   ' *** Call DisableCtrlAltDelete(True)
   
   ' *** To enable Ctrl-Alt-Delete:
   ' *** Call DisableCtrlAltDelete(False)

   Dim X          As Long
   X = SystemParametersInfo(97, bDisabled, CStr(1), 0)

End Sub

0
 
LVL 5

Expert Comment

by:tuvi
ID: 1414021
If you want to trap, use a Keyboard hook.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414022
I'm pretty sure you can't trap it with a keyboard hook.  The hook isn't notified.  The first parameter to the SystemParametesInfo (97) is the constant SPI_SCREENSAVERRUNNING.  Microsoft recomends that you do not use this feature.  So you do so at your own risk.  
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1414023
Better to 'do it on you own risk' then not doing at all, if he relly needs it. becedes, it worked on 3.1, 95, 98, and I think on NT as well. What are the chances it is going to change?
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414024
The docs say it doesn't work on NT.  But that was probably for versions before 4.0.  I suspect it will not work some day, however.  Its good to know it works on 98.  That has been questioned.
0
 
LVL 2

Expert Comment

by:duneram
ID: 1414025
i recently figured out how to disable cAD on NT... It works like a charm....
0
 
LVL 22

Expert Comment

by:nietod
ID: 1414026
Not going to share it with the rest of the class?
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1414027
He is going to sell it for points :)
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 2

Expert Comment

by:duneram
ID: 1414028
Sorry, Not this time around.  
0
 
LVL 2

Expert Comment

by:duneram
ID: 1414029
mikep: perhaps :)  .  But I am sure when MS finds out how I did it they will patch their code... so even if I tell, it will probably be fixed fairly quickly.  thats been my experience in the past...
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1414030
I agree with MikeP that it still works under '98.  Too bad nothing else does (at least from my experience)!

wsaitoh - If you want to prevent your program from showing up in that little box, use this:

  #define REGISTER 0
  #define UNREGISTER 1

  typedef DWORD (WINAPI *fp_RegServProc) (DWORD, DWORD);
  fp_RegServProc pRegisterServiceProcess = NULL;

  pRegisterServiceProcess = (fp_RegServProc) GetProcAddress (GetModuleHandle ("KERNEL32.dll"), "RegisterServiceProcess");

  pRegisterServiceProcess (0, UNREGISTER);
0
 
LVL 2

Accepted Solution

by:
lucidity earned 100 total points
ID: 1414031
0
 

Author Comment

by:wsaitoh
ID: 1414032
I appologize for not clearly asking the question originally, but I will see how the above will work to trap CTRL-ALT-DEL.  What would it take to get a message to your app. that the above was trapped, let the app. bring up its own dialog on certain conditions and during all other times, let it pass through to the system as normal?  Thanks.
0
 
LVL 2

Expert Comment

by:cessi0g
ID: 1414033
c2cap95 example is a static VxD that loads before Windows starts and you can't unload. It install itself hooking keyboard at DEVICE_INIT message.
I think that you need to convert it to a Dynamic VxD and provide a DEVICE_IO_CONTROL interface to "talk" to a Win32 App.
In such a way, you can send messages from a Win32 App to the VxD to enable, disable or whatever you want to do in the VxD.
Let me know if you need more help on writing this kind of modules.

Regards,
Jorge
0
 
LVL 1

Expert Comment

by:mcsilver
ID: 5561559
wsaitoh:

Did you ever figure out how to do what you wanted?  If I understand you correctly, I want to do the same thing.  I want to add to the existing Ctrl-Alt-Del functionality.  Whether I do this by adding another button to the dialog or by showing my own dialog before showing the standard one, or by some other way, I don't much care.  However, if I can preserve the existing functionality without having to rewrite it, that would be best.

I looked at Ctrl2cap (mentioned above) but it seems only to give me the interception functionality.  I'm still clueless as to how to alter the existing dialog (as in the first option) or how to bring up the standard dialog after I intercept (as in the second option).

Thanks for any insight,
Craig
0
 
LVL 2

Expert Comment

by:duneram
ID: 5623181
Hi Jorge,

An alternate thing the person can do (this one only works on 9x) is thunk to 16 bits with a call to the EnableHardwareInput API.  MS says this function is obsolete, but I tell you it's not.

It's in the system dll's and u can get to it via a true thunk ( http://search.microsoft.com/us/dev/default.asp?qu=thunk&boolean=ALL&nq=NEW&so=RECCNT&p=1&chkM=on&radM=2&chkS=on&radS=2&chkA=on&radA=2&chkP=on&radP=2&chkK=on )
or just make a simple call to QT_THUNK.

QT_THUNK is exported by Kernel32.dll on 9x

QT_THUNK is undocumented, but before you say u don't want to use it, note that Microsoft uses it to perform their transforms internally from the flat world to the segment world (32 to 16 bit).

if anyone is interested in this undocumented function, they need to get their hands on Matt Pietrek's book: "windows 95 system programming secrets" You can see it here:  http://www.duneram.com/books/winbooks.html

Another good author with much information to share is Jeffrey Richter:
http://www.duneram.com/books/jeffreyrichter.html

Now if you thunk down to 16 bits and call EnableHardwareInput at different times during your program, you can effectively disable control+alt+delete because all keyboard/mouse input will be disabled across your whole system. (very anti win32).

Also note the above only works on win9x.

Good Luck.  But yeah Jorge, thats some out of the box thinking.  Thats one of the things people need to do to make windows work for them.

David


0
 
LVL 2

Expert Comment

by:cessi0g
ID: 5647288
David, you're right!
But, in my opinion, Win95 is an obsolete OS. Today I think the better way to do this kind of software, is to go into WDM.
WDM runs only on Win98 and NT.
On www.oneysoft.com there's a lot of info about writing WDM's.
I'm trying to forget to write VxD's and migrate to WDM.
If someone like to have a look at a WDM to intercept keys, visit the Walter Oney's page or let me know, to post some sample code.

One more thing about Craig's comment: Ctrl2Cap just intercept keyboard, right!
But this module uses a VxD function that you can use to intercept, to passtrough, to change (add or remove) keys or whatever you want.
You have full control over the keyboard.
In the past I posted a piece of code on http://www.experts-exchange.com/jsp/qShow.jsp?ta=winprog&qid=10045464 .

Regards,
Jorge
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now