/* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "Common.h" BOOL findFilename(TCHAR *); TCHAR *filename(TCHAR *); BOOL WINAPI Enum16(DWORD, WORD, WORD, TCHAR *, TCHAR *, LPARAM); // Globals extern PROCESS_LIST ProcessList; BOOL areThereProcessesRunning(void) { HANDLE hSnapShot = NULL; LPDWORD lpdwPIDs = NULL; PROCESSENTRY32 procentry; BOOL bFlag; if (!ProcessList.count) // Process list is empty return FALSE; // Get a handle to a Toolhelp snapshot of all processes. if ((hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) == INVALID_HANDLE_VALUE) return FALSE; // While there are processes, keep looping. for (procentry.dwSize=sizeof(PROCESSENTRY32), bFlag=Process32First(hSnapShot, &procentry); bFlag; procentry.dwSize=sizeof(PROCESSENTRY32), bFlag=Process32Next(hSnapShot, &procentry)) { TCHAR *szFileNameAux = filename(procentry.szExeFile); // Search szFileName in user-defined list if (findFilename(szFileNameAux)) return TRUE; // Did we just bump into an NTVDM? if (!_wcsicmp(szFileNameAux, L"NTVDM.EXE")) { BOOL bFound = FALSE; // Enum the 16-bit stuff. VDMEnumTaskWOWEx(procentry.th32ProcessID, (TASKENUMPROCEX)Enum16, (LPARAM)&bFound); // Did we find any user-defined process? if (bFound) return TRUE; } } return FALSE; } BOOL WINAPI Enum16(DWORD dwThreadId, WORD hMod16, WORD hTask16, TCHAR *szModName, TCHAR *szFileName, LPARAM lpUserDefined) { BOOL bRet; BOOL *pbFound = (BOOL *)lpUserDefined; if ((bRet = findFilename(filename(szFileName)))) *pbFound = TRUE; return bRet; } BOOL findFilename(TCHAR *fileName) { for (int i=0; i < ProcessList.count; i++) if (ProcessList.szFileName[i] && !_wcsicmp(ProcessList.szFileName[i], fileName)) return TRUE; return FALSE; } TCHAR *filename(TCHAR *fullFileName) { TCHAR *str; str = wcsrchr(fullFileName, '\\'); if (!str) return fullFileName; return ++str; }