Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1998- **
  4. //*********************************************************************
  5. //
  6. // created 8-19-1998
  7. //
  8. //
  9. // class definition for the process information handler
  10. // the class is to wrap NT/Win95 specific debugging aid APIs
  11. #ifdef UNICODE
  12. #undef Process32First
  13. #undef Process32Next
  14. #undef PROCESSENTRY32
  15. #undef PPROCESSENTRY32
  16. #undef LPPROCESSENTRY32
  17. #endif // !UNICODE
  18. class CProcessInfo
  19. {
  20. public:
  21. CProcessInfo();
  22. ~CProcessInfo();
  23. HRESULT GetExeNameFromPID(DWORD dwPID, LPTSTR szFile, int cchFile);
  24. BOOL _fNT;
  25. protected:
  26. HRESULT MakeRoomForInfoArray(int n);
  27. HRESULT EnsureProcessInfo();
  28. //
  29. // win95 toolhelp stuff
  30. //
  31. HRESULT W95InitToolhelp32();
  32. HRESULT W95CreateProcessList();
  33. HRESULT W95FillProcessList();
  34. typedef BOOL (WINAPI* PROCESSWALK)(HANDLE, LPPROCESSENTRY32);
  35. typedef HANDLE (WINAPI* CREATESNAPSHOT)(DWORD, DWORD);
  36. CREATESNAPSHOT _lpfnCreateToolhelp32Snapshot;
  37. PROCESSWALK _lpfnProcess32First;
  38. PROCESSWALK _lpfnProcess32Next;
  39. //
  40. // NT PSAPI stuff
  41. //
  42. HRESULT NTInitPsapi();
  43. HRESULT NTCreateProcessList();
  44. HRESULT NTFillProcessList(DWORD dwProcessID, int iIndex);
  45. typedef BOOL (CALLBACK* LPFNENUMPROCESSES)(DWORD *,DWORD,DWORD *);
  46. typedef BOOL (CALLBACK* LPFNENUMPROCESSMODULES)(HANDLE,HMODULE *,DWORD,LPDWORD);
  47. typedef DWORD (CALLBACK* LPFNGETMODULEBASENAMEW)(HANDLE,HMODULE,LPWSTR,DWORD);
  48. HINSTANCE _hPsapiDLL;
  49. LPFNENUMPROCESSES _lpfnEnumProcesses;
  50. LPFNENUMPROCESSMODULES _lpfnEnumProcessModules;
  51. LPFNGETMODULEBASENAMEW _lpfnGetModuleBaseName;
  52. //
  53. // place to hold processs information
  54. //
  55. struct PROCESSINFO {
  56. DWORD dwPID;
  57. TCHAR szExeName[MAX_PATH];
  58. } *_pProcInfoArray;
  59. int _iProcInfoCount;
  60. int _nAlloced;
  61. };