void SetCompressorStats() { DWORD line_count, i; char buf[1024]; bool found = false; line_count = SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINECOUNT, 0, 0); for(i=0; i<line_count; i++) { *((LPWORD)buf) = sizeof(buf); SendDlgItemMessage(g_sdata.hwnd, IDC_LOGWIN, EM_GETLINE, (WPARAM)i, (LPARAM)buf); if(found) { DWORD len = lstrlen(TOTAL_SIZE_COMPRESSOR_STAT); lstrcat(g_sdata.compressor_stats,buf); if(!lstrncmp(buf,TOTAL_SIZE_COMPRESSOR_STAT,len)) { break; } } else { DWORD len = lstrlen(EXE_HEADER_COMPRESSOR_STAT); if(!lstrncmp(buf,EXE_HEADER_COMPRESSOR_STAT,len)) { found = true; lstrcpy(g_sdata.compressor_stats,"\n\n"); lstrcat(g_sdata.compressor_stats,buf); } } } }
BOOL CALLBACK CVisualBoyHandler::EnumVBAWindowProc(HWND hWnd, LPARAM lParam) { static CONST TCHAR szName[] = TEXT("VisualBoyAdvance"); static CONST DWORD cchNameLength = sizeof(szName) / sizeof(szName[0]); static CONST TCHAR szNameSpeed[] = TEXT("VisualBoyAdvance-nnn%"); static CONST DWORD cchNameSpeedLength = sizeof(szNameSpeed) / sizeof(szNameSpeed[0]); TCHAR szWindowName[cchNameSpeedLength]; DWORD cchWindowName; BOOL bContinue = TRUE; cchWindowName = GetWindowText(hWnd, szWindowName, cchNameSpeedLength); if(cchWindowName >= cchNameLength - 1) { if(lstrncmp(szWindowName, szName, cchNameLength - 1) == 0) { if(cchWindowName >= cchNameLength) { if(szWindowName[cchNameLength - 1] == TEXT('-')) { bContinue = FALSE; } } else { bContinue = FALSE; } } /* VBA-M */ else if(lstrncmp(szWindowName+1, szName, cchNameLength - 1) == 0) { if(cchWindowName >= cchNameLength) { if(szWindowName[cchNameLength] == TEXT('-')) { bContinue = FALSE; } } else { bContinue = FALSE; } } } if(bContinue == FALSE) { *reinterpret_cast<HWND *>(lParam) = hWnd; } return bContinue; }
static int isAccessiblePathName(TCHAR *pathName, int writeFlag) { int pathLen = lstrlen(pathName); if (pathLen > (MAX_PATH - 1)) return 0; if (pathLen >= untrustedUserDirectoryLen && 0 == lstrncmp(pathName, untrustedUserDirectory, untrustedUserDirectoryLen)) { if (pathLen > untrustedUserDirectoryLen + 2) return testDotDot(pathName, untrustedUserDirectoryLen+2); return 1; } if (writeFlag) return 0; if (pathLen >= resourceDirectoryLen && 0 == lstrncmp(pathName, resourceDirectory, resourceDirectoryLen)) { if (pathLen > resourceDirectoryLen + 2) return testDotDot(pathName, resourceDirectoryLen+2); return 1; } return 0; }
char* lstrstr(const char *str1, const char *str2) { if( str1 == str2 ) return (char*)str1; size_t len2 = lstrlen(str2); while( *str1 != endSymb ) { if( !lstrncmp(str1, str2, len2) ) return (char*)str1; ++str1; } return NULL; }