Cannot get reference to Locked screen when the system is in RDP st



Read the senario first in order to understand the problem

I had compile service in order to logon to windows remotely. I am achieving
this by opening a reference to winst0 desktop and getting the reference of
the login windows and set the username and password.

There are 3 states in which the user name and password can be passed.

1. when the system is at logged out state i.e no user has logged on (my
service is working in this state)

2. when the system is at locked out state by pressing ctrl+alt+delete and
selecting lock option (my service is working in this state also)

3. when the target system is accessed via RDP, the target computer goes into
locked state, this is where is am facing problem.

I cannot get the reference to the locked window.

Can any one please let me know what is the problem and how do i get the
problem solved.

here is the code

HWINSTA hWinStaUser = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED);
if(SetProcessWindowStation(hWinStaUser))
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
// Switch into the Winlogon desktop
if (SelectDesktop("Winlogon"))
{
//myfile << "failed to select logon desktop\n";
//return FALSE;
//myfile << "generating ctrl-alt-del\n";
HWND hwndCtrlAltDel = FindWindow("SAS window class", "SAS window");
if (hwndCtrlAltDel == NULL) {
myfile << "\"SAS window\" not found\n";
hwndCtrlAltDel = HWND_BROADCAST;
}else{
SendMessage(hwndCtrlAltDel, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL,
VK_DELETE));
}
HWND w=NULL;

if( NULL != (w=FindWindow(NULL,"Welcome to Windows")) || NULL !=
(w=FindWindow(NULL,"Computer Locked")) || hwndCtrlAltDel!=NULL )
// SendMessage(w, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL,VK_DELETE));
Sleep(1000);
// username
// Alt-U for username edit
if(NULL != (w=FindWindow(NULL,"Log On to Windows")) || NULL !=
(w=FindWindow(NULL,"Unlock Computer")) ){
keybd_event( VK_MENU, 0, 0, NULL );
keybd_event( VkKeyScan('u'), 1, 0, NULL );
keybd_event( VkKeyScan('u'), 1, KEYEVENTF_KEYUP, NULL );
keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, NULL );
Sleep( 50 ); // maybe not needed

// Enter the Username
char username[] = "Administrator";
for( int c=0; c<strlen(username); c++ )
{
keybd_event( VkKeyScan(username[c]), 1, 0, NULL );
keybd_event( VkKeyScan(username[c]), 1, KEYEVENTF_KEYUP, NULL );
}
// Alt-P for password edit
keybd_event( VK_MENU, 0, 0, NULL );
keybd_event( VkKeyScan('p'), 1, 0, NULL );
keybd_event( VkKeyScan('p'), 1, KEYEVENTF_KEYUP, NULL );
keybd_event( VK_MENU, 0, KEYEVENTF_KEYUP, NULL );
Sleep( 50 ); // maybe not needed

// Enter the password
char password[] = "admin";
for( int c=0; c<strlen(password); c++ )
{
keybd_event( VkKeyScan(password[c]), 1, 0, NULL );
keybd_event( VkKeyScan(password[c]), 1, KEYEVENTF_KEYUP, NULL );
}
// Send the enter key and do the default (logon)

HWND hwndDomain;
int dwIndex;
if(NULL!= (hwndDomain = GetDlgItem(w, 1504)) || NULL!= (hwndDomain =
GetDlgItem(w, 1956))){
dwIndex = (DWORD) SendMessage(hwndDomain, CB_FINDSTRINGEXACT, 0, (LPARAM)
"DOMAIN1");
}
if (dwIndex != CB_ERR)
{
SendMessage(hwndDomain, CB_SETCURSEL, (WPARAM) dwIndex, 0);
}
keybd_event( VK_RETURN, 0, 0, NULL );
keybd_event( VK_RETURN, KEYEVENTF_KEYUP, 0, NULL );
}
// Switch back to our original desktop
if (old_desktop != NULL)
SelectHDESK(old_desktop);
}
if (hWinStaUser)
CloseWindowStation(hWinStaUser);
}
.



Relevant Pages

  • Re: logon problem
    ... I am trying to logon to my computer but as soon as turn it on i see the ... windows logo then a single glimpse of username,password dialog box and then ... user accounts of control panel and disable "use welcome screen" then when i ... correct username and password and doing so i can login into my system ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Authentication problem
    ... > I have as virtual folder on my machine which is set to accept only Windows ... > Also I have added my local host in Trusted sites. ... > logon with the current username and password, ...
    (microsoft.public.inetserver.iis.security)
  • Cannot get reference to Locked screen when the system is in RDP st
    ... I had compile service in order to logon to windows remotely. ... the login windows and set the username and password. ... if (dwIndex!= CB_ERR) ...
    (microsoft.public.platformsdk.security)
  • Re: Authentication problem
    ... > I have as virtual folder on my machine which is set to accept only Windows ... > Also I have added my local host in Trusted sites. ... > logon with the current username and password, ...
    (microsoft.public.inetserver.iis)
  • Re: How to force a logoff in a logon script?
    ... Windows has a registry key that governs which UI will be presented ... the unauthorized user cancels the logon dialog and goes away ... system, but complains that there was no cancel button, only an OK ...
    (microsoft.public.windows.server.scripting)