Solved

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

Posted on 2004-08-17
6
1,139 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

16 Experts available now in Live!

Get 1:1 Help Now