in native/os/win32/system.c [83:158]
static DWORD WINAPI password_thread(void *data)
{
tcn_pass_cb_t *cb = (tcn_pass_cb_t *)data;
MSG msg;
HWINSTA hwss;
HWINSTA hwsu;
HDESK hwds;
HDESK hwdu;
HWND hwnd;
/* Ensure connection to service window station and desktop, and
* save their handles.
*/
GetDesktopWindow();
hwss = GetProcessWindowStation();
hwds = GetThreadDesktop(GetCurrentThreadId());
/* Impersonate the client and connect to the User's
* window station and desktop.
*/
hwsu = OpenWindowStation("WinSta0", FALSE, MAXIMUM_ALLOWED);
if (hwsu == NULL) {
ExitThread(1);
return 1;
}
SetProcessWindowStation(hwsu);
hwdu = OpenDesktop("Default", 0, FALSE, MAXIMUM_ALLOWED);
if (hwdu == NULL) {
SetProcessWindowStation(hwss);
CloseWindowStation(hwsu);
ExitThread(1);
return 1;
}
SetThreadDesktop(hwdu);
hwnd = CreateDialog(dll_instance, MAKEINTRESOURCE(1001), NULL, NULL);
if (hwnd != NULL)
ShowWindow(hwnd, SW_SHOW);
else {
ExitThread(1);
return 1;
}
while (1) {
if (PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE)) {
if (msg.message == WM_KEYUP) {
int nVirtKey = (int)msg.wParam;
if (nVirtKey == VK_ESCAPE) {
DestroyWindow(hwnd);
break;
}
else if (nVirtKey == VK_RETURN) {
HWND he = GetDlgItem(hwnd, 1002);
if (he) {
int n = GetWindowText(he, cb->password, SSL_MAX_PASSWORD_LEN - 1);
cb->password[n] = '\0';
}
DestroyWindow(hwnd);
break;
}
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
Sleep(100);
}
/* Restore window station and desktop.
*/
SetThreadDesktop(hwds);
SetProcessWindowStation(hwss);
CloseDesktop(hwdu);
CloseWindowStation(hwsu);
ExitThread(0);
return 0;
}