Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

21 Experts available now in Live!

Get 1:1 Help Now