BOOL CWinWow64::Wow64IsX64Path( LPCWSTR lpszRealPath, BOOL bNormalized ) const { if (!lpszRealPath || !*lpszRealPath) { return FALSE; } CWinPath PathReal = lpszRealPath; if (!bNormalized) PathReal.ExpandNormalizedPathName(); if (0 == StrCmpNW(PathReal.m_strPath, m_PathSysWow64.m_strPath, m_PathSysWow64.m_strPath.GetLength())) { LPCWSTR lpszSubPath = (LPCWSTR)PathReal.m_strPath + m_PathSysWow64.m_strPath.GetLength(); if (!IsExemptSubDir(lpszSubPath)) { return TRUE; } } if (0 == StrCmpNW(PathReal.m_strPath, m_PathProgramFilesX86.m_strPath, m_PathProgramFilesX86.m_strPath.GetLength())) { return TRUE; } return FALSE; }
static void test_StrCmpW(void) { static const WCHAR str1[] = {'a','b','c','d','e','f'}; static const WCHAR str2[] = {'a','B','c','d','e','f'}; ok(0 != StrCmpNW(str1, str2, 5), "StrCmpNW is case-insensitive\n"); ok(0 == StrCmpNIW(str1, str2, 5), "StrCmpNIW is case-sensitive\n"); if (pChrCmpIW) { ok(!pChrCmpIW('a', 'a'), "ChrCmpIW doesn't work at all!\n"); ok(!pChrCmpIW('b', 'B'), "ChrCmpIW is not case-insensitive\n"); ok(pChrCmpIW('a', 'z'), "ChrCmpIW believes that a == z!\n"); } else win_skip("ChrCmpIW() is not available\n"); if (pStrIsIntlEqualW) { ok(pStrIsIntlEqualW(FALSE, str1, str2, 5), "StrIsIntlEqualW(FALSE,...) isn't case-insensitive\n"); ok(!pStrIsIntlEqualW(TRUE, str1, str2, 5), "StrIsIntlEqualW(TRUE,...) isn't case-sensitive\n"); } else win_skip("StrIsIntlEqualW() is not available\n"); if (pIntlStrEqWorkerW) { ok(pIntlStrEqWorkerW(FALSE, str1, str2, 5), "IntlStrEqWorkerW(FALSE,...) isn't case-insensitive\n"); ok(!pIntlStrEqWorkerW(TRUE, str1, str2, 5), "IntlStrEqWorkerW(TRUE,...) isn't case-sensitive\n"); } else win_skip("IntlStrEqWorkerW() is not available\n"); }
BOOL CWinWow64::Wow64FsRedirection( LPCWSTR lpszWow64Path, CString& strRealPath, BOOL bNormalized ) const { if (!m_bIsWow64 || !m_bRedirectionIsValid) { strRealPath.Empty(); return FALSE; } if (!lpszWow64Path || !*lpszWow64Path) { strRealPath.Empty(); return FALSE; } CWinPath PathWow64 = lpszWow64Path; if (!bNormalized) PathWow64.ExpandNormalizedPathName(); if (0 == StrCmpNW(PathWow64.m_strPath, m_PathSystem32.m_strPath, m_PathSystem32.m_strPath.GetLength())) { LPCWSTR lpszSubPath = (LPCWSTR)PathWow64.m_strPath + m_PathSystem32.m_strPath.GetLength(); if (!IsExemptSubDir(lpszSubPath)) { strRealPath = m_PathSysWow64.m_strPath; strRealPath.Append(lpszSubPath); return TRUE; } } if (0 == StrCmpNW(PathWow64.m_strPath, m_PathProgramFiles.m_strPath, m_PathProgramFiles.m_strPath.GetLength())) { LPCWSTR lpszSubPath = (LPCWSTR)PathWow64.m_strPath + m_PathProgramFiles.m_strPath.GetLength(); strRealPath = m_PathProgramFilesX86.m_strPath; strRealPath.Append(lpszSubPath); return TRUE; } strRealPath = PathWow64; return FALSE; }
BOOL CWinWow64::IsExemptSubDir( LPCWSTR lpszSubDir ) const { if (!lpszSubDir || !*lpszSubDir) return FALSE; if (0 == StrCmpNW(lpszSubDir, L"catroot\\", (int)wcslen(L"catroot\\"))) return TRUE; if (0 == StrCmpNW(lpszSubDir, L"catroot2\\", (int)wcslen(L"catroot2\\"))) return TRUE; if (0 == StrCmpNW(lpszSubDir, L"drivers\\etc\\", (int)wcslen(L"drivers\\etc\\"))) return TRUE; if (0 == StrCmpNW(lpszSubDir, L"logfiles\\", (int)wcslen(L"logfiles\\"))) return TRUE; if (0 == StrCmpNW(lpszSubDir, L"spool\\", (int)wcslen(L"spool\\"))) return TRUE; if (! AppGetSystemInfo()->IsWin7OrLater() ) return FALSE; if (0 == StrCmpNW(lpszSubDir, L"driversstore\\", (int)wcslen(L"driversstore\\"))) return TRUE; return FALSE; }
OBJECT_TYPE MapTypeNameToType(LPCWSTR TypeName, DWORD cbTypeName) { if (!TypeName) return UNKNOWN_OBJECT_TYPE; for (UINT i = 0; i < _countof(ObjectTypeNames); i++) { LPCWSTR typeName = ObjectTypeNames[i]; if (!StrCmpNW(typeName, TypeName, cbTypeName / sizeof(WCHAR))) { return (OBJECT_TYPE) i; } } return UNKNOWN_OBJECT_TYPE; }
void FileListDialog::ReadFromPipe(HANDLE g_hChildStd_OUT_Rd,int SearchType) { DWORD dwRead, dwWritten=0,len; char charBuf[CHAR_SIZE]; char *context,*buf,*chBuf=charBuf; TCHAR tchBuf[UCHAR_SIZE]; BOOL bSuccess = FALSE; SearchStringSize = SearchString.size(); std::wstring LastFile,NewFile; int Blocks=0; if(SearchType == GTAG_FILES) gtagSearchResult.ClearAll(); gtagFunctionList.ClearAll(); for (;;) { if(dwWritten){ strncpy_s(chBuf,CHAR_SIZE,buf,dwWritten); chBuf+=(dwWritten); } bSuccess = ReadFile( g_hChildStd_OUT_Rd, chBuf, CHAR_SIZE-dwWritten, &dwRead, NULL); if( ! bSuccess || dwRead == 0 ) break; chBuf=charBuf; dwWritten += dwRead; buf=strtok_s(chBuf,"\r\n",&context); while( buf != NULL ) { len = strlen(buf)+2; if(len<=dwWritten){ mbstowcs(tchBuf,buf,len); dwWritten-=len; if(SearchType==GTAG_FUNCTION &&(StrCmpNW(tchBuf,SearchString.c_str(),SearchStringSize))==0){ if(StrCmpNW(&tchBuf[SearchStringSize],L" ",1) == 0){ int looper; int numstart=0; std::wstring line_num; for(looper=SearchStringSize+1;looper<99;looper++) { if(StrCmpNW(tchBuf+looper,L" ",1)==0) if(numstart) break; else continue; else{ line_num.append(tchBuf+looper,1); numstart=1; } } linenum_list.push_back(StrToIntW(line_num.c_str())); } } else if(SearchType==GTAG_FILES) { fileName=tchBuf; int colonPos=0,numberPos=0; if(IsSymbolSearch){ if((colonPos=fileName.find(L":",2))==std::wstring::npos)continue; NewFile = fileName.substr(0,colonPos); if(LastFile.size()==0)LastFile=NewFile; if(LastFile!=NewFile){ gtagSearchResult.AddItem(LastFile); symbol_blocks.push_back(Blocks); LastFile=NewFile; } colonPos++; if((numberPos=fileName.find(L":",colonPos))==std::wstring::npos)continue; NewFile=fileName.substr(colonPos,numberPos-colonPos); symbol_linenum_list.push_back(StrToIntW(NewFile.c_str())); NewFile = fileName.substr(numberPos+1); NewFile.erase (0, NewFile.find_first_not_of (L" \t\r\n")) ; symbol_list.push_back(NewFile); Blocks++; } else{ //for now dont add h files if(fileName.find(L".h",fileName.size()-5)==std::wstring::npos) gtagSearchResult.AddItem(tchBuf); } } else if(SearchType==CTAG_FUNCTION){ std::wstring buffer = tchBuf; size_t sz = buffer.find(L"function"); if(sz!=std::wstring::npos && sz!=0){ unsigned int looper=sz; int numstart=0; std::wstring line_num; for(looper=sz+11;looper<sz+21;looper++) { if(StrCmpNW(tchBuf+looper,L" ",1)==0) if(numstart) break; else continue; else{ line_num.append(tchBuf+looper,1); numstart=1; } } ctag_linenum_list.push_back(StrToIntW(line_num.c_str())); ctag_func_list.push_back(tchBuf+looper+1+file_name_length); } } buf = strtok_s( NULL, "\r\n",&context ); } else break; } } if(IsSymbolSearch){ gtagSearchResult.AddItem(LastFile); symbol_blocks.push_back(Blocks); } CloseHandle(g_hChildStd_OUT_Rd); }