Solved

How to emulate a CTRL+ALT+DEL Sequence (secure attention sequence)

Posted on 2004-08-17
6
1,144 Views
Last Modified: 2013-12-03
I am writing a Windows NT service that needs to popup the standard “user logon” dialog box.

I know in advance that the workstation is locked. The basic idea is to emulate a “secure attention sequence”, i.e. CTRL+ALT+DEL. The user will be responsible for fill the login credentials. I would like to know, for example, if I can call a function on Winlogon.exe , or the standard Gina (msgina.dll) , for example.

The premises are:

1.      I can’t replace the GINA
2.      I need a code that works inside a service (I am using Microsoft Visual C++).

Regards,
0
Comment
Question by:POLITEC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 8

Expert Comment

by:adg080898
ID: 11827012
The whole idea of Ctrl+Alt+Del to bring up the login is to *prevent* programmatically opening the login dialog. Of course, anything is possible.
0
 
LVL 8

Expert Comment

by:adg080898
ID: 11827030
Have you tried keybd_event?

// Press the three keys down
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0);
keybd_event(VK_DELETE, MapVirtualKey(VK_DELETE, 0), 0, 0);

// Release the keys
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_DELETE, MapVirtualKey(VK_DELETE, 0), KEYEVENTF_KEYUP, 0);

I don't have any service source code handy to test it, but it should work. The docs for keybd_event say that the keyboard *driver* calls this to inject input, so it may work.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputFunctions/keybd_event.asp
0
 
LVL 86

Expert Comment

by:jkr
ID: 11827051
I feel bad to state the same again as in your very Q in the C++ area, but: The logon desktop is secured quite "heavily". You cannot use any of the above functions successfully without gaining access to that very desktop. and, that is not possible.
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 12046663
Actually, there is a solution that I posted at http:Q_21095286.html

// 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"))
     {
          vnclog.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
          return FALSE;
     }

     vnclog.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;
}

ant the related USENET posting at http://groups.google.com/groups?lr=&ie=UTF-8&selm=3F9D5000.303%40davebsoft.com
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…

749 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