Advertisement
opexxx

process_enum.cpp

Apr 23rd, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. static VOID VmCheck()
  2. {
  3. DWORD nProcessIDs[1024];
  4. DWORD nProcesses;
  5. DWORD cb;
  6. DWORD i;
  7. HANDLE hProcess;
  8. CHAR szPath[MAX_PATH + 32];
  9. BOOLEAN found = FALSE;
  10.  
  11. /* Check running process for known Virtual Machine tools */
  12. if(EnumProcesses(nProcessIDs, sizeof(nProcessIDs), &cb)) {
  13. nProcesses = cb / sizeof(nProcessIDs[0]);
  14. for(i = 0; i < nProcesses; i++) {
  15. hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, nProcessIDs[i]);
  16. if(!hProcess)
  17. continue;
  18.  
  19. ZeroMemory(szPath, sizeof(szPath));
  20. if(!GetModuleFileNameEx(hProcess, NULL, szPath, sizeof(szPath)))
  21. continue;
  22.  
  23. if( (strstr(szPath, "VBoxService") != NULL) ||
  24. (strstr(szPath, "VBoxTray") != NULL)    ||
  25. (strstr(szPath, "VMware") != NULL)  ||
  26. (strstr(szPath, "VirtualPC") != NULL)   ||
  27. (strstr(szPath, "wireshark") != NULL) ) {
  28.  
  29. found = TRUE;
  30. break;
  31. }
  32.  
  33. CloseHandle(hProcess);
  34. }
  35. }
  36.  
  37. if(found)
  38. ExitProcess(1);
  39.  
  40. /* TODO: VMware sidt check */
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement