static BOOL CoreCheck() { BOOL bOk = TRUE; CHAR szVer[260]; TCHAR tszExePath[1024]; GetModuleFileName(GetModuleHandle(NULL), tszExePath, SIZEOF(tszExePath)); CallService(MS_SYSTEM_GETVERSIONTEXT, SIZEOF(szVer), (LPARAM)szVer); strlwr(szVer); _tcslwr(tszExePath); #ifdef _UNICODE bOk *= (GetVersion() & 0x80000000) == 0; bOk *= strstr(szVer, "unicode") != 0; #else bOk *= strstr(szVer, "unicode") == 0; #endif bOk *= _tcsstr(_tcsrchr(tszExePath, '\\'), _T("miranda")) != 0; bOk *= !strstr(szVer, "coffee") && strncmp(szVer, "1.", 2) && !strstr(szVer, " 1."); bOk *= myGlobals.mirandaVersion < PLUGIN_MAKE_VERSION(1,0,0,0); return bOk; }
//////////////////////////////////////////////////////////////////////////////////////// /// // /// BOOL CALLBACK EnumChildWindowCallback(HWND hwnd, LPARAM lParam) // /// // //////////////////////////////////////////////////////////////////////////////////////// static BOOL CALLBACK EnumChildWindowCallback(HWND hwnd, LPARAM lParam) { TCHAR ClassName[200],TextBuffer[200]; TButtonList *ButtonList=(TButtonList *)lParam; GetClassName(hwnd,ClassName,sizeof(ClassName)); GetWindowText(hwnd,TextBuffer,sizeof(TextBuffer)); _tcslwr(ClassName); _tcslwr(TextBuffer); if (ButtonList->NumButtons>=MAX_BUTTONS) return(FALSE); if (_tcsstr(ClassName,"button")) { if(_tcsstr(TextBuffer,_T("accept"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=ACCEPT; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("agree"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=AGREE; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("decline"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=DECLINE; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("yes"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=YES; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("continue"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=CONTINUE; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if((_tcsstr(TextBuffer,_T("no")))&&(!_tcsstr(TextBuffer,_T("not")))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=NO; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("cancel"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=CANCEL; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("close"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=CLOSE; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("ok"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=OK; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("don't"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=DONTSEND; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("open"))) { ButtonList->Button[ButtonList->NumButtons].ButtonType=OPEN; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } else if(_tcsstr(TextBuffer,_T("restart"))) { if (SendMessage(hwnd, BM_GETCHECK, 0, 0)==BST_CHECKED) { printf("Restart Button Checked\n"); ButtonList->Button[ButtonList->NumButtons].ButtonType=RESTART; ButtonList->Button[ButtonList->NumButtons].WindowHandle=hwnd; ButtonList->NumButtons++; return(TRUE); } } } return(TRUE); }
bool CTaksiProcess::OnDllProcessAttach() { // DLL_PROCESS_ATTACH // We have attached to a new process. via the CBT most likely. // This is called before anything else. // NOTE: HookCBTProc is probably already active and could be called at any time! // Get Name of the process the DLL is attaching to if ( ! ::GetModuleFileName(NULL, m_Stats.m_szProcessPath, sizeof(m_Stats.m_szProcessPath))) { m_Stats.m_szProcessPath[0] = '\0'; } else { _tcslwr(m_Stats.m_szProcessPath); } // determine process full path const TCHAR* pszTitle = GetFileTitlePtr(m_Stats.m_szProcessPath); ASSERT(pszTitle); // save short filename without ".exe" extension. const TCHAR* pExt = pszTitle + lstrlen(pszTitle) - 4; if ( !lstrcmpi(pExt, _T(".exe"))) { int iLen = pExt - pszTitle; lstrcpyn( m_szProcessTitleNoExt, pszTitle, iLen+1 ); m_szProcessTitleNoExt[iLen] = '\0'; } else { lstrcpy( m_szProcessTitleNoExt, pszTitle ); } bool bProcMaster = m_bIsProcessIgnored = CheckProcessMaster(); if ( bProcMaster ) { // First time here! if ( ! sg_Shared.InitShared()) { DEBUG_ERR(( "InitShared FAILED!" LOG_CR )); return false; } sg_ProcStats.InitProcStats(); sg_Config.InitConfig(); // Read from the INI file shortly. } else { if ( sg_Shared.m_dwVersionStamp != TAKSI_VERSION_N ) // this is weird! { DEBUG_ERR(( "InitShared BAD VERSION 0%x != 0%x" LOG_CR, sg_Shared.m_dwVersionStamp, TAKSI_VERSION_N )); return false; } } #ifdef _DEBUG CTaksiShared* pDll = &sg_Shared; CTaksiConfigData* pConfig = &sg_Config; #endif sg_Shared.m_iProcessCount ++; LOG_MSG(( "DLL_PROCESS_ATTACH '%s' v" TAKSI_VERSION_S " (num=%d)" LOG_CR, pszTitle, sg_Shared.m_iProcessCount )); // determine process handle that is loading this DLL. m_Stats.m_dwProcessId = ::GetCurrentProcessId(); m_hWndHookTry = NULL; // save handle to process' heap m_hHeap = ::GetProcessHeap(); // do not hook on selected applications. set m_bIsProcessIgnored if ( ! bProcMaster ) { // (such as: myself, Explorer.EXE) CheckProcessCustom(); // determine frame capturing algorithm if ( m_bIsProcessIgnored && ! bProcMaster ) { LOG_MSG(( "Special process ignored." LOG_CR )); return true; } } g_FrameRate.InitFreqUnits(); // log information on which process mapped the DLL sg_Shared.LogMessage( _T("mapped: ")); #ifdef USE_LOGFILE // open log file, specific for this process if ( sg_Config.m_bDebugLog ) { TCHAR szLogName[ _MAX_PATH ]; int iLen = _sntprintf( szLogName, COUNTOF(szLogName)-1, _T("%sTaksi_%s.log"), sg_Shared.m_szIniDir, m_szProcessTitleNoExt ); HRESULT hRes = g_Log.OpenLogFile(szLogName); if ( IS_ERROR(hRes)) { LOG_MSG(( "Log start FAIL. 0x%x" LOG_CR, hRes )); } else { DEBUG_TRACE(( "Log started." LOG_CR)); } } #endif if ( ! bProcMaster ) // not read INI yet. { DEBUG_TRACE(( "sg_Config.m_bDebugLog=%d" LOG_CR, sg_Config.m_bDebugLog)); DEBUG_TRACE(( "sg_Config.m_bUseDirectInput=%d" LOG_CR, sg_Config.m_bUseDirectInput)); DEBUG_TRACE(( "sg_Shared.m_hHookCBT=%d" LOG_CR, (UINT_PTR)sg_Shared.m_hHookCBT)); // DEBUG_TRACE(( "sg_Config.m_bUseGDI=%d" LOG_CR, sg_Config.m_abUseGAPI[TAKSI_GAPI_GDI])); } // ASSUME HookCBTProc will call AttachGAPIs later return true; }
/* ** CIilinkApp initialization */ BOOL CIilinkApp::InitInstance() { INT_PTR nResponse; CString Message, Message2; char CompilerLoc[1024]; HKEY hKeyVC9, hWinSDK6; int rc; BOOL bDefault=0; /* ** Make sure II_SYSTEM is set. */ if (!strcmp(getenv("II_SYSTEM"), "")) { Message.LoadString(IDS_NO_IISYSTEM); Message2.LoadString(IDS_TITLE); MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION); return FALSE; } rc = GetEnvironmentVariable("PATH", NULL, 0); if (rc > 0) { char *szBuf, *pdest; int result1=0, result2=0; szBuf = (char *)malloc(rc); GetEnvironmentVariable("PATH", szBuf, rc); _tcslwr(szBuf); pdest=_tcsstr(szBuf, "9.0\\vc"); if (pdest != NULL) result1=pdest-szBuf+1; pdest=_tcsstr(szBuf, "8\\vc"); if (pdest != NULL) result2=pdest-szBuf+1; if (result1 && result2 && result1 < result2 || result1 && !result2) bDefault=1; free(szBuf); } /* Find SDK 6.0 that goes along with VC9.0 */ if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v6.0A", 0, KEY_READ, &hWinSDK6) != ERROR_SUCCESS && bDefault) { Message.LoadString(IDS_NO_SDK6); Message2.LoadString(IDS_TITLE); MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION); } /* ** Let's find out if Visual Studio 9.0 is installed, and set up the environment to it. */ if (RegOpenKeyEx ( HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VS", 0, KEY_READ, &hKeyVC9) == ERROR_SUCCESS) { if (SearchPath(NULL, "cl.exe", NULL, sizeof(CompilerLoc), CompilerLoc, NULL) != 0 && !bDefault) { Message.LoadString(IDS_VC9_EXISTS); Message2.LoadString(IDS_TITLE); rc = MessageBox(NULL, Message, Message2, MB_YESNO | MB_ICONQUESTION); if (rc == IDYES) { if (hWinSDK6 == NULL) { Message.LoadString(IDS_NO_SDK6); Message2.LoadString(IDS_TITLE); MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION); } /* ** Set up our environment to point to the 9.0 compiler. */ SetupVC9Environment(hKeyVC9, hWinSDK6); } } else { /* ** Set up our environment to point to the VC .NET compiler. */ SetupVC9Environment(hKeyVC9, hWinSDK6); } RegCloseKey(hKeyVC9); RegCloseKey(hWinSDK6); } /* ** Make sure we can find the compiler. */ if (!SearchPath(NULL, "cl.exe", NULL, sizeof(CompilerLoc), CompilerLoc, NULL)) { Message.LoadString(IDS_NO_COMPILER); Message2.LoadString(IDS_TITLE); MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION); return FALSE; } /* ** Make sure the compiler version is at least at the version that ** the product was built with. */ if (!CompareVersion(CompilerLoc)) return FALSE; /* ** Make sure the installation is down. */ if (ping_iigcn()!=1) { int status; Message.LoadString(IDS_INGRES_RUNNING); Message2.LoadString(IDS_TITLE); status = MessageBox(NULL, Message, Message2, MB_YESNO | MB_ICONINFORMATION); if (status == IDNO) return FALSE; else IngresUp = TRUE; } AfxEnableControlContainer(); hSystemPalette=0; /* // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); */ InitCommonControls(); CWinApp::InitInstance(); AfxEnableControlContainer(); FileSrcList = FileObjList = NULL; UserLoc = ""; BackupExt = "BAK"; PropSheet psDlg("Ingres User Defined Data Type Linker"); m_pMainWnd = &psDlg; nResponse = psDlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } if (hSystemPalette) { HDC hDC=::GetDC(NULL); ::SelectPalette(hDC,hSystemPalette,FALSE); ::SelectPalette(hDC,hSystemPalette,TRUE); ::RealizePalette(hDC); ::ReleaseDC(NULL,hDC); } /* ** Since the dialog has been closed, return FALSE so that we exit the ** application, rather than start the application's message pump. */ return FALSE; }
INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { InviteChatParam *param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); param = (InviteChatParam*)lParam; break; case WM_CLOSE: EndDialog(hwndDlg, 0); break; case WM_NCDESTROY: delete param; break; case WM_NOTIFY: NMCLISTCONTROL* nmc; { nmc = (NMCLISTCONTROL*)lParam; if (nmc->hdr.idFrom == IDC_CCLIST) { switch (nmc->hdr.code) { case CLN_NEWCONTACT: if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0) ChatValidateContact((UINT_PTR)nmc->hItem, nmc->hdr.hwndFrom, param->ppro); break; case CLN_LISTREBUILT: if (param) ChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro); break; } } } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ADDSCR: if (param->ppro->msnLoggedIn) { TCHAR email[MSN_MAX_EMAIL_LEN]; GetDlgItemText(hwndDlg, IDC_EDITSCR, email, _countof(email)); CLCINFOITEM cii = { 0 }; cii.cbSize = sizeof(cii); cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS; cii.pszText = _tcslwr(email); HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1); } break; case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; case IDOK: char tEmail[MSN_MAX_EMAIL_LEN]; tEmail[0] = 0; GCThreadData *info = NULL; if (param->id) info = param->ppro->MSN_GetThreadByChatId(param->id); /*else if (param->hContact) { if (!param->ppro->MSN_IsMeByContact(param->hContact, tEmail)) info = param->ppro->MSN_GetThreadByContact(tEmail); }*/ HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST); STRLIST *cont = new STRLIST; ChatInviteSend(NULL, hwndList, *cont, param->ppro); if (info) { for (int i = 0; i < cont->getCount(); ++i) ChatInviteUser(param->ppro->msnNsThread, info, (*cont)[i]); delete cont; } else { /* Group chats only work for Skype users */ CMStringA buf; buf.AppendFormat("<thread><id></id><members><member><mri>%d:%s</mri><role>admin</role></member>", NETID_SKYPE, param->ppro->GetMyUsername(NETID_SKYPE)); for (int i = 0; i < cont->getCount(); ++i) { // TODO: Add support for assigning role in invite dialog maybe? buf.AppendFormat("<member><mri>%s</mri><role>user</role></member>", (*cont)[i]); } buf.Append("</members></thread>"); param->ppro->msnNsThread->sendPacketPayload("PUT", "MSGR\\THREAD", buf); } EndDialog(hwndDlg, IDOK); } break; } return FALSE; }
__inline void ConvertCase(TCHAR *dest, const TCHAR *source, size_t size) { _tcsncpy(dest, source, size); _tcslwr(dest); }
// --------------------------------------------------------------------------------------- // FUNCTION: CString::ToLower // CString& ToLower() // // DESCRIPTION: // This function converts the CString to all lowercase characters using ctype // // PARAMETERS: // RETURN VALUE: // a reference to this object (*this) -- allows chaining together of // these calls, (eg. strTest.ToLower().TrimLeft().ToUpper();) // --------------------------------------------------------------------------------------- CString& CString::ToLower() { //std::transform(begin(), end(), begin(), tolower); // portable, slow way of doing it _tcslwr(const_cast<PTSTR>(data())); // unportable, fast way return *this; }
extern "C" int __declspec(dllexport) CListInitialise() { mir_getLP( &pluginInfo ); mir_getCLI(); mir_getTMI(&tmi); API::onInit(); RegisterCLUIFrameClasses(); ZeroMemory((void *)&cfg::dat, sizeof(cfg::dat)); int iCount = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); iCount += 20; if (iCount < 300) iCount = 300; cfg::init(); cfg::dat.hMenuNotify = CreatePopupMenu(); cfg::dat.wNextMenuID = 1; cfg::dat.sortTimer = cfg::getDword("CLC", "SortTimer", 150); cfg::dat.avatarBorder = (COLORREF)cfg::getDword("CLC", "avatarborder", 0); cfg::dat.avatarRadius = (COLORREF)cfg::getDword("CLC", "avatarradius", 4); cfg::dat.hBrushAvatarBorder = CreateSolidBrush(cfg::dat.avatarBorder); cfg::dat.avatarSize = cfg::getWord("CList", "AvatarSize", 24); cfg::dat.dualRowMode = cfg::getByte("CLC", "DualRowMode", 0); cfg::dat.avatarPadding = cfg::getByte("CList", "AvatarPadding", 0); cfg::dat.isTransparent = cfg::getByte("CList", "Transparent", 0); cfg::dat.alpha = cfg::getByte("CList", "Alpha", SETTING_ALPHA_DEFAULT); cfg::dat.autoalpha = cfg::getByte("CList", "AutoAlpha", SETTING_ALPHA_DEFAULT); cfg::dat.fadeinout = cfg::getByte("CLUI", "FadeInOut", 0); cfg::dat.autosize = cfg::getByte("CLUI", "AutoSize", 0); cfg::dat.bNoOfflineAvatars = cfg::getByte("CList", "NoOfflineAV", 1); cfg::dat.bFullTransparent = cfg::getByte("CLUI", "fulltransparent", 0); cfg::dat.bDblClkAvatars = cfg::getByte("CLC", "dblclkav", 0); cfg::dat.bEqualSections = cfg::getByte("CLUI", "EqualSections", 0); cfg::dat.bCenterStatusIcons = cfg::getByte("CLC", "si_centered", 1); cfg::dat.boldHideOffline = -1; cfg::dat.bSecIMAvail = ServiceExists("SecureIM/IsContactSecured") ? 1 : 0; cfg::dat.bNoTrayTips = cfg::getByte("CList", "NoTrayTips", 0); cfg::dat.bShowLocalTime = cfg::getByte("CLC", "ShowLocalTime", 1); cfg::dat.bShowLocalTimeSelective = cfg::getByte("CLC", "SelectiveLocalTime", 1); cfg::dat.bDontSeparateOffline = cfg::getByte("CList", "DontSeparateOffline", 0); cfg::dat.bShowXStatusOnSbar = cfg::getByte("CLUI", "xstatus_sbar", 0); cfg::dat.bLayeredHack = cfg::getByte("CLUI", "layeredhack", 1); cfg::dat.bFirstRun = cfg::getByte("CLUI", "firstrun", 1); cfg::dat.langPackCP = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); cfg::dat.realTimeSaving = cfg::getByte("CLUI", "save_pos_always", 0); DWORD sortOrder = cfg::getDword("CList", "SortOrder", SORTBY_NAME); cfg::dat.sortOrder[0] = LOBYTE(LOWORD(sortOrder)); cfg::dat.sortOrder[1] = HIBYTE(LOWORD(sortOrder)); cfg::dat.sortOrder[2] = LOBYTE(HIWORD(sortOrder)); if (cfg::dat.bFirstRun) cfg::writeByte("CLUI", "firstrun", 0); ReloadThemedOptions(); Reload3dBevelColors(); cfg::dat.dwFlags = cfg::getDword("CLUI", "Frameflags", CLUI_FRAME_STATUSICONS | CLUI_FRAME_SHOWBOTTOMBUTTONS | CLUI_FRAME_BUTTONSFLAT | CLUI_FRAME_CLISTSUNKEN); cfg::dat.dwFlags |= (cfg::getByte("CLUI", "ShowSBar", 1) ? CLUI_FRAME_SBARSHOW : 0); cfg::dat.soundsOff = cfg::getByte("Skin", "UseSound", 1) ? 0 : 1; CallService(MS_DB_GETPROFILEPATHT, MAX_PATH, (LPARAM)cfg::dat.tszProfilePath); _tcslwr(cfg::dat.tszProfilePath); PreloadContactListModule(); // get the clist interface pcli->hInst = g_hInst; pcli->pfnBuildGroupPopupMenu = BuildGroupPopupMenu; pcli->pfnCluiProtocolStatusChanged = CluiProtocolStatusChanged; pcli->pfnCompareContacts = CompareContacts; pcli->pfnCreateClcContact = CreateClcContact; pcli->pfnCreateEvent = fnCreateEvent; pcli->pfnDocking_ProcessWindowMessage = Docking_ProcessWindowMessage; pcli->pfnGetDefaultFontSetting = GetDefaultFontSetting; pcli->pfnGetRowBottomY = RowHeight::getItemBottomY; pcli->pfnGetRowHeight = RowHeight::getHeight; pcli->pfnGetRowTopY = RowHeight::getItemTopY; pcli->pfnGetRowTotalHeight = RowHeight::getTotalHeight; pcli->pfnGetWindowVisibleState = GetWindowVisibleState; pcli->pfnHitTest = HitTest; pcli->pfnLoadContactTree = LoadContactTree; pcli->pfnOnCreateClc = OnCreateClc; pcli->pfnPaintClc = PaintClc; pcli->pfnRebuildEntireList = RebuildEntireList; pcli->pfnRowHitTest = RowHeight::hitTest; pcli->pfnScrollTo = ScrollTo; pcli->pfnTrayCalcChanged = TrayCalcChanged; pcli->pfnSetHideOffline = SetHideOffline; pcli->pfnShowHide = ShowHide; saveAddContactToGroup = pcli->pfnAddContactToGroup; pcli->pfnAddContactToGroup = AddContactToGroup; saveAddEvent = pcli->pfnAddEvent; pcli->pfnAddEvent = AddEvent; saveRemoveEvent = pcli->pfnRemoveEvent; pcli->pfnRemoveEvent = RemoveEvent; saveAddGroup = pcli->pfnAddGroup; pcli->pfnAddGroup = AddGroup; saveAddInfoItemToGroup = pcli->pfnAddInfoItemToGroup; pcli->pfnAddInfoItemToGroup = AddInfoItemToGroup; saveContactListControlWndProc = pcli->pfnContactListControlWndProc; pcli->pfnContactListControlWndProc = ContactListControlWndProc; saveContactListWndProc = pcli->pfnContactListWndProc; pcli->pfnContactListWndProc = ContactListWndProc; saveIconFromStatusMode = pcli->pfnIconFromStatusMode; pcli->pfnIconFromStatusMode = fnIconFromStatusMode; saveLoadClcOptions = pcli->pfnLoadClcOptions; pcli->pfnLoadClcOptions = LoadClcOptions; saveProcessExternalMessages = pcli->pfnProcessExternalMessages; pcli->pfnProcessExternalMessages = ProcessExternalMessages; saveRecalcScrollBar = pcli->pfnRecalcScrollBar; pcli->pfnRecalcScrollBar = RecalcScrollBar; saveTrayIconProcessMessage = pcli->pfnTrayIconProcessMessage; pcli->pfnTrayIconProcessMessage = TrayIconProcessMessage; int rc = LoadContactListModule(); if (rc == 0) rc = LoadCLCModule(); LoadCLUIModule(); LoadButtonModule(); HookEvent(ME_SYSTEM_MODULESLOADED, systemModulesLoaded); return rc; }
bool CGDALIO::Import(TERRAINCREATIONPARAMS *tcParms) { TCHAR OpenFileName[_MAX_PATH]; OPENFILENAME Ofn; double adfGeoTransform[6]; GDALDataset *poDataset; CString errMess; IToolBox *pToolBox; pToolBox = EngineGetToolBox(); if (!pToolBox) { return false; } // let's open all files up, because some GeoSpatial files // don't have extensions memset(&Ofn, 0, sizeof(OPENFILENAME)); Ofn.lStructSize = sizeof(OPENFILENAME); Ofn.lpstrFilter = RecognizedImportFormats; Ofn.nFilterIndex = 1; sprintf(OpenFileName, "*.*"); Ofn.lpstrFile = OpenFileName; Ofn.nMaxFile = _MAX_PATH; Ofn.lpstrTitle = _T("Open GeoSpatial File"); Ofn.hwndOwner = AfxGetApp()->GetMainWnd()->m_hWnd; Ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_NOCHANGEDIR; if (!GetOpenFileName(&Ofn)) { // cancel selected. return false; } poDataset = (GDALDataset *) GDALOpen( OpenFileName, GA_ReadOnly ); if( poDataset == NULL ) { errMess.Format(_T("Unable to open File\n%s\nError: %s"), OpenFileName, CPLGetLastErrorMsg()); MessageBox(NULL, _T("File Open Error!"), (const TCHAR *)errMess, MB_OK); return false; } if (poDataset->GetGeoTransform( adfGeoTransform ) != CE_None ) { errMess.Format(_T("Unable to retrieve dimensions of File\n%s\nError: %s"), OpenFileName, CPLGetLastErrorMsg()); MessageBox(NULL, _T("File Open Error!"), (const TCHAR *)errMess, MB_OK); GDALClose(poDataset); return false; } CHashString filePath; static DWORD msgHash_GetSceneSavePath = CHashString(_T("GetSceneSavePath")).GetUniqueID(); pToolBox->SendMessage(msgHash_GetSceneSavePath, sizeof(IHashString*), &filePath ); TCHAR relPathName[_MAX_PATH]; _tcscpy( relPathName, filePath.GetString() ); // split up the path TCHAR newPath[_MAX_PATH]; TCHAR newName[_MAX_FNAME]; _tsplitpath(pToolBox->GetRelativePath(relPathName), NULL, newPath, newName, NULL); // make sure lower case for IHashString Compares _tcslwr(newPath); _tcslwr(newName); // clear the sector modified map. SINGLETONINSTANCE(CTerrainEditor)->OnWorldModified(false); errMess.Format( _T("Size is %dx%dx%d\n"), poDataset->GetRasterXSize(), poDataset->GetRasterYSize(), poDataset->GetRasterCount() ); errMess.Format(_T( "Origin = (%.6f,%.6f)\n"), adfGeoTransform[0], adfGeoTransform[3] ); errMess.Format(_T("Pixel Size = (%.6f,%.6f)\n"), adfGeoTransform[1], adfGeoTransform[5] ); // for now assume data is in meters tcParms->TerrainWidth = (DWORD)ceil(((float)poDataset->GetRasterXSize() * fabs(adfGeoTransform[1])) / tcParms->SectorSize); tcParms->TerrainHeight = (DWORD)ceil(((float)poDataset->GetRasterYSize() * fabs(adfGeoTransform[5])) / tcParms->SectorSize); //Temp: Pause thumbnail thread: bool pause = true; static DWORD msgHash_PauseThumbnailGenerationThread = CHashString(_T("PauseThumbnailGenerationThread")).GetUniqueID(); pToolBox->SendMessage(msgHash_PauseThumbnailGenerationThread, sizeof( bool * ),&pause, NULL, NULL ); //End Temp static DWORD msgHash_TerrainManagerCreateTerrain = CHashString(_T("TerrainManagerCreateTerrain")).GetUniqueID(); pToolBox->SendMessage(msgHash_TerrainManagerCreateTerrain, sizeof( TERRAINCREATIONPARAMS ), tcParms, NULL, NULL ); //Temp: Unpause thumbnail thread pause = false; pToolBox->SendMessage(msgHash_PauseThumbnailGenerationThread, sizeof( bool * ),&pause, NULL, NULL ); //End Temp static DWORD msgHash_WorldModified = CHashString(_T("WorldModified")).GetUniqueID(); pToolBox->SendMessage(msgHash_WorldModified, sizeof(BOOL), (void *)true); SINGLETONINSTANCE(CTerrainEditor)->SetAllSectorsModified(); GDALClose(poDataset); return true; }
void CCOMString::MakeLower() { _tcslwr(m_pszString); }
extern "C" bool CGT_WriteFile( CGT_CDiagMsg*pdm, const TCHAR* pszPath, const TCHAR* pszFile, const void* pBuffer, long nBytes, long flags ) { FILE* pF; int iItems; TCHAR full[2*MAX_PATH]; bool bFirstTry; TCHAR mode[3]; if(pszPath && !FC_StringIsAbsPath(pszFile)) _tmakepath(full, NULL, pszPath, pszFile, NULL); else lstrcpy(full, pszFile); assert(lstrlen(full) < FC_ARRAY_LEN(full)); //assert: must now be full path: assert(FC_StringIsAbsPath(full)); if(flags & CGT_WF_TOLOWER) _tcslwr(full); bFirstTry = true; mode[0] = (flags & CGT_WF_APPEND) ? _T('a') : _T('w'); mode[1] = (flags & CGT_WF_TEXTMODE) ? _T('t') : _T('b'); mode[2] = 0; tryAgain: iItems =0; pF = _tfopen(full, mode); if(pF) { iItems = fwrite(pBuffer, 1, nBytes, pF); fclose(pF); if(iItems!=nBytes) pdm->msg1(CG_E_WRITE_FILE_FAILED, NULL, full); } else if(bFirstTry && (flags & CGT_WF_CRT_PATH)) { FC_CString jot; bFirstTry = false; //here we create the folder if not exists //assume that the error was due to non existent folder... jot.load(full).stripFilePart(); if(FC_CreateSubDir(jot)) goto tryAgain; else pdm->msg1(CG_E_MKDIR_FAILED, NULL, jot);//TODO should be fatal error. } else { FC_CString jot; pdm->msg2(CG_E_FILE_OPEN, NULL, full, jot.fmtSysErr(GetLastError())); } return iItems==nBytes; }
int _tmain(int argc, _TCHAR* argv[]) { EventLog::SetSourceName(_T("EasyDynamicDNS")); if (argc >= 2) { TCHAR cmd[20]; _tcsncpy(cmd, argv[1], 19); cmd[19] = 0; _tcslwr(cmd); if (_tcscmp(cmd, "/install") == 0) { if (Install() != TRUE) _tprintf(_T("Installation error.\n")); return 0; } else if (_tcscmp(cmd, "/uninstall") == 0) { if (Uninstall() != TRUE) _tprintf(_T("Remove error.\n")); return 0; } else if (_tcscmp(cmd, "/start") == 0) { if (Start() != TRUE) _tprintf(_T("Start error.\n")); return 0; } else if (_tcscmp(cmd, "/stop") == 0) { if (Stop() != TRUE) _tprintf(_T("Stop error.\n")); return 0; } else if (_tcscmp(cmd, "/config") == 0) { if (Config(argc - 2, &argv[2]) != TRUE) _tprintf(_T("Config error\n")); return 0; } else if (_tcscmp(cmd, "/run") == 0) { if (Run() != TRUE) _tprintf(_T("Run error\n")); return 0; } else if (_tcscmp(cmd, "/help") == 0) { Usage(); return 0; } else { _tprintf ("Syntax error\n"); Usage(); return 1; } } // run service SERVICE_TABLE_ENTRY DispatchTable[] = { { _T("EasyDynamicDNS"), (LPSERVICE_MAIN_FUNCTION) EasyDynamicDNSStart }, { NULL, NULL } }; if (!StartServiceCtrlDispatcher(DispatchTable)) { EventLog log; log.LogLastError("Service run error"); } return 0; }
KString& KString::ToLower() { _tcslwr(GetDataPtr()); return *this; }
extern "C" int __declspec(dllexport) CListInitialise(PLUGINLINK * link) { int rc = 0; DBVARIANT dbv; int i; char szProfilePath[MAX_PATH]; pluginLink = link; #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif mir_getMMI(&mmi); mir_getLI(&li); mir_getTMI(&tmi); mir_getLP( &pluginInfo ); API::onInit(); LoadCLCButtonModule(); RegisterCLUIFrameClasses(); ZeroMemory((void*) &cfg::dat, sizeof(cfg::dat)); int iCount = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); iCount += 20; if( iCount < 300 ) iCount = 300; cfg::eCache = reinterpret_cast<TExtraCache *>(malloc(sizeof(TExtraCache) * iCount)); ZeroMemory(cfg::eCache, sizeof(struct TExtraCache) * iCount); cfg::nextCacheEntry = 0; cfg::maxCacheEntry = iCount; cfg::init(); cfg::dat.toolbarVisibility = cfg::getDword("CLUI", "TBVisibility", DEFAULT_TB_VISIBILITY); cfg::dat.hMenuButtons = GetSubMenu(LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT)), 3); cfg::dat.hMenuNotify = CreatePopupMenu(); cfg::dat.wNextMenuID = 1; cfg::dat.sortTimer = cfg::getDword("CLC", "SortTimer", 150); cfg::dat.szNoEvents = TranslateTS(szNoevents); cfg::dat.avatarBorder = (COLORREF)cfg::getDword("CLC", "avatarborder", 0); cfg::dat.avatarRadius = (COLORREF)cfg::getDword("CLC", "avatarradius", 4); cfg::dat.hBrushAvatarBorder = CreateSolidBrush(cfg::dat.avatarBorder); cfg::dat.avatarSize = cfg::getWord("CList", "AvatarSize", 24); cfg::dat.dualRowMode = cfg::getByte("CLC", "DualRowMode", 0); cfg::dat.avatarPadding = cfg::getByte("CList", "AvatarPadding", 0); cfg::dat.isTransparent = cfg::getByte("CList", "Transparent", 0); cfg::dat.alpha = cfg::getByte("CList", "Alpha", SETTING_ALPHA_DEFAULT); cfg::dat.autoalpha = cfg::getByte("CList", "AutoAlpha", SETTING_ALPHA_DEFAULT); cfg::dat.fadeinout = cfg::getByte("CLUI", "FadeInOut", 0); cfg::dat.autosize = cfg::getByte("CLUI", "AutoSize", 0); cfg::dat.dwExtraImageMask = cfg::getDword("CLUI", "ximgmask", 0); cfg::dat.bNoOfflineAvatars = cfg::getByte("CList", "NoOfflineAV", 1); cfg::dat.bFullTransparent = cfg::getByte("CLUI", "fulltransparent", 0); cfg::dat.bDblClkAvatars = cfg::getByte("CLC", "dblclkav", 0); cfg::dat.bEqualSections = cfg::getByte("CLUI", "EqualSections", 0); cfg::dat.bCenterStatusIcons = cfg::getByte("CLC", "si_centered", 1); cfg::dat.boldHideOffline = -1; cfg::dat.bSecIMAvail = ServiceExists("SecureIM/IsContactSecured") ? 1 : 0; cfg::dat.bNoTrayTips = cfg::getByte("CList", "NoTrayTips", 0); cfg::dat.bShowLocalTime = cfg::getByte("CLC", "ShowLocalTime", 1); cfg::dat.bShowLocalTimeSelective = cfg::getByte("CLC", "SelectiveLocalTime", 1); cfg::dat.bDontSeparateOffline = cfg::getByte("CList", "DontSeparateOffline", 0); cfg::dat.bShowXStatusOnSbar = cfg::getByte("CLUI", "xstatus_sbar", 0); cfg::dat.bLayeredHack = cfg::getByte("CLUI", "layeredhack", 1); cfg::dat.bFirstRun = cfg::getByte("CLUI", "firstrun", 1); cfg::dat.langPackCP = CallService(MS_LANGPACK_GETCODEPAGE, 0, 0); cfg::dat.realTimeSaving = cfg::getByte("CLUI", "save_pos_always", 0); DWORD sortOrder = cfg::getDword("CList", "SortOrder", SORTBY_NAME); cfg::dat.sortOrder[0] = LOBYTE(LOWORD(sortOrder)); cfg::dat.sortOrder[1] = HIBYTE(LOWORD(sortOrder)); cfg::dat.sortOrder[2] = LOBYTE(HIWORD(sortOrder)); if(cfg::dat.bFirstRun) cfg::writeByte("CLUI", "firstrun", 0); if(!cfg::getString(NULL, "CLUI", "exIconOrder", &dbv)) { if(lstrlenA(dbv.pszVal) < EXICON_COUNT) { for(i = 1; i <= EXICON_COUNT; i++) cfg::dat.exIconOrder[i - 1] = i; } else { for(i = 0; i < EXICON_COUNT; i++) if(dbv.pszVal[i] < EXICON_COUNT+1 && dbv.pszVal[i] >0) cfg::dat.exIconOrder[i] = dbv.pszVal[i]; else cfg::dat.exIconOrder[i] = i+1; } DBFreeVariant(&dbv); } else { for(i = 1; i <= EXICON_COUNT; i++) cfg::dat.exIconOrder[i - 1] = i; } ReloadThemedOptions(); FLT_ReadOptions(); Reload3dBevelColors(); himlExtraImages = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16), 30, 2); ImageList_SetIconSize(himlExtraImages, cfg::dat.exIconScale, cfg::dat.exIconScale); cfg::dat.dwFlags = cfg::getDword("CLUI", "Frameflags", CLUI_FRAME_SHOWTOPBUTTONS | CLUI_FRAME_STATUSICONS | CLUI_FRAME_SHOWBOTTOMBUTTONS | CLUI_FRAME_BUTTONSFLAT | CLUI_FRAME_CLISTSUNKEN); cfg::dat.dwFlags |= (cfg::getByte("CLUI", "ShowSBar", 1) ? CLUI_FRAME_SBARSHOW : 0); cfg::dat.soundsOff = cfg::getByte("CLUI", "NoSounds", 0); CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szProfilePath); #if defined(_UNICODE) MultiByteToWideChar(CP_ACP, 0, szProfilePath, MAX_PATH, cfg::dat.tszProfilePath, MAX_PATH); cfg::dat.tszProfilePath[MAX_PATH - 1] = 0; #else mir_sntprintf(cfg::dat.tszProfilePath, MAX_PATH, "%s", szProfilePath); #endif _tcslwr(cfg::dat.tszProfilePath); if(cfg::getByte("Skin", "UseSound", 0) != cfg::dat.soundsOff) cfg::writeByte("Skin", "UseSound", (BYTE)(cfg::dat.soundsOff ? 0 : 1)); // get the clist interface pcli = ( CLIST_INTERFACE* )CallService(MS_CLIST_RETRIEVE_INTERFACE, 0, (LPARAM)g_hInst); if ( (INT_PTR)pcli == CALLSERVICE_NOTFOUND ) { LBL_Error: MessageBoxA( NULL, "This plugin requires Miranda IM 0.8.0.9 or later", "Fatal error", MB_OK ); return 1; } if ( pcli->version < 6 ) // don't join it with the previous if() goto LBL_Error; pcli->pfnBuildGroupPopupMenu = BuildGroupPopupMenu; pcli->pfnCluiProtocolStatusChanged = CluiProtocolStatusChanged; pcli->pfnCompareContacts = CompareContacts; pcli->pfnCreateClcContact = CreateClcContact; pcli->pfnCreateEvent = fnCreateEvent; pcli->pfnDocking_ProcessWindowMessage = Docking_ProcessWindowMessage; pcli->pfnGetDefaultFontSetting = GetDefaultFontSetting; pcli->pfnGetRowBottomY = RowHeight::getItemBottomY; pcli->pfnGetRowHeight = RowHeight::getHeight; pcli->pfnGetRowTopY = RowHeight::getItemTopY; pcli->pfnGetRowTotalHeight = RowHeight::getTotalHeight; pcli->pfnGetWindowVisibleState = GetWindowVisibleState; pcli->pfnHitTest = HitTest; pcli->pfnLoadContactTree = LoadContactTree; pcli->pfnOnCreateClc = LoadCLUIModule; pcli->pfnPaintClc = PaintClc; pcli->pfnRebuildEntireList = RebuildEntireList; pcli->pfnRowHitTest = RowHeight::hitTest; pcli->pfnScrollTo = ScrollTo; pcli->pfnTrayIconUpdateBase = TrayIconUpdateBase; pcli->pfnSetHideOffline = SetHideOffline; pcli->pfnShowHide = ShowHide; saveAddContactToGroup = pcli->pfnAddContactToGroup; pcli->pfnAddContactToGroup = AddContactToGroup; saveRemoveItemFromGroup = pcli->pfnRemoveItemFromGroup; pcli->pfnRemoveItemFromGroup = RemoveItemFromGroup; saveAddEvent = pcli->pfnAddEvent; pcli->pfnAddEvent = AddEvent; saveRemoveEvent = pcli->pfnRemoveEvent; pcli->pfnRemoveEvent = RemoveEvent; saveAddGroup = pcli->pfnAddGroup; pcli->pfnAddGroup = AddGroup; saveAddInfoItemToGroup = pcli->pfnAddInfoItemToGroup; pcli->pfnAddInfoItemToGroup = AddInfoItemToGroup; saveContactListControlWndProc = pcli->pfnContactListControlWndProc; pcli->pfnContactListControlWndProc = ContactListControlWndProc; saveContactListWndProc = pcli->pfnContactListWndProc; pcli->pfnContactListWndProc = ContactListWndProc; saveIconFromStatusMode = pcli->pfnIconFromStatusMode; pcli->pfnIconFromStatusMode = fnIconFromStatusMode; saveLoadClcOptions = pcli->pfnLoadClcOptions; pcli->pfnLoadClcOptions = LoadClcOptions; saveProcessExternalMessages = pcli->pfnProcessExternalMessages; pcli->pfnProcessExternalMessages = ProcessExternalMessages; saveRecalcScrollBar = pcli->pfnRecalcScrollBar; pcli->pfnRecalcScrollBar = RecalcScrollBar; saveTrayIconProcessMessage = pcli->pfnTrayIconProcessMessage; pcli->pfnTrayIconProcessMessage = TrayIconProcessMessage; rc = LoadContactListModule(); if (rc == 0) rc = LoadCLCModule(); HookEvent(ME_SYSTEM_MODULESLOADED, systemModulesLoaded); return rc; }
//-------------------------------------------------------------------------------------- int _tmain(int argc, _TCHAR* argv[]) { m_hInstance = (HINSTANCE)GetModuleHandle(NULL); if (argc >= 3) { m_lpFontPath = argv[2]; m_lpFontName = argv[1]; printf(__FUNCTION__"(): Using external font %ws \"%ws\"\n", m_lpFontName, m_lpFontPath); } else { printf("USAGE: MsFontsFuzz.exe <font_name> <font_file> [options]\n"); goto end; } _stprintf_s(m_TmpFontPath, _T("__TMP__%s"), _tGetNameFromFullPath(m_lpFontPath)); DbgMsg(__FILE__, __LINE__, "[+] Temporary font file is \"%ws\"\n", m_TmpFontPath); if (_tcslen(m_TmpFontPath) >= 4) { _tcslwr(m_TmpFontPath + _tcslen(m_TmpFontPath) - 4); if (!_tcscmp(m_TmpFontPath + _tcslen(m_TmpFontPath) - 4, _T(".otf"))) { m_dwFontType = FONT_TYPE_OTF; DbgMsg(__FILE__, __LINE__, "[+] Font type is .OTF\n"); } else if (!_tcscmp(m_TmpFontPath + _tcslen(m_TmpFontPath) - 4, _T(".ttf"))) { m_dwFontType = FONT_TYPE_TTF; DbgMsg(__FILE__, __LINE__, "[+] Font type is .TTF\n"); } } RemoveFontResource(m_TmpFontPath); #ifdef USE_BOADCAST_MESSAGES SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); #endif char ch = 0; memset(m_szTable, '.', sizeof(m_szTable) - 1); for (int i = 0; i < sizeof(m_szTable); i++) { if (i != 0 && i % 16 == 0) { m_szTable[i] = '\n'; continue; } if (ch >= 0x20) { m_szTable[i] = ch; } if (ch == 0x7f) { m_szTable[i] = 0; break; } ch += 1; } if (argc > 3) { // enumerate additional parameters for (int i = 3; i < argc; i++) { if (!_tcscmp(argv[i], _T("--test"))) { // single launch mode m_bTest = TRUE; } else if (!_tcscmp(argv[i], _T("--resume"))) { // resume fuzzing in the new process m_bResume = TRUE; } else if (!_tcscmp(argv[i], _T("--noisy"))) { // show lot of output information m_bNoisy = TRUE; } else if (!_tcscmp(argv[i], _T("--text")) && argc - i > 1) { #ifdef UNICODE // use caller-specified text for display WideCharToMultiByte( CP_ACP, 0, argv[i + 1], -1, m_szTable, sizeof(m_szTable) - 1, NULL, NULL ); #else strcpy_s(m_szTable, argv[i + 1]); #endif i++; } else if (!_tcscmp(argv[i], _T("--fix-crcs"))) { // fix incorrect checksums for the original font file m_bFixCrcs = TRUE; } else if (argc - i > 1 && argv[i][0] == '-') { /** * Process data generation options. */ LPCTSTR lpParam = argv[i] + 1; DWORD dwValue = 0; BOOL bFound = FALSE; if (!StrToIntEx(argv[i + 1], STIF_SUPPORT_HEX, (int *)&dwValue)) { DbgMsg(__FILE__, __LINE__, "[!] ERROR: Invalid value for parameter \"%ws\"\n", argv[i]); continue; } for (int i_n = 0; i_n < sizeof(m_Params) / sizeof(ENGINE_PARAM); i_n++) { // search parameter by name if (!_tcscmp(m_Params[i_n].lpName, lpParam)) { *(m_Params[i_n].pdwValue) = dwValue; bFound = TRUE; break; } } if (!bFound) { DbgMsg(__FILE__, __LINE__, "[!] ERROR: Unknown parameter \"%ws\"\n", argv[i]); } i++; } } } DbgInit(LOG_FILE_NAME); // check block size and range if (BLOCK_SIZE == 1) { if (BLOCK_RANGE_START >= 0xFF) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_START value (it must be <0xFF)\n"); goto end; } if (BLOCK_RANGE_END > 0xFF) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_END value (it must be <=0xFF)\n"); goto end; } } else if (BLOCK_SIZE == 2) { if (BLOCK_RANGE_START >= 0xFFFF) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_START value (it must be <0xFFFF)\n"); goto end; } if (BLOCK_RANGE_END > 0xFFFF) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_END value (it must be <=0xFFFF)\n"); goto end; } } else if (BLOCK_SIZE == 4) { if (BLOCK_RANGE_START >= 0xFFFFFFFF) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_START value (it must be <0xFFFFFFFF)\n"); goto end; } if (BLOCK_RANGE_END > 0xFFFFFFFF) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_END value (it must be <=0xFFFFFFFF)\n"); goto end; } } else { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_SIZE value (it must be 1, 2 or 4)\n"); goto end; } // check step size if (BLOCK_RANGE_N > BLOCK_RANGE_END) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid BLOCK_RANGE_N value (it must be <=BLOCK_RANGE_END)\n"); goto end; } WNDCLASSEX wcex; ZeroMemory(&wcex, sizeof(wcex)); wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.hInstance = m_hInstance; wcex.lpszClassName = _T(WND_CLASS); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); m_hWndEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (m_hWndEvent == NULL) { DbgMsg(__FILE__, __LINE__, "CreateEvent() ERROR %d\n", GetLastError()); goto end; } // register window class if (RegisterClassEx(&wcex) == NULL) { DbgMsg(__FILE__, __LINE__, "RegisterClassEx() ERROR %d\n", GetLastError()); goto end; } // init random number generator init_genrand(GetTickCount()); SetUnhandledExceptionFilter(UnhandledExceptionError); // read input file if (ReadFromFile(m_lpFontPath, &m_pData, &m_dwDataSize)) { if (FILE_RANGE_START >= m_dwDataSize) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid FILE_RANGE_START value (it must be <=FILE_SIZE)\n"); M_FREE(m_pData); return -1; } if (FILE_RANGE_END > m_dwDataSize) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid FILE_RANGE_END value (it must be <FILE_SIZE)\n"); M_FREE(m_pData); return -1; } if (FILE_RANGE_END == 0) { FILE_RANGE_END = m_dwDataSize; } if (FILE_RANGE_START >= FILE_RANGE_END) { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Invalid FILE_RANGE_START/FILE_RANGE_END values\n"); M_FREE(m_pData); return -1; } DbgMsg(__FILE__, __LINE__, "[+] %d bytes readed from \"%ws\"\n", m_dwDataSize, m_lpFontPath); if (!m_bResume && (m_dwFontType == FONT_TYPE_OTF || m_dwFontType == FONT_TYPE_TTF)) { OTF_TableByOffset(m_pData, (ULONG)-1); } if (m_bFixCrcs) { // write fixed checksums into the original file if (DumpToFile(m_lpFontPath, m_pData, m_dwDataSize)) { DbgMsg(__FILE__, __LINE__, "[+] Checksums has been fixed for font file \"%ws\"\n", m_lpFontPath); } } else if (m_bTest) { // single run with the unchanged font file if (DumpToFile(m_TmpFontPath, m_pData, m_dwDataSize)) { FuzzIteration(); } } else { DbgMsg(__FILE__, __LINE__, "[+] Fuzzing params:\n\n"); // print parameters values for (int i_n = 0; i_n < sizeof(m_Params) / sizeof(ENGINE_PARAM); i_n++) { DbgMsg(__FILE__, __LINE__, " %20ws = 0x%.8x\n", m_Params[i_n].lpName, *(m_Params[i_n].pdwValue)); } DbgMsg(__FILE__, __LINE__, "\n"); DbgMsg(__FILE__, __LINE__, "[+] Processing cases...\n\n"); // align buffer size by block size m_dwAlignedDataSize = XALIGN_UP(m_dwDataSize, BLOCK_SIZE); // allocate output buffer if (m_pAlignedData = M_ALLOC(m_dwAlignedDataSize)) { char *lpszBigBuff = (char *)M_ALLOC(BIG_BUFFER_LENGTH); if (lpszBigBuff) { FillMemory(lpszBigBuff, BIG_BUFFER_LENGTH, 'A'); } PVOID pBigData = M_ALLOC(m_dwDataSize + BIG_BUFFER_LENGTH); // for each byte/word/dword of input file... for (DWORD i = FILE_RANGE_START; i < FILE_RANGE_END; i += BLOCK_SIZE) { DbgMsg(__FILE__, __LINE__, "Offset=0x%.8x TotalSize=0x%.8x File=%.8x\n", i, m_dwDataSize, m_dwCasesProcessed); POTF_TABLE_HEADER Table = NULL; if (m_dwFontType == FONT_TYPE_OTF || m_dwFontType == FONT_TYPE_TTF) { Table = OTF_TableByOffset(m_pData, i); if (Table == NULL) { // skip OTF/TTF data outside the tables continue; } } if (BLOCK_RANGE_N > 0) { // fuze each value with the step size == BLOCK_RANGE_N for (DWORD n = XALIGN_DOWN(BLOCK_RANGE_START, BLOCK_RANGE_N); n < XALIGN_DOWN(BLOCK_RANGE_END, BLOCK_RANGE_N); n += BLOCK_RANGE_N) { // write plain value WriteVal(i, BLOCK_SIZE, n, n, n); if (BLOCK_SIZE > 1) { // write randomized value WriteVal(i, BLOCK_SIZE, n, n + getrand(0, BLOCK_RANGE_N - 1), n + getrand(0, BLOCK_RANGE_N - 1) ); } } } // zero-bytes stuff WriteVal(i, BLOCK_SIZE, 0x00, 0x0000, 0x00000000); // integer overflow stuff WriteVal(i, BLOCK_SIZE, 0xFF, 0xFFFF, 0xFFFFFFFF); // invalid user-mode pointers WriteVal(i, BLOCK_SIZE, 0x0D, 0x0D0D, 0x0D0D0D0D); if (lpszBigBuff && pBigData) { /** * Write big ASCI data after the each byte. */ memcpy(pBigData, m_pData, i); memcpy((PUCHAR)pBigData + i, lpszBigBuff, BIG_BUFFER_LENGTH); memcpy((PUCHAR)pBigData + i + BIG_BUFFER_LENGTH, (PUCHAR)m_pData + i, m_dwDataSize - i); if (m_dwFontType == FONT_TYPE_OTF || m_dwFontType == FONT_TYPE_TTF) { POTF_FILE_HEADER Hdr = (POTF_FILE_HEADER)pBigData; POTF_TABLE_HEADER Table = (POTF_TABLE_HEADER)((PUCHAR)pBigData + sizeof(OTF_FILE_HEADER)); POTF_TABLE_HEADER CurrentTable = NULL; for (USHORT t = 0; t < htons(Hdr->numTables); t++) { ULONG Offset = htonl(Table->offset), Length = htonl(Table->length); if (i >= Offset && i < Offset + Length) { // fix OTF/TTF table checksum and length ULONG Sum = OTF_CalcTableChecksum((ULONG *)((PUCHAR)pBigData + Offset), Length); Table->checkSum = htonl(Sum); Table->length = htonl(Length); CurrentTable = Table; break; } Table += 1; } if (CurrentTable) { Table = (POTF_TABLE_HEADER)((PUCHAR)pBigData + sizeof(OTF_FILE_HEADER)); for (USHORT t = 0; t < htons(Hdr->numTables); t++) { ULONG Offset = htonl(Table->offset), Length = htonl(Table->length); if (Offset > htonl(CurrentTable->offset)) { // fix offsets of the other tables Table->offset = htonl(Offset + BIG_BUFFER_LENGTH); } Table += 1; } } } if (DumpToFile(m_TmpFontPath, pBigData, m_dwDataSize + BIG_BUFFER_LENGTH)) { FuzzIteration(); m_dwCasesProcessed++; } } if (m_dwCasesProcessed > MAX_CASES_PER_PROCESS) { TCHAR szSelf[MAX_PATH], szCmdLine[MAX_PATH]; GetModuleFileName(GetModuleHandle(NULL), szSelf, MAX_PATH); _stprintf_s( szCmdLine, MAX_PATH, _T("\"%s\" \"%s\" \"%s\" -BLOCK_SIZE 0x%x -BLOCK_RANGE_START 0x%x -BLOCK_RANGE_END 0x%x -BLOCK_RANGE_N 0x%x -FILE_RANGE_START 0x%x --resume Y"), szSelf, m_lpFontName, m_lpFontPath, BLOCK_SIZE, BLOCK_RANGE_START, BLOCK_RANGE_END, BLOCK_RANGE_N, i ); if (m_bNoisy) { _tcscat(szCmdLine, _T(" --noisy Y")); } STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); // create a new fuzzer instance if (!CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { MessageBox(0, _T("CreateProcess() fails"), _T("ERROR"), MB_ICONERROR); } ExitProcess(0); } } DbgMsg(__FILE__, __LINE__, "Done; %d cases processed\n", m_dwCasesProcessed); if (pBigData) { M_FREE(pBigData); } if (lpszBigBuff) { M_FREE(lpszBigBuff); } M_FREE(m_pAlignedData); } } M_FREE(m_pData); } else { DbgMsg(__FILE__, __LINE__, __FUNCTION__"(): Error while reading input file\n"); } end: if (m_hWndEvent) { CloseHandle(m_hWndEvent); } printf("Press any key to quit...\n"); _getch(); return 0; }
void CIPFilterDlg::OnBnClickedAppend() { CString strFilePath; // Do NOT localize that string if (DialogBrowseFile(strFilePath, _T("All IP Filter Files (*ipfilter.dat;*ip.prefix;*.p2b;*.p2p;*.p2p.txt;*.zip;*.gz;*.rar)|*ipfilter.dat;*ip.prefix;*.p2b;*.p2p;*.p2p.txt;*.zip;*.gz;*.rar|eMule IP Filter Files (*ipfilter.dat;*ip.prefix)|*ipfilter.dat;*ip.prefix|Peer Guardian Files (*.p2b;*.p2p;*.p2p.txt)|*.p2b;*.p2p;*.p2p.txt|Text Files (*.txt)|*.txt|ZIP Files (*.zip;*.gz)|*.zip;*.gz|RAR Files (*.rar)|*.rar|All Files (*.*)|*.*||"))) { CWaitCursor curWait; TCHAR szExt[_MAX_EXT]; _tsplitpath(strFilePath, NULL, NULL, NULL, szExt); _tcslwr(szExt); bool bIsArchiveFile = _tcscmp(szExt, _T(".zip"))==0 || _tcscmp(szExt, _T(".rar"))==0 || _tcscmp(szExt, _T(".gz"))==0; bool bExtractedArchive = false; CString strTempUnzipFilePath; if (_tcscmp(szExt, _T(".zip")) == 0) { CZIPFile zip; if (zip.Open(strFilePath)) { CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p")); if (zfile == NULL) zfile = zip.GetFile(_T("ipfilter.dat")); if (zfile) { _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (zfile->Extract(strTempUnzipFilePath)) { strFilePath = strTempUnzipFilePath; bExtractedArchive = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from ZIP file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in ZIP file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } zip.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?"), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else if (_tcscmp(szExt, _T(".rar")) == 0) { CRARFile rar; if (rar.Open(strFilePath)) { CString strFile; if (rar.GetNextFile(strFile) && (strFile.CompareNoCase(_T("ipfilter.dat")) == 0 || strFile.CompareNoCase(_T("guarding.p2p")) == 0)) { _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); if (rar.Extract(strTempUnzipFilePath)) { strFilePath = strTempUnzipFilePath; bExtractedArchive = true; } else { CString strError; strError.Format(_T("Failed to extract IP filter file from RAR file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else { CString strError; strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in RAR file \"%s\"."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } rar.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } else if (_tcscmp(szExt, _T(".gz")) == 0) { CGZIPFile gz; if (gz.Open(strFilePath)) { _tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp")); strTempUnzipFilePath.ReleaseBuffer(); // add filename and extension of uncompressed file to temporary file CString strUncompressedFileName = gz.GetUncompressedFileName(); if (!strUncompressedFileName.IsEmpty()) { strTempUnzipFilePath += _T('.'); strTempUnzipFilePath += strUncompressedFileName; } if (gz.Extract(strTempUnzipFilePath)) { strFilePath = strTempUnzipFilePath; bExtractedArchive = true; } gz.Close(); } else { CString strError; strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?"), strFilePath); AfxMessageBox(strError, MB_ICONERROR); } } if ((!bIsArchiveFile || bExtractedArchive) && theApp.ipfilter->AddFromFile(strFilePath, true)) { if (thePrefs.GetFilterServerByIP()) theApp.emuledlg->serverwnd->serverlistctrl.RemoveAllFilteredServers(); InitIPFilters(); m_ipfilter.Update(-1); } if (!strTempUnzipFilePath.IsEmpty()) VERIFY( _tremove(strTempUnzipFilePath) == 0); } }
BOOL CPropertiesGeneral::OnInitDialog() { CPropertyPage::OnInitDialog(); CARMDlg* dlg=(CARMDlg*)this->GetParentOwner()->GetParent(); TCHAR szTemp[MAX_PATH]; arfile* arFile=(arfile*)dlg->m_lstFiles.GetItemDataPtr(dlg->m_lstFiles.GetCurSel()); HANDLE hFile; FILETIME fileTime; size_t fileSize; SYSTEMTIME stUTC, stLocal; TCITEM ti={0}; HZIP hZip; ZIPENTRY ze; LPTSTR pszTemp, pszBuffer, pszTok; CString szBytes; szBytes.LoadString(IDS_BYTES); _tcscpy(szTemp,arFile->fileName); *_tcsrchr(szTemp,'\\')=0; SetDlgItemText(IDC_PROP_DESC,arFile->description); SetDlgItemText(IDC_PROP_FILENAME,szTemp+_tcslen(szTemp)+1); SetDlgItemText(IDC_PROP_LOCATION,szTemp); _itot(arFile->size,szTemp,10); _tcscat(szTemp,szBytes); SetDlgItemText(IDC_PROP_UNCOMPRESSED,szTemp); hFile=CreateFile(arFile->fileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); fileSize=GetFileSize(hFile,NULL); GetFileTime(hFile,NULL,NULL,&fileTime); FileTimeToSystemTime(&fileTime, &stUTC); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); CloseHandle(hFile); _itot((int)fileSize,szTemp,10); _tcscat(szTemp,szBytes); SetDlgItemText(IDC_PROP_FILESIZE,szTemp); _stprintf(szTemp,"%4d/%2d/%2d %2d:%2d:%2d",stLocal.wYear,stLocal.wMonth,stLocal.wDay,stLocal.wHour,stLocal.wMinute,stLocal.wSecond); SetDlgItemText(IDC_PROP_MODIFIED,szTemp); _stprintf(szTemp,"%d - ",arFile->features); ti.mask=TCIF_TEXT; ti.pszText=szTemp+_tcslen(szTemp); ti.cchTextMax=MAX_PATH-(int)_tcslen(szTemp); dlg->m_tab.GetItem(dlg->m_tab.GetCurSel(),&ti); SetDlgItemText(IDC_PROP_FILETYPE,szTemp); hZip=OpenZip(arFile->fileName,0,ZIP_FILENAME); if (hZip) { for (int c=0; GetZipItem(hZip,c,&ze)!=ZR_ARGS; c++) { _tcslwr(ze.name); if (!_tcsncmp(ze.name,"tune/",5) && _tcsstr(ze.name,".info")) { pszTemp=(LPTSTR)malloc(ze.unc_size); UnzipItem(hZip,c,pszTemp,ze.unc_size,ZIP_MEMORY); pszBuffer=_tcsstr(pszTemp,"Colors="); if (pszBuffer) { pszBuffer+=7; if (_tcschr(pszBuffer,'\r')) *_tcschr(pszBuffer,'\r')=0; if (_tcschr(pszBuffer,'\n')) *_tcschr(pszBuffer,'\n')=0; pszTok=_tcstok(pszBuffer,"|"); while (pszTok) { ((CListBox*)this->GetDlgItem(IDC_PROP_VARIATIONS))->AddString(pszTok); pszTok=_tcstok(NULL,"|"); } } free(pszTemp); } } CloseZip(hZip); } return FALSE; }
void CDuiString::MakeLower() { _tcslwr(m_pstr); }
static void GetList(void *) { char szKey[64] = {0}; TCHAR tszTempPath[MAX_PATH]; DWORD dwLen = GetTempPath(SIZEOF(tszTempPath), tszTempPath); if (tszTempPath[dwLen-1] == '\\') tszTempPath[dwLen-1] = 0; ptrT updateUrl( GetDefaultUrl()), baseUrl; SERVLIST hashes(50, CompareHashes); if (!ParseHashes(updateUrl, baseUrl, hashes)) { hListThread = NULL; return; } FILELIST *UpdateFiles = new FILELIST(20); TCHAR *dirname = Utils_ReplaceVarsT(_T("%miranda_path%")); for (int i=0; i < hashes.getCount(); i++) { ServListEntry &hash = hashes[i]; TCHAR tszPath[MAX_PATH]; mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\%s"), dirname, hash.m_name); if (GetFileAttributes(tszPath) != DWORD(-1)) continue; FILEINFO *FileInfo = new FILEINFO; FileInfo->bDeleteOnly = FALSE; _tcscpy(FileInfo->tszOldName, hash.m_name); // copy the relative old name _tcscpy(FileInfo->tszNewName, hash.m_name); TCHAR tszFileName[MAX_PATH]; _tcscpy(tszFileName, _tcsrchr(tszPath, L'\\') + 1); TCHAR *tp = _tcschr(tszFileName, L'.'); *tp = 0; TCHAR tszRelFileName[MAX_PATH]; _tcscpy(tszRelFileName, hash.m_name); tp = _tcsrchr(tszRelFileName, L'.'); if (tp) *tp = 0; tp = _tcschr(tszRelFileName, L'\\'); if (tp) tp++; else tp = tszRelFileName; _tcslwr(tp); mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszFileName); mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), baseUrl, tszRelFileName); for (tp = _tcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = _tcschr(tp, '\\')) *tp++ = '/'; FileInfo->File.CRCsum = hash.m_crc; UpdateFiles->insert(FileInfo); } mir_free(dirname); // Show dialog if (UpdateFiles->getCount() == 0) { if (!opts.bSilent) ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List is empty."), 2, 0); delete UpdateFiles; } else CallFunctionAsync(LaunchListDialog, UpdateFiles); hListThread = NULL; }
void ShortcutMapper::populateShortCuts() { TCHAR filter1[40]={0},filter2[40]={0}; NppParameters *nppParam = NppParameters::getInstance(); size_t nrItems = 0; switch(_currentState) { case STATE_MENU: { nrItems = nppParam->getUserShortcuts().size(); break; } case STATE_MACRO: { nrItems = nppParam->getMacroList().size(); break; } case STATE_USER: { nrItems = nppParam->getUserCommandList().size(); break; } case STATE_PLUGIN: { nrItems = nppParam->getPluginCommandList().size(); break; } case STATE_SCINTILLA: { nrItems = nppParam->getScintillaKeyList().size(); break; } } ListView_DeleteAllItems(hlistview); if(nrItems==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); return; } else ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), true); switch(_currentState) { case STATE_MENU: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_MACRO: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_USER: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_PLUGIN: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_SCINTILLA: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } } int index=0; int widths[3]; widths[0]=gettextwidth(hlistview,L"Index"); widths[1]=gettextwidth(hlistview,L"Name"); widths[2]=gettextwidth(hlistview,L"Shortcut"); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER1),filter1,sizeof(filter2)/sizeof(TCHAR)); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER2),filter2,sizeof(filter2)/sizeof(TCHAR)); _tcslwr(filter1); _tcslwr(filter2); for(size_t i = 0; i < nrItems; i++) { TCHAR keys[40]={0}; const TCHAR *name=GetShortcutName(_currentState,i,nppParam); GetShortcutKeys(_currentState,i,nppParam,keys,sizeof(keys)/sizeof(TCHAR)); if((filter1[0]==L'\0' && filter2[0]==L'\0') || (filter1[0]!=L'\0' && CheckFilter(name,filter1)) || (filter2[0]!=L'\0' && CheckFilter(keys,filter2))){ TCHAR str[10]={0}; LV_ITEM lvitem={0}; int w; _sntprintf_s(str,sizeof(str)/sizeof(TCHAR),_TRUNCATE,L"%i",i); w=gettextwidth(hlistview,str); if(w>widths[0]) widths[0]=w; w=gettextwidth(hlistview,name); if(w>widths[1]) widths[1]=w; w=gettextwidth(hlistview,keys); if(w>widths[2]) widths[2]=w; lvitem.mask=LVIF_TEXT|LVIF_PARAM; lvitem.iItem=index; lvitem.pszText=(LPWSTR)str; lvitem.lParam=i; ListView_InsertItem(hlistview,&lvitem); lvitem.mask=LVIF_TEXT; lvitem.iSubItem=1; lvitem.pszText=(LPWSTR)name; ListView_SetItem(hlistview,&lvitem); lvitem.iSubItem=2; lvitem.pszText=(LPWSTR)keys; ListView_SetItem(hlistview,&lvitem); index++; } } ListView_SetColumnWidth(hlistview,0,widths[0]); ListView_SetColumnWidth(hlistview,1,widths[1]); ListView_SetColumnWidth(hlistview,2,widths[2]); ListView_SetItemState(hlistview,0,LVIS_SELECTED,LVIS_SELECTED); if(index==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); } }
//远程服务 bool CAttemperEngineSink::OnTCPNetworkMainRemoteService(WORD wSubCmdID, VOID * pData, WORD wDataSize, DWORD dwSocketID) { switch (wSubCmdID) { case SUB_CS_C_SEARCH_CORRESPOND: //协调查找 { //效验参数 ASSERT(wDataSize==sizeof(CMD_CS_C_SearchCorrespond)); if (wDataSize!=sizeof(CMD_CS_C_SearchCorrespond)) return false; //处理消息 CMD_CS_C_SearchCorrespond * pSearchCorrespond=(CMD_CS_C_SearchCorrespond *)pData; pSearchCorrespond->szNickName[CountArray(pSearchCorrespond->szNickName)-1]=0; //变量定义 CMD_CS_S_SearchCorrespond SearchCorrespond; ZeroMemory(&SearchCorrespond,sizeof(SearchCorrespond)); //结果用户 CGlobalUserItem * ResultUserItem[2]; ZeroMemory(ResultUserItem,sizeof(ResultUserItem)); //设置变量 SearchCorrespond.dwSocketID=pSearchCorrespond->dwSocketID; SearchCorrespond.dwClientAddr=pSearchCorrespond->dwClientAddr; //查找用户 if (pSearchCorrespond->dwGameID!=0L) { ResultUserItem[0]=m_GlobalInfoManager.SearchUserItemByGameID(pSearchCorrespond->dwGameID); } //查找用户 if (pSearchCorrespond->szNickName[0]!=0) { _tcslwr(pSearchCorrespond->szNickName); ResultUserItem[1]=m_GlobalInfoManager.SearchUserItemByNickName(pSearchCorrespond->szNickName); } //设置结果 for (BYTE i=0;i<CountArray(ResultUserItem);i++) { if (ResultUserItem[i]!=NULL) { //变量定义 WORD wServerIndex=0; //查找房间 do { //查找房间 CGlobalServerItem * pGlobalServerItem=ResultUserItem[i]->EnumServerItem(wServerIndex++); //终止判断 if (pGlobalServerItem==NULL) break; if (SearchCorrespond.wUserCount>=CountArray(SearchCorrespond.UserRemoteInfo)) break; //索引定义 WORD wIndex=SearchCorrespond.wUserCount++; //辅助信息 SearchCorrespond.UserRemoteInfo[wIndex].cbGender=ResultUserItem[i]->GetGender(); SearchCorrespond.UserRemoteInfo[wIndex].cbMemberOrder=ResultUserItem[i]->GetMemberOrder(); SearchCorrespond.UserRemoteInfo[wIndex].cbMasterOrder=ResultUserItem[i]->GetMasterOrder(); //用户信息 SearchCorrespond.UserRemoteInfo[wIndex].dwUserID=ResultUserItem[i]->GetUserID(); SearchCorrespond.UserRemoteInfo[wIndex].dwGameID=ResultUserItem[i]->GetGameID(); lstrcpyn(SearchCorrespond.UserRemoteInfo[wIndex].szNickName,ResultUserItem[i]->GetNickName(),LEN_NICKNAME); //房间信息 SearchCorrespond.UserRemoteInfo[wIndex].wKindID=pGlobalServerItem->GetKindID(); SearchCorrespond.UserRemoteInfo[wIndex].wServerID=pGlobalServerItem->GetServerID(); lstrcpyn(SearchCorrespond.UserRemoteInfo[wIndex].szGameServer,pGlobalServerItem->m_GameServer.szServerName,LEN_SERVER); } while (true); } } //发送数据 WORD wHeadSize=sizeof(SearchCorrespond)-sizeof(SearchCorrespond.UserRemoteInfo); WORD wItemSize=sizeof(SearchCorrespond.UserRemoteInfo[0])*SearchCorrespond.wUserCount; m_pITCPNetworkEngine->SendData(dwSocketID,MDM_CS_REMOTE_SERVICE,SUB_CS_S_SEARCH_CORRESPOND,&SearchCorrespond,wHeadSize+wItemSize); return true; } } return false; }
INT_PTR CALLBACK DlgInviteToChat(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { InviteChatParam* param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); param = (InviteChatParam*)lParam; // WindowSetIcon(hwndDlg, "msn"); break; case WM_CLOSE: EndDialog(hwndDlg, 0); break; case WM_NCDESTROY: // WindowFreeIcon(hwndDlg); delete param; break; case WM_NOTIFY: { NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam; if (nmc->hdr.idFrom == IDC_CCLIST) { switch (nmc->hdr.code) { case CLN_NEWCONTACT: if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0) ChatValidateContact(nmc->hItem, nmc->hdr.hwndFrom, param->ppro); break; case CLN_LISTREBUILT: if (param) ChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro); break; } } } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case IDC_ADDSCR: if (param->ppro->msnLoggedIn) { TCHAR email[MSN_MAX_EMAIL_LEN]; GetDlgItemText(hwndDlg, IDC_EDITSCR, email, SIZEOF(email)); CLCINFOITEM cii = {0}; cii.cbSize = sizeof(cii); cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS; cii.pszText = _tcslwr(email); HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1); } break; case IDOK: { char tEmail[MSN_MAX_EMAIL_LEN] = ""; ThreadData *info = NULL; if (param->id) info = param->ppro->MSN_GetThreadByChatId(param->id); else if (param->hContact) { if (!param->ppro->MSN_IsMeByContact(param->hContact, tEmail)) info = param->ppro->MSN_GetThreadByContact(tEmail); } HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST); STRLIST *cont = new STRLIST; ChatInviteSend(NULL, hwndList, *cont, param->ppro); if (info) { for (int i = 0; i < cont->getCount(); ++i) ChatInviteUser(info, (*cont)[i]); delete cont; } else { if (tEmail[0]) cont->insertn(tEmail); param->ppro->MsgQueue_Add("chat", 'X', NULL, 0, NULL, 0, cont); if (param->ppro->msnLoggedIn) param->ppro->msnNsThread->sendPacket("XFR", "SB"); } } EndDialog(hwndDlg, IDOK); break; case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; } } break; } return FALSE; }
///////////////////////////////////////////////////////////////////////////// // {secret} int TCReplaceTextImpl(LPCTSTR pszSource, LPCTSTR pszFind, LPCTSTR pszReplace, LPTSTR pszDest, int cchMaxDest, bool bIgnoreCase, int* pnOccurrences) { // Initialize the number of occurrences found if (pnOccurrences) *pnOccurrences = 0; // Count the length of the source string int cchSource = pszSource ? _tcslen(pszSource) : 0; // If ignoring case, copy the source string and make it lowercase LPCTSTR pszSource2; if (cchSource) { if (bIgnoreCase) { LPTSTR pszTemp = LPTSTR(_alloca((cchSource + 1) * sizeof TCHAR)); _tcscpy(pszTemp, pszSource); _tcslwr(pszTemp); pszSource2 = pszTemp; } else pszSource2 = pszSource; } // Count the length of the search phrase int cchFind = pszFind ? _tcslen(pszFind) : 0; // If ignoring case, copy the search phrase and make it lowercase LPCTSTR pszFind2; if (cchFind) { if (bIgnoreCase) { LPTSTR pszTemp = LPTSTR(_alloca((cchFind + 1) * sizeof TCHAR)); _tcscpy(pszTemp, pszFind); _tcslwr(pszTemp); pszFind2 = pszTemp; } else pszFind2 = pszFind; } // Count the length of the replacement string int cchReplace = pszReplace ? _tcslen(pszReplace) : 0; // Ensure that cchMaxDest is zero if pszDest is NULL if (!pszDest) cchMaxDest = 0; // Determine if pszDest is equal to pszSource (in-place operation) else if (pszDest == pszSource) { // Ensure that the replacement phrase is no longer than the search phrase if (cchReplace > cchFind) return -1; // If cchMaxDest is negative, use the length of the source string if (cchMaxDest < 0) cchMaxDest = cchSource + 1; // Ensure that cchMaxDest characters will fit into the source string else if (cchMaxDest > (cchSource + 1)) return -1; } // pszDest cannot be within pszSource else if (pszDest > pszSource && pszDest <= pszSource + cchSource) return -1; // Otherwise cchMaxDest must be zero or positive else if (cchMaxDest < 0) return -1; // Loop until search phrase is not found int nOccurrences = 0, cchNeeded; if (cchSource && cchFind) { LPCTSTR pszBegin = pszSource; LPCTSTR pszBegin2 = pszSource2; LPCTSTR pszFound; while (NULL != (pszFound = _tcsstr(pszBegin2, pszFind2))) { // Increment the count of occurrences ++nOccurrences; // Copy the string up to the first character of the search phrase int cch = pszFound - pszBegin2; if (cch < cchMaxDest) _tcsncpy(pszDest, pszBegin, cch); else TC_tcscpyn(pszDest, pszBegin, cchMaxDest); cchMaxDest = max(0, cchMaxDest - cch); pszDest += cch; // Copy the replacement string if (cchReplace < cchMaxDest) _tcsncpy(pszDest, pszReplace, cchReplace); else TC_tcscpyn(pszDest, pszReplace, cchMaxDest); cchMaxDest = max(0, cchMaxDest - cchReplace); pszDest += cchReplace; // Increment the begining pointers past the search phrase pszBegin += cch + cchFind; pszBegin2 += cch + cchFind; } // Copy the remaining part of the string and ensure null-termination TC_tcscpyn(pszDest, pszBegin, cchMaxDest); // Compute the number of characters needed for the destination string cchNeeded = nOccurrences * (cchReplace - cchFind) + cchSource; } else if (!cchFind) { TC_tcscpyn(pszDest, pszReplace, cchMaxDest); nOccurrences = 1; cchNeeded = cchReplace; } else { nOccurrences = 0; cchNeeded = 0; TC_tcscpyn(pszDest, NULL, cchMaxDest); } // Copy the number of occurrences of the search phrase that were found if (pnOccurrences) *pnOccurrences = nOccurrences; // Return the number of characters needed for the destination string return cchNeeded; }
void CStdString::MakeLower() { _tcslwr(m_pstr); }
BOOL SearchForExecutable (LPCTSTR pFileName, LPTSTR pFullName) { static TCHAR pszDefaultPathExt[] = _T(".com;.exe;.bat;.cmd"); LPTSTR pszPathExt, pszPath; LPTSTR pCh; DWORD dwBuffer; TRACE ("SearchForExecutable: \'%s\'\n", debugstr_aw(pFileName)); /* load environment variable PATHEXT */ pszPathExt = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, ENV_BUFFER_SIZE); if (dwBuffer > ENV_BUFFER_SIZE) { LPTSTR pszOldPathExt = pszPathExt; pszPathExt = (LPTSTR)cmd_realloc (pszPathExt, dwBuffer * sizeof (TCHAR)); if (pszPathExt == NULL) { cmd_free(pszOldPathExt); return FALSE; } GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, dwBuffer); _tcslwr(pszPathExt); } else if (0 == dwBuffer) { _tcscpy(pszPathExt, pszDefaultPathExt); } else { _tcslwr(pszPathExt); } /* Check if valid directly on specified path */ if (SearchForExecutableSingle(pFileName, pFullName, pszPathExt, NULL)) { cmd_free(pszPathExt); return TRUE; } /* If an explicit directory was given, stop here - no need to search PATH. */ if (pFileName[1] == _T(':') || _tcschr(pFileName, _T('\\'))) { cmd_free(pszPathExt); return FALSE; } /* load environment variable PATH into buffer */ pszPath = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR)); dwBuffer = GetEnvironmentVariable (_T("PATH"), pszPath, ENV_BUFFER_SIZE); if (dwBuffer > ENV_BUFFER_SIZE) { LPTSTR pszOldPath = pszPath; pszPath = (LPTSTR)cmd_realloc (pszPath, dwBuffer * sizeof (TCHAR)); if (pszPath == NULL) { cmd_free(pszOldPath); cmd_free(pszPathExt); return FALSE; } GetEnvironmentVariable (_T("PATH"), pszPath, dwBuffer); } TRACE ("SearchForExecutable(): Loaded PATH: %s\n", debugstr_aw(pszPath)); /* search in PATH */ pCh = _tcstok(pszPath, _T(";")); while (pCh) { if (SearchForExecutableSingle(pFileName, pFullName, pszPathExt, pCh)) { cmd_free(pszPath); cmd_free(pszPathExt); return TRUE; } pCh = _tcstok(NULL, _T(";")); } cmd_free(pszPath); cmd_free(pszPathExt); return FALSE; }
void CUiApp::RegisterClass( arg_sptr_c<RegContext>::type pctx ) { mui_string ls = pctx->register_name; _tcslwr( const_cast<TCHAR*>( ls.c_str() ) ); m_regmap[ls] = pctx; }
INT_PTR CALLBACK dlgfunc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { int id, f, option; TCHAR buffer[MAX_PATH], temp[2000]; switch( msg ) { case WM_DESTROY: g_hDlg = NULL; return 0; case WM_INITDIALOG: g_hDlg = hDlg; option = 0; Init (); if (0 == is_usingNT) { EnableWindow(GetDlgItem(hDlg, IDC_CHK1), FALSE); } else if (0 == is_admin) { /* if not admin, see if a shell is set for this user */ is_per_user = rw_reg(A_RD|A_SZ, HKEY_CURRENT_USER, logonstr, TEXT("Shell"), buffer); SetDlgItemText(hDlg, IDC_CHK1, TEXT("Set shell for this user &individually")); } CheckDlgButton(hDlg, IDC_CHK1, is_per_user ? BST_CHECKED : BST_UNCHECKED); display: if (is_usingNT) { if (0 == is_per_user) { _tcscpy(buffer, TEXT("Shell for all users")); if (0 == is_admin) _tcscat(buffer, TEXT(" (run as admin to change)")); } else { DWORD result = sizeof temp; temp[0] = 0; GetUserName(temp, &result); _stprintf(buffer, TEXT("Shell for the current user (%s)"), temp); } SetDlgItemText(hDlg, IDC_GRP1, buffer); } if (2 == option) _tcscpy(buffer, szBlackbox); else if (1 == option) _tcscpy(buffer, szExplorer); else get_shell(buffer); _tcslwr(_tcscpy(temp, buffer)); if (0 == _tcsicmp(temp, szBlackbox)) { id = IDC_RBN1; } else if (_tcsstr(temp, TEXT("explorer"))) { id = IDC_RBN2; } else if (temp[0]) { id = IDC_RBN3; } else { _tcscpy(buffer, TEXT("<not set>")); id = 0; } CheckRadioButton(hDlg, IDC_RBN1, IDC_RBN3, id); for (f = IDC_RBN1; f <= IDC_RBN3; ++f) EnableWindow(GetDlgItem(hDlg, f), is_admin || is_per_user); set_line: { HWND hLine = GetDlgItem(hDlg, IDC_EDT1); SetWindowText(hLine, buffer); SendMessage(hLine, EM_SETREADONLY, id != IDC_RBN3, 0); } return 1; case WM_COMMAND: id = LOWORD( wParam ); switch(id) { case IDC_CHK1: is_per_user = 0 != IsDlgButtonChecked(hDlg, id); option = 0; goto display; case IDC_RBN1: option = 2; goto display; case IDC_RBN2: option = 1; goto display; case IDC_RBN3: buffer[0] = 0; goto set_line; case IDCANCEL: EndDialog(hDlg, 0); return 1; case IDOK: case IDC_LOG1: GetDlgItemText(hDlg, IDC_EDT1, shellpath, sizeof shellpath); if (SetAsShell(shellpath) == 1) return 1; if (0 == is_admin && is_per_user && 0 == get_per_user()) { id = 1; } else if (id == IDC_LOG1) { id = 2; } else if (0 == is_admin && 0 == is_per_user) { id = 3; } else { id = 4; } EndDialog(hDlg, id); return 1; } } return 0; }