ÕâÆª½Ì³ÌC++ FindWindowº¯Êý´úÂëʾÀýдµÃºÜʵÓã¬Ï£ÍûÄܰﵽÄú¡£
±¾ÎÄÕûÀí»ã×ÜÁËC++ÖÐFindWindowº¯ÊýµÄµäÐÍÓ÷¨´úÂëʾÀý¡£Èç¹ûÄúÕý¿àÓÚÒÔÏÂÎÊÌ⣺C++ FindWindowº¯ÊýµÄ¾ßÌåÓ÷¨£¿C++ FindWindowÔõôÓã¿C++ FindWindowʹÓõÄÀý×Ó£¿ÄÇô¹§Ï²Äú, ÕâÀᆱѡµÄº¯Êý´úÂëʾÀý»òÐí¿ÉÒÔΪÄúÌṩ°ïÖú¡£ ÔÚÏÂÎÄÖÐÒ»¹²Õ¹Ê¾ÁËFindWindowº¯ÊýµÄ28¸ö´úÂëʾÀý£¬ÕâЩÀý×ÓĬÈϸù¾ÝÊÜ»¶Ó³Ì¶ÈÅÅÐò¡£Äú¿ÉÒÔΪϲ»¶»òÕ߸оõÓÐÓõĴúÂëµãÔÞ£¬ÄúµÄÆÀ¼Û½«ÓÐÖúÓÚÎÒÃǵÄÏµÍ³ÍÆ¼ö³ö¸ü°ôµÄC++´úÂëʾÀý¡£ ʾÀý1: CaptureThreadDWORD WINAPI CaptureThread(HANDLE hDllMainThread){ bool bSuccess = false; //wait for dll initialization to finish before executing any initialization code if(hDllMainThread) { WaitForSingleObject(hDllMainThread, INFINITE); CloseHandle(hDllMainThread); } TCHAR lpLogPath[MAX_PATH]; SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, lpLogPath); wcscat_s(lpLogPath, MAX_PATH, TEXT("//OBS//pluginData//captureHookLog.txt")); dummyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if(!logOutput.is_open()) logOutput.open(lpLogPath, ios_base::in | ios_base::out | ios_base::trunc, _SH_DENYNO); wstringstream str; str << OBS_KEEPALIVE_EVENT << UINT(GetCurrentProcessId()); strKeepAlive = str.str(); logOutput << CurrentDateTimeString() << "we're booting up: " << endl; InitializeCriticalSection(&d3d9EndMutex); InitializeCriticalSection(&glMutex); DWORD procID = GetCurrentProcessId(); wstringstream strRestartEvent, strEndEvent, strReadyEvent, strExitEvent, strInfoMemory; strRestartEvent << RESTART_CAPTURE_EVENT << procID; strEndEvent << END_CAPTURE_EVENT << procID; strReadyEvent << CAPTURE_READY_EVENT << procID; strExitEvent << APP_EXIT_EVENT << procID; strInfoMemory << INFO_MEMORY << procID; hSignalRestart = GetEvent(strRestartEvent.str().c_str()); hSignalEnd = GetEvent(strEndEvent.str().c_str()); hSignalReady = GetEvent(strReadyEvent.str().c_str()); hSignalExit = GetEvent(strExitEvent.str().c_str()); DWORD bla; HANDLE hWindowThread = CreateThread(NULL, 0, DummyWindowThread, NULL, 0, &bla); if (!hWindowThread) { logOutput << CurrentTimeString() << "CaptureThread: could not create window thread for some reason" << endl; return 0; } CloseHandle(hWindowThread); hInfoFileMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(CaptureInfo), strInfoMemory.str().c_str()); if(!hInfoFileMap) { logOutput << CurrentTimeString() << "CaptureThread: could not info file mapping" << endl; return 0; } infoMem = (CaptureInfo*)MapViewOfFile(hInfoFileMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(CaptureInfo)); if(!infoMem) { logOutput << CurrentTimeString() << "CaptureThread: could not map view of info shared memory" << endl; CloseHandle(hInfoFileMap); hInfoFileMap = NULL; return 0; } hwndOBS = FindWindow(OBS_WINDOW_CLASS, NULL); if(!hwndOBS) { logOutput << CurrentTimeString() << "CaptureThread: could not find main application window? wtf? seriously?" << endl; return 0; } textureMutexes[0] = OpenMutex(MUTEX_ALL_ACCESS, FALSE, TEXTURE_MUTEX1); if (textureMutexes[0]) { textureMutexes[1] = OpenMutex(MUTEX_ALL_ACCESS, FALSE, TEXTURE_MUTEX2); if (textureMutexes[1]) { while(!AttemptToHookSomething()) Sleep(50); logOutput << CurrentTimeString() << "(half life scientist) everything.. seems to be in order" << endl; while (1) { AttemptToHookSomething(); Sleep(4000); } CloseHandle(textureMutexes[1]); textureMutexes[1] = NULL; } else { logOutput << CurrentTimeString() << "could not open texture mutex 2" << endl; } CloseHandle(textureMutexes[0]); textureMutexes[0] = NULL; } else { logOutput << CurrentTimeString() << "could not open texture mutex 1" << endl; }//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:Andypro1£¬ÏîÄ¿Ãû³Æ:OBS£¬´úÂëÐÐÊý:101£¬
ʾÀý2: ErrorMsgvoid ErrorMsg(char *message){ MessageBox(FindWindow("ConsoleWindowClass",NULL),(LPCTSTR)message,(LPCTSTR)"Error",MB_OK|MB_ICONWARNING); WSACleanup(); exit(0);}
¿ª·¢ÕßID:tmdgus0118£¬ÏîÄ¿Ãû³Æ:CNOM£¬´úÂëÐÐÊý:6£¬
ʾÀý3: FindWindowHWNDFormDeploy::getTabHwnd(){ return FindWindow(WC_TABCONTROL, L"tab1");}
¿ª·¢ÕßID:counterm£¬ÏîÄ¿Ãû³Æ:MyFirstMeetingInitializer£¬´úÂëÐÐÊý:5£¬
ʾÀý4: wxLogMessagevoid DataViewerAddColDlg::CreateControls(){ wxLogMessage("DataViewerAddColDlg::CreateControls()"); SetBackgroundColour(*wxWHITE); if (time_variant && fixed_lengths) { wxXmlResource::Get()->LoadDialog(this, GetParent(), "ID_DATA_VIEWER_ADD_COL_TIME_FIXED_DLG"); } else if (time_variant && !fixed_lengths) { wxXmlResource::Get()->LoadDialog(this, GetParent(), "ID_DATA_VIEWER_ADD_COL_TIME_DLG"); } else if (!time_variant && fixed_lengths) { wxXmlResource::Get()->LoadDialog(this, GetParent(), "ID_DATA_VIEWER_ADD_COL_FIXED_DLG"); } else { // !time_variant && !fixed_lengths wxXmlResource::Get()->LoadDialog(this, GetParent(), "ID_DATA_VIEWER_ADD_COL_DLG"); } m_apply_button = wxDynamicCast(FindWindow(XRCID("wxID_OK")), wxButton); m_name = wxDynamicCast(FindWindow(XRCID("ID_TEXT_NEW_NAME")), wxTextCtrl); m_name->SetValue(default_name); wxString name_chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789"; wxTextValidator name_validator(wxFILTER_INCLUDE_CHAR_LIST); name_validator.SetCharIncludes(name_chars); m_name->SetValidator(name_validator); m_name_valid = false; m_type = wxDynamicCast(FindWindow(XRCID("ID_CHOICE_TYPE")), wxChoice); // add options for Float, Integer, String, or Date m_type->Append("real (eg 1.03, 45.7)"); m_type->Append("integer (eg -1, 0, 23)"); m_type->Append("string (eg New York)"); //m_type->Append("date (eg 20110131)"); wxStaticText* mt = wxDynamicCast(FindWindow(XRCID("ID_STATIC_INSERT_POS")), wxStaticText); m_insert_pos = wxDynamicCast(FindWindow(XRCID("ID_CHOICE_INSERT_POS")), wxChoice); //if ( !project->IsFileDataSource()) { // mt->Disable(); // m_insert_pos->Disable(); //} m_displayed_decimals_lable = wxDynamicCast(FindWindow(XRCID("ID_STATIC_DISPLAYED_DECIMALS")), wxStaticText); m_displayed_decimals = wxDynamicCast(FindWindow(XRCID("ID_DISPLAYED_DECIMALS")), wxChoice); m_displayed_decimals->Append("default"); m_displayed_decimals->Append("1"); m_displayed_decimals->Append("2"); m_displayed_decimals->Append("3"); m_displayed_decimals->Append("4"); m_displayed_decimals->Append("5"); m_displayed_decimals->Append("6"); m_displayed_decimals->Append("7"); m_displayed_decimals->Append("8"); m_displayed_decimals->Append("9"); m_displayed_decimals->Append("10"); if (fixed_lengths) { m_length_lable = wxDynamicCast(FindWindow(XRCID("ID_STATIC_LENGTH")), wxStaticText); m_length = wxDynamicCast(FindWindow(XRCID("ID_TEXT_LENGTH")), wxTextCtrl); m_length->SetValidator(wxTextValidator(wxFILTER_DIGITS)); m_length_valid = true; m_decimals_lable = wxDynamicCast(FindWindow(XRCID("ID_STATIC_DECIMALS")), wxStaticText); m_decimals = wxDynamicCast(FindWindow(XRCID("ID_TEXT_DECIMALS")), wxTextCtrl); m_decimals->SetValidator(wxTextValidator(wxFILTER_DIGITS)); m_decimals_valid = true; m_max_label = wxDynamicCast(FindWindow(XRCID("ID_STATIC_MAX_LABEL")), wxStaticText); m_max_val = wxDynamicCast(FindWindow(XRCID("ID_STATIC_MAX_VAL")), wxStaticText); m_min_label = wxDynamicCast(FindWindow(XRCID("ID_STATIC_MIN_LABEL")), wxStaticText); m_min_val = wxDynamicCast(FindWindow(XRCID("ID_STATIC_MIN_VAL")), wxStaticText); } if (default_field_type == GdaConst::double_type) { m_type->SetSelection(0); } else if (default_field_type == GdaConst::long64_type) { m_type->SetSelection(1); } else if (default_field_type == GdaConst::string_type) { m_type->SetSelection(2); } else if (default_field_type == GdaConst::date_type) { m_type->SetSelection(3); } else { m_type->SetSelection(0); } Connect(XRCID("ID_TEXT_NEW_NAME"), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(DataViewerAddColDlg::OnOkClick)); Connect(XRCID("ID_TEXT_LENGTH"), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(DataViewerAddColDlg::OnOkClick)); Connect(XRCID("ID_TEXT_DECIMALS"), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(DataViewerAddColDlg::OnOkClick)); CheckName(); SetDefaultsByType(default_field_type);}
¿ª·¢ÕßID:lixun910£¬ÏîÄ¿Ãû³Æ:geoda£¬´úÂëÐÐÊý:93£¬
ʾÀý5: WinMainint CALLBACK WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmd, int show){// AllocConsole();// AttachConsole(GetCurrentProcessId());#pragma warning(push)#pragma warning( disable : 4996 )// freopen("CON", "w", stdout);#pragma warning(pop) HANDLE mutex = CreateMutex(NULL, TRUE, g_mutex_name); if(!mutex) return 0; if(GetLastError() == ERROR_ALREADY_EXISTS) { HWND hwnd = FindWindow(g_class_name, g_title); if(hwnd) { ShowWindow(hwnd, SW_SHOW); SetForegroundWindow(hwnd); } ReleaseMutex(mutex); CloseHandle(mutex); return 0; } WMU_SNAPIT_UNINSTALL = RegisterWindowMessage(g_message_name); g_icon = (HICON)LoadImage(NULL, g_icon_name, IMAGE_ICON, 0, 0, LR_LOADFROMFILE); WNDCLASSEX wc; ZeroMemory(&wc, sizeof(wc)); wc.cbSize = sizeof(wc); wc.style = CS_VREDRAW | CS_HREDRAW; wc.lpfnWndProc = fproc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hIcon = g_icon; wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = g_class_name; wc.hInstance = hinst; wc.hIconSm = g_icon; RegisterClassEx(&wc); HWND hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, g_class_name, g_title, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, 0, 0, hinst, 0 ); ReleaseMutex(mutex); if(hwnd == 0) { CloseHandle(mutex); return 0; } memset(&g_idata, 0, sizeof(g_idata)); g_idata.cbSize = sizeof(g_idata); g_idata.hWnd = hwnd; g_idata.uFlags = NIF_MESSAGE | NIF_ICON; g_idata.uCallbackMessage = WMU_TRAYICON; g_idata.hIcon = g_icon; g_menu = CreatePopupMenu(); AppendMenu(g_menu, MF_STRING | MF_GRAYED, ID_MENU_INSTALL, "Install"); AppendMenu(g_menu, MF_STRING | MF_GRAYED, ID_MENU_UNINSTALL, "Uninstall"); AppendMenu(g_menu, MF_STRING, ID_MENU_HIDE, "Hide"); AppendMenu(g_menu, MF_STRING, ID_MENU_EXIT, "Exit"); Shell_NotifyIcon(NIM_ADD, &g_idata); hook_install_(); MSG msg; while(GetMessage(&msg, 0, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } hook_uninstall_(); Shell_NotifyIcon(NIM_DELETE, &g_idata); CloseHandle(mutex); return 0;}
¿ª·¢ÕßID:akozlins£¬ÏîÄ¿Ãû³Æ:snapit£¬´úÂëÐÐÊý:91£¬
ʾÀý6: wxBoxSizer//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ......... itemStaticBoxSizer14->Add(itemBoxSizer16, 0, wxGROW|wxALL, 5); m_passwordCtrl = new wxTextCtrl( itemDialog1, ID_PASSWORD_TXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer16->Add(m_passwordCtrl, 5, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxBitmapButton* itemBitmapButton18 = new wxBitmapButton( itemDialog1, ID_BITMAPBUTTON, itemDialog1->GetBitmapResource(wxT("graphics/toolbar/new/copypassword.xpm")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); wxBitmap itemBitmapButton18BitmapDisabled(itemDialog1->GetBitmapResource(wxT("graphics/toolbar/new/copypassword_disabled.xpm"))); itemBitmapButton18->SetBitmapDisabled(itemBitmapButton18BitmapDisabled); if (CManagePasswordPolicies::ShowToolTips()) itemBitmapButton18->SetToolTip(_("Copy Password to clipboard")); itemBoxSizer16->Add(itemBitmapButton18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_lowerTableDesc = new wxStaticText( itemDialog1, wxID_STATIC, _("Selected policy details:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add(m_lowerTableDesc, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer20, 0, wxGROW|wxALL, 5); m_PolicyDetails = new wxGrid( itemDialog1, ID_POLICYPROPERTIES, wxDefaultPosition, wxSize(-1, 150), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); m_PolicyDetails->SetDefaultColSize(210); m_PolicyDetails->SetDefaultRowSize(25); m_PolicyDetails->SetColLabelSize(25); m_PolicyDetails->SetRowLabelSize(50); m_PolicyDetails->CreateGrid(5, 2, wxGrid::wxGridSelectRows); itemBoxSizer20->Add(m_PolicyDetails, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_PolicyEntries = new wxGrid( itemDialog1, ID_POLICYENTRIES, wxDefaultPosition, wxSize(-1, 150), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); m_PolicyEntries->SetDefaultColSize(140); m_PolicyEntries->SetDefaultRowSize(25); m_PolicyEntries->SetColLabelSize(25); m_PolicyEntries->SetRowLabelSize(50); m_PolicyEntries->CreateGrid(5, 3, wxGrid::wxGridSelectRows); itemBoxSizer20->Add(m_PolicyEntries, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxStdDialogButtonSizer* itemStdDialogButtonSizer23 = new wxStdDialogButtonSizer; itemBoxSizer2->Add(itemStdDialogButtonSizer23, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxButton* itemButton24 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer23->AddButton(itemButton24); wxButton* itemButton25 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer23->AddButton(itemButton25); wxButton* itemButton26 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 ); itemStdDialogButtonSizer23->AddButton(itemButton26); itemStdDialogButtonSizer23->Realize();////@end CManagePasswordPolicies content construction if (m_core.IsReadOnly()) { FindWindow(wxID_NEW)->Enable(false); FindWindow(wxID_DELETE)->Enable(false); // Hide cancel button & change OK button text FindWindow(wxID_CANCEL)->Enable(false); FindWindow(wxID_CANCEL)->Show(false); FindWindow(wxID_OK)->SetLabel(_("Close")); FindWindow(ID_EDIT_PP)->SetLabel(_("View")); } // We have 2 grids, but we show only one at a time, // toggle when user clicks on ID_LIST button. // Setting these up: m_PolicyNames->SetRowLabelSize(0); int col0Width = m_PolicyNames->GetColSize(0); col0Width += 45; m_PolicyNames->SetColSize(0, col0Width); m_PolicyNames->SetColLabelValue(0, _("Policy Name")); m_PolicyNames->SetColLabelValue(1, _("Use count")); UpdateNames(); m_PolicyNames->SelectRow(0); // Since we select the default policy, disable List & Delete FindWindow(ID_LIST)->Enable(false); FindWindow(wxID_DELETE)->Enable(false); m_PolicyDetails->SetRowLabelSize(0); m_PolicyDetails->SetColLabelValue(0, _("Policy Field")); m_PolicyDetails->SetColLabelValue(1, _("Value")); UpdateDetails(); m_PolicyEntries->SetRowLabelSize(0); m_PolicyEntries->SetColLabelValue(0, _("Group")); m_PolicyEntries->SetColLabelValue(1, _("Title")); m_PolicyEntries->SetColLabelValue(2, _("User Name")); ShowPolicyDetails(); // Max. of 255 policy names allowed - only 2 hex digits used for number if (m_MapPSWDPLC.size() >= 255) FindWindow(wxID_NEW)->Enable(false); // No changes yet FindWindow(wxID_UNDO)->Enable(false); FindWindow(wxID_REDO)->Enable(false); m_PolicyNames->SetFocus();}
¿ª·¢ÕßID:pwsafe£¬ÏîÄ¿Ãû³Æ:pwsafe£¬´úÂëÐÐÊý:101£¬
ʾÀý7: RestoreSettingsBOOL RestoreSettings(HWND hWnd){ // Check whether locate32 is running HWND hLocateSTWindow=FindWindow("LOCATEAPPST",NULL); if (hLocateSTWindow!=NULL) { char szText[100]; LoadString(hInst,IDS_LOCATE32RUNNING,szText,100); if (MessageBox(hWnd,szText,NULL,MB_OKCANCEL|MB_ICONINFORMATION)) return FALSE; } char szPath[MAX_PATH]=""; char szTitle[100],szFilter[200]; OSVERSIONINFO ve; ve.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); if (GetVersionEx(&ve)) { if (ve.dwPlatformId==VER_PLATFORM_WIN32_NT) LoadString(hInst,IDS_RESTOREFILTER,szFilter,200); else LoadString(hInst,IDS_RESTOREFILTER9x,szFilter,200); } else LoadString(hInst,IDS_RESTOREFILTER,szFilter,200); LoadString(hInst,IDS_RESTORESETTINGS,szTitle,100); for (int i=0;szFilter[i]!='/0';i++) { if (szFilter[i]=='|') szFilter[i]='/0'; } OPENFILENAME ofn; ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize=OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner=hWnd; ofn.hInstance=hInst; ofn.lpstrFilter=szFilter; ofn.lpstrFile=szPath; ofn.nMaxFile=MAX_PATH; ofn.lpstrTitle=szTitle; ofn.Flags=OFN_ENABLESIZING|OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_LONGNAMES|OFN_HIDEREADONLY; ofn.lpstrDefExt="*.reg"; if (!GetOpenFileName(&ofn)) return FALSE; int nDotIndex; for (nDotIndex=(int)strlen(szPath)-1;nDotIndex>=0 && szPath[nDotIndex]!='.';nDotIndex--); if (nDotIndex>=0 && _stricmp(szPath+nDotIndex+1,"reg")==0) { char szBackup[MAX_PATH]; CopyMemory(szBackup,szPath,nDotIndex+1); strcpy_s(szBackup+nDotIndex+1,MAX_PATH-nDotIndex-1,"old.reg"); // Backing up char szCommand[2000]; sprintf_s(szCommand,2000,"regedit /ea /"%s/" HKEY_CURRENT_USER//Software//Update",szBackup); PROCESS_INFORMATION pi; STARTUPINFO si; // Ansi and Unicode versions are same ZeroMemory(&si,sizeof(STARTUPINFO)); si.cb=sizeof(STARTUPINFO); if (CreateProcess(NULL,szCommand,NULL, NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL,NULL,&si,&pi)) { WaitForSingleObject(pi.hProcess,2000); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } else ShowError(hWnd,IDS_ERRORCANNOTRUNREGEDIT,GetLastError()); // Restore key DeleteSubKey(HKEY_CURRENT_USER,"SOFTWARE//Update"); sprintf_s(szCommand,2000,"regedit /s /"%s/"",szPath); ZeroMemory(&si,sizeof(STARTUPINFO)); si.cb=sizeof(STARTUPINFO); if (CreateProcess(NULL,szCommand,NULL, NULL,FALSE,CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL,NULL,&si,&pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } else ShowError(hWnd,IDS_ERRORCANNOTRUNREGEDIT,GetLastError());//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:quachdnguyen£¬ÏîÄ¿Ãû³Æ:locate-src£¬´úÂëÐÐÊý:101£¬
ʾÀý8: InitInstance//// FUNCTION: InitInstance(HANDLE, int)//// PURPOSE: Saves instance handle and creates main window//// COMMENTS://// In this function, we save the instance handle in a global variable and// create and display the main program window.//BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPTSTR lpCmdLine){ HWND hWnd = NULL; TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name BOOL bAlreadyRunning = FALSE; hInst = hInstance; // Store instance handle in our global variable // Initialize global strings LoadString(hInstance, IDC_STARTAPP, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); //If it is already running, then focus on the window hWnd = FindWindow(szWindowClass, szTitle); if (hWnd) { SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01)); // Set return value to indicate that we // want to close down this process. bAlreadyRunning = TRUE; } else { MyRegisterClass(hInstance, szWindowClass); RECT rect; GetClientRect(hWnd, &rect); hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } } // Data on the command line means we have a notication. // Send details to main window. if (_tcslen(lpCmdLine) > 0) { COPYDATASTRUCT cds; cds.cbData = (_tcslen(lpCmdLine)+1) * sizeof(TCHAR); cds.dwData = 0; cds.lpData = lpCmdLine; SendMessage(hWnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); } if (bAlreadyRunning) return FALSE; // If started by user, request notifications. if (_tcslen(lpCmdLine) == 0) { TCHAR tchApp[MAX_PATH]; GetModuleFileName(hInstance, tchApp, MAX_PATH); // First, clear out any previous requests. CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_NONE); // Now, let's register some more.z CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_DEVICE_CHANGE); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_RESTORE_END); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_RS232_DETECTED); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_SYNC_END); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_TIME_CHANGE);#ifdef NOTIFICATION_EVENT_TZ_CHANGE // New for CE 3.0 CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_TZ_CHANGE);#endif#ifdef NOTIFICATION_EVENT_WAKEUP // New for CE 3.0 CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_WAKEUP);#endif // Docs say these aren't supported. Are they? CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_ON_AC_POWER); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_OFF_AC_POWER); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_NET_CONNECT); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_NET_DISCONNECT); CeRunAppAtEvent(tchApp, NOTIFICATION_EVENT_IR_DISCOVERED); }// ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd);//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:venkatarajasekhar£¬ÏîÄ¿Ãû³Æ:repo£¬´úÂëÐÐÊý:101£¬
ʾÀý9: FindWindowvoid GraphicsCaptureSource::AttemptCapture(){ //Log(TEXT("attempting to capture..")); if (!bUseHotkey) hwndTarget = FindWindow(strWindowClass, NULL); else { hwndTarget = hwndNextTarget; hwndNextTarget = NULL; } if (hwndTarget) { GetWindowThreadProcessId(hwndTarget, &targetProcessID); if(!targetProcessID) { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: GetWindowThreadProcessId failed, GetLastError = %u"), GetLastError()); bErrorAcquiring = true; return; } } else { if (!bUseHotkey && !warningID) warningID = API->AddStreamInfo(Str("Sources.SoftwareCaptureSource.WindowNotFound"), StreamInfoPriority_High); bCapturing = false; return; } if(warningID) { API->RemoveStreamInfo(warningID); warningID = 0; } //------------------------------------------- // see if we already hooked the process. if not, inject DLL char pOPStr[12]; mcpy(pOPStr, "NpflUvhel{x", 12); //OpenProcess obfuscated for (int i=0; i<11; i++) pOPStr[i] ^= i^1; OPPROC pOpenProcess = (OPPROC)GetProcAddress(GetModuleHandle(TEXT("KERNEL32")), pOPStr); HANDLE hProcess = (*pOpenProcess)(PROCESS_ALL_ACCESS, FALSE, targetProcessID); if(hProcess) { //------------------------------------------- // load keepalive event hOBSIsAlive = CreateEvent(NULL, FALSE, FALSE, String() << OBS_KEEPALIVE_EVENT << UINT(targetProcessID)); //------------------------------------------- hwndCapture = hwndTarget; hSignalRestart = OpenEvent(EVENT_ALL_ACCESS, FALSE, String() << RESTART_CAPTURE_EVENT << UINT(targetProcessID)); if(hSignalRestart) { SetEvent(hSignalRestart); bCapturing = true; captureWaitCount = 0; } else { BOOL bSameBit = TRUE; if(Is64BitWindows()) { BOOL bCurrentProcessWow64, bTargetProcessWow64; IsWow64Process(GetCurrentProcess(), &bCurrentProcessWow64); IsWow64Process(hProcess, &bTargetProcessWow64); bSameBit = (bCurrentProcessWow64 == bTargetProcessWow64); } if(bSameBit) { String strDLL; DWORD dwDirSize = GetCurrentDirectory(0, NULL); strDLL.SetLength(dwDirSize); GetCurrentDirectory(dwDirSize, strDLL); strDLL << TEXT("//plugins//GraphicsCapture//GraphicsCaptureHook"); BOOL b32bit = TRUE; if(Is64BitWindows()) IsWow64Process(hProcess, &b32bit); if(!b32bit) strDLL << TEXT("64"); strDLL << TEXT(".dll"); if(InjectLibrary(hProcess, strDLL)) { captureWaitCount = 0;//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:AaronMike£¬ÏîÄ¿Ãû³Æ:OBS£¬´úÂëÐÐÊý:101£¬
ʾÀý10: UdpSocketThreadbool GNSx30Proxy::open(int gnsType){ bool res = true; if(stateInitialized != m_state) { res = false; return res; } HKEY hKey; DWORD dwDisposition; //Default frquencies m_comActive = 134100; m_comStandby = 130825; m_navActive = 108700; m_navStandby = 111450; m_pvData->gnsType = gnsType; m_pvData->garminTrainerPort = TRAINER_PORT; m_pvData->proxyPort = PROXY_PORT; //Start the serverThread m_pServerSocketThread = new UdpSocketThread(m_pvData->proxyPort); m_pServerSocketThread->create(); m_pServerSocketThread->setCallback(UdpDataCallback, this); m_pServerSocketThread->resume(); m_pClientSocket = new UdpSocket(); m_pClientSocket->openForSending("127.0.0.1", m_pvData->garminTrainerPort); if (ERROR_SUCCESS!= RegCreateKeyEx(HKEY_CURRENT_USER, GARMIN_INTERNATIONAL_SETTINGS, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey,&dwDisposition) ) { logMessageEx("??? GNSx30Proxy::open Error creating key " GARMIN_INTERNATIONAL_SETTINGS); res = false; return res; } if(TYPE_GNS430 == gnsType) { //Create the trainer settings values if (ERROR_SUCCESS != RegSetValueEx(hKey, "CDUType", 0, REG_SZ, (LPBYTE)GNS_430AWT, strlen(GNS_430AWT) + 1)) { logMessageEx("??? GNSx30Proxy::open Error writing key CDUType"); res = false; return res; } }else if(TYPE_GNS530 == gnsType) { //Create the trainer settings values if (ERROR_SUCCESS != RegSetValueEx(hKey, "CDUType", 0, REG_SZ, (LPBYTE)GNS_530AWT, strlen(GNS_530AWT) + 1)) { logMessageEx("??? GNSx30Proxy::open Error writing key CDUType"); res = false; return res; } } RegFlushKey(hKey); RegCloseKey(hKey); memset(m_pvData->LCD_data,0x00, OFFSCREEN_BUFFER_WIDTH*OFFSCREEN_BUFFER_HEIGHT*4); startAndInject(m_trainter_exe, m_trainter_path, m_interface_lib, m_hideGUI); int count = 0; bool procesStarted = false; while(count < 20) // 10 sec { m_win = FindWindow("AfxFrameOrView42", "GARMIN 400W/500W Trainer"); if(NULL != m_win) { procesStarted = true; break; } Sleep(500); count++; } if(!procesStarted) { logMessageEx("??? GNSx30Proxy::Open Error starting process %s", m_trainter_exe);//.........ÕâÀﲿ·Ö´úÂëÊ¡ÂÔ.........
¿ª·¢ÕßID:rwwende£¬ÏîÄ¿Ãû³Æ:garmin-gns-430-530-interface£¬´úÂëÐÐÊý:101£¬
|