Results 1 to 23 of 23

Thread: Simulate CTLR + ALT + DEL

  1. #1

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50

    Simulate CTLR + ALT + DEL

    I am trying to simulate all sort of key presses, CTRL + ALT + DEL being one of them.

    I have tried GetKeyboardState and SetKeyboardState to no avail. I'z prolly doing something wrong.

    I am runing Win2K, if that makes a difference?

    Anywayz, thanks in advance.
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  2. #2
    Megatron
    Guest
    I read somewhere that as a safety feature, Ctrl+Alt+Del will only function when hardware interrupts are sent (e.g: when the physical keys are pressed).

  3. #3

  4. #4

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50
    Cheerz guys.

    I'll get there! I know it's possible, but just don't know how yet!!
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  5. #5
    Have you taken a peek at these?

  6. #6
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    AFAIK, in WinNT platforms the only way to simulate that key combination is to create your own "Graphical Identification and Authentication" module, or GINA for short.

    Don't ask me how as I have no idea, but I believe there are some examples of GINAs in the Platform SDK (although I bet they are in C++).

  7. #7
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I don't think it's pos, certainly not in win2k. There's an option for the user to have to press CTRL+ALT+DEL to log on, change pwd etc, and it says this is a security feature because Windows will only respond to actual keystrokes

    I tried
    VB Code:
    1. SendKeys "^%{DEL}"
    on win98 and 2k, neither of which produced any joy.

  8. #8
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    Originally posted by chrisjk
    I don't think it's pos, certainly not in win2k. There's an option for the user to have to press CTRL+ALT+DEL to log on, change pwd etc, and it says this is a security feature because Windows will only respond to actual keystrokes

    I tried
    VB Code:
    1. SendKeys "^%{DEL}"
    on win98 and 2k, neither of which produced any joy.
    Everything is possible, including this one. pcAnywhere does it so I believe us mortals can too (not very easy do).

  9. #9
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    okay, but why would MS go to the bother of implementing this CTRL+ALT+DEL "safety feature" if it could easily be simulated?

  10. #10
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    Originally posted by chrisjk
    okay, but why would MS go to the bother of implementing this CTRL+ALT+DEL "safety feature" if it could easily be simulated?
    Remove the "easily" from your sentence, and then I'd answer, Who the hell knows?

  11. #11
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    It's to guarantee that pressing Ctrl+Alt+Del before inputtung your password is done by the OS, not a Trojan horse program or something
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  12. #12

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50
    Yer filburt1 I looked, cheerz. Didn't get the answer tho

    You can disable CTRL+ALT+DELETE, right?
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  13. #13
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can disable CTRL+ALT+DELETE, right?
    only if you're using Win9x

  14. #14

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50

    Smile

    Thanks a lot guys, you'z all been really helpful.

    One other thing, can I disable and simulate all other keys and combinations tho? just not CTRL+ALT+DELETE
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  15. #15
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Use SendKeys

    % is ALT
    ^ is CTRL
    + is SHIFT

    VB Code:
    1. SendKeys "%{ENTER}"
    is ALT+ENTER
    VB Code:
    1. SendKeys "^%{F10}"
    is CTRL+ALT+F10

  16. #16
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    I wonder why people keep trying to stop users from switching to other programs

    Anyway, disabling system shorcuts is only *possible* on Win9x (forget it in Win2k/XP). What you need to do is to cheat Windows telling it that the screen saver is running, this way Windows automatically disables those keys. Correct me if I'm wrong, but I believe SystemParametersInfo is the API function you need.
    Live your own life, for you will die your own death.

  17. #17
    Hyperactive Member
    Join Date
    Jul 2000
    Posts
    352

    The way I understand it.....

    The way I understand it, PC Anywhere paid a pretty penny to Microsoft to get the code they needed. I don't believe that code has been, is being, or will ever be released to the general programming public. Anyone know any employees of Symantec ? I think that is your best chance. Good Luck. If you somehow find out how, just email me at [email protected].

  18. #18
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    This is a programming community isn't it? No Net Admins? That is why VNC hasn't been mentioned! I strongly reccomend VNC as a replacement to PCAnywhere. Also it allows a CTRL+ALT+DEL to be sent, only it is installed as a service though, that might be the key. VNC can be found at http://www.uk.research.att.com/vnc/ , the SOURCE in C++ is there, if you have the patience to look through it ( or maybe email the authors) you might be able to find out what you need.

    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  19. #19
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121

    helpful?

    Here is the relevant code I could find:

    Code:
    // Static routine used to fool Winlogon into thinking CtrlAltDel was pressed
    
    void *
    SimulateCtrlAltDelThreadFn(void *context)
    {
    	HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
    
    	// Switch into the Winlogon desktop
    	if (!vncService::SelectDesktop("Winlogon"))
    	{
    		log.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
    		return FALSE;
    	}
    
    	log.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
    
    	// Fake a hotkey event to any windows we find there.... :(
    	// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
    	PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
    
    	// Switch back to our original desktop
    	if (old_desktop != NULL)
    		vncService::SelectHDESK(old_desktop);
    
    	return NULL;
    }
    
    // Static routine to simulate Ctrl-Alt-Del locally
    
    BOOL
    vncService::SimulateCtrlAltDel()
    {
    	log.Print(LL_ALL, VNCLOG("preparing to generate ctrl-alt-del\n"));
    
    	// Are we running on NT?
    	if (IsWinNT())
    	{
    		log.Print(LL_ALL, VNCLOG("spawn ctrl-alt-del thread...\n"));
    
    		// *** This is an unpleasant hack.  Oh dear.
    
    		// I simulate CtrAltDel by posting a WM_HOTKEY message to all
    		// the windows on the Winlogon desktop.
    		// This requires that the current thread is part of the Winlogon desktop.
    		// But the current thread has hooks set & a window open, so it can't
    		// switch desktops, so I instead spawn a new thread & let that do the work...
    
    		omni_thread *thread = omni_thread::create(SimulateCtrlAltDelThreadFn);
    		if (thread == NULL)
    			return FALSE;
    		thread->join(NULL);
    
    		return TRUE;
    	}
    
    	return TRUE;
    }
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

  20. #20
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Here is how to disable ALT-TAB, ALT-ESC, CTRL-ESC in NT4 SP3 and higher and Win2000. (Cant get the CTRL+ALT+DEL to work though). I converted this code from C++ code that was in MSDN.

    Add a checkbox control to your form

    Module code
    VB Code:
    1. Option Explicit
    2. Public Type KBDLLHOOKSTRUCT
    3.     vkCode As Long
    4.     scanCode As Long
    5.     flags As Long
    6.     time As Long
    7.     dwExtraInfo As Long
    8. End Type
    9. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    10. Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
    11. Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
    12. Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
    13. Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
    14. Public Const HC_ACTION = 0
    15. Public Const WM_KEYDOWN = &H100
    16. Public Const WM_KEYUP = &H101
    17. Public Const WM_SYSKEYDOWN = &H104
    18. Public Const WM_SYSKEYUP = &H105
    19. Public Const VK_TAB = &H9
    20. Public Const VK_CONTROL = &H11
    21. Public Const VK_ESCAPE = &H1B
    22. Public Const VK_DELETE = &H2E
    23.  
    24. Public Const WH_KEYBOARD_LL = 13
    25. Public Const LLKHF_ALTDOWN = &H20
    26.  
    27.  
    28. Dim m_udtKEYBOARDHOOK As KBDLLHOOKSTRUCT
    29.  
    30. Public Function KeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    31.     Dim blnConsumeKey As Boolean
    32.    
    33.     If (nCode = HC_ACTION) Then
    34.         If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Or wParam = WM_KEYUP Or wParam = WM_SYSKEYUP Then
    35.             CopyMemory m_udtKEYBOARDHOOK, ByVal lParam, Len(m_udtKEYBOARDHOOK)
    36.             With m_udtKEYBOARDHOOK
    37.                 blnConsumeKey = _
    38.                 ((.vkCode = VK_TAB) And ((.flags And LLKHF_ALTDOWN) <> 0)) Or _
    39.                 ((.vkCode = VK_ESCAPE) And ((.flags And LLKHF_ALTDOWN) <> 0)) Or _
    40.                 ((.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0))
    41.             End With
    42.         End If
    43.     End If
    44.    
    45.     If blnConsumeKey Then
    46.         KeyboardProc = -1
    47.     Else
    48.         KeyboardProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
    49.     End If
    50. End Function
    Form code
    VB Code:
    1. Dim m_lngKeyboad As Long
    2.  
    3. Private Sub chkDisable_Click()
    4.     If chkDisable = vbChecked Then
    5.         m_lngKeyboad = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf KeyboardProc, App.hInstance, 0)
    6.     Else
    7.         UnhookWindowsHookEx m_lngKeyboad
    8.         m_lngKeyboad = 0
    9.     End If
    10. End Sub
    11.  
    12. Private Sub Form_Unload(Cancel As Integer)
    13.     If m_lngKeyboad <> 0 Then UnhookWindowsHookEx m_lngKeyboad
    14. End Sub
    Note Do not close the application while in IDE, but press X in the form's title bar. If you close it by pressing END button in IDE you wont be able to hook it again without restarting the IDE.

  21. #21
    Addicted Member
    Join Date
    May 2000
    Location
    Mexico City
    Posts
    242
    way to go! I don't understand how the code works, but I'll surely add it to my library.
    Live your own life, for you will die your own death.

  22. #22

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50

    Wink

    Thanks alot guys. You've all been really helpfull.

    Cheerz spec to Zevlag, I'll have a bash at figuring out that code (I know more Japanese than C ), and Serge
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  23. #23
    Lively Member
    Join Date
    Apr 2001
    Location
    Utah, USA
    Posts
    121
    Well, umm, ok, your welcome

    If you can't figure out what the code is doing I would recomend that you eMail the authors. I'm sure that they wouldn't mind answering your questions......


    Zevlag
    Josh -- Name
    Zevlag13 -- AIM

    www.WotsIt.org for all your file format spec questions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width