Cannot get reference to Locked screen when the system is in RDP st
- From: Abdul Khaliq <AbdulKhaliq@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 20 Feb 2008 07:47:02 -0800
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);
}
.
- Follow-Ups:
- Re: Cannot get reference to Locked screen when the system is in RDP st
- From: Ivan Brugiolo [MSFT]
- Re: Cannot get reference to Locked screen when the system is in RDP st
- Prev by Date: Enumerate Server 2008 roles
- Next by Date: Re: rename fails on handle obtained by IoCreateFileSpecifyDeviceObject
- Previous by thread: Enumerate Server 2008 roles
- Next by thread: Re: Cannot get reference to Locked screen when the system is in RDP st
- Index(es):
Relevant Pages
|