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.

128 lines
3.6 KiB

  1. #define MAX_PROCESS_NAME_LENGTH (MAX_PATH*sizeof(WCHAR))
  2. #define MAX_THREAD_NAME_LENGTH (10*sizeof(WCHAR))
  3. //
  4. // Value to decide if process names should be collected from:
  5. // the SystemProcessInfo structure (fastest)
  6. // -- or --
  7. // the process's image file (slower, but shows Unicode filenames)
  8. //
  9. #define PNCM_NOT_DEFINED ((LONG)-1)
  10. #define PNCM_SYSTEM_INFO 0L
  11. #define PNCM_MODULE_FILE 1L
  12. extern LONG lProcessNameCollectionMethod;
  13. #define IDLE_PROCESS_ID ((DWORD)0)
  14. #define SYSTEM_PROCESS_ID ((DWORD)7)
  15. //
  16. // Process/Thread name format
  17. //
  18. #define NAME_FORMAT_BLANK 1 // Nothing appended
  19. #define NAME_FORMAT_ID 2 // PID/TID appended
  20. #define NAME_FORMAT_DEFAULT 1 // Default to what it used to be
  21. //
  22. // VA structures & defines
  23. //
  24. #define NOACCESS 0
  25. #define READONLY 1
  26. #define READWRITE 2
  27. #define WRITECOPY 3
  28. #define EXECUTE 4
  29. #define EXECUTEREAD 5
  30. #define EXECUTEREADWRITE 6
  31. #define EXECUTEWRITECOPY 7
  32. #define MAXPROTECT 8
  33. typedef struct _MODINFO {
  34. PVOID BaseAddress;
  35. ULONG_PTR VirtualSize;
  36. PUNICODE_STRING InstanceName;
  37. PUNICODE_STRING LongInstanceName;
  38. ULONG_PTR TotalCommit;
  39. ULONG_PTR CommitVector[MAXPROTECT];
  40. struct _MODINFO *pNextModule;
  41. } MODINFO, *PMODINFO;
  42. typedef struct _PROCESS_VA_INFO {
  43. PUNICODE_STRING pProcessName;
  44. HANDLE hProcess;
  45. ULONG_PTR dwProcessId;
  46. // process VA information
  47. PPROCESS_BASIC_INFORMATION BasicInfo;
  48. // process VA statistics
  49. ULONG_PTR ImageReservedBytes;
  50. ULONG_PTR ImageFreeBytes;
  51. ULONG_PTR ReservedBytes;
  52. ULONG_PTR FreeBytes;
  53. ULONG_PTR MappedGuard;
  54. ULONG_PTR MappedCommit[MAXPROTECT];
  55. ULONG_PTR PrivateGuard;
  56. ULONG_PTR PrivateCommit[MAXPROTECT];
  57. // process image statistics
  58. PMODINFO pMemBlockInfo; // pointer to image list
  59. MODINFO OrphanTotals; // blocks with no image
  60. MODINFO MemTotals; // sum of image data
  61. DWORD LookUpTime;
  62. struct _PROCESS_VA_INFO *pNextProcess;
  63. } PROCESS_VA_INFO, *PPROCESS_VA_INFO;
  64. extern PPROCESS_VA_INFO pProcessVaInfo; // list head
  65. extern const WCHAR IDLE_PROCESS[];
  66. extern const WCHAR SYSTEM_PROCESS[];
  67. extern PUNICODE_STRING pusLocalProcessNameBuffer;
  68. extern HANDLE hEventLog; // handle to event log
  69. extern HANDLE hLibHeap; // local heap
  70. extern LPWSTR wszTotal;
  71. extern LPBYTE pProcessBuffer;
  72. extern LARGE_INTEGER PerfTime;
  73. PM_LOCAL_COLLECT_PROC CollectProcessObjectData;
  74. PM_LOCAL_COLLECT_PROC CollectThreadObjectData;
  75. PM_LOCAL_COLLECT_PROC CollectHeapObjectData;
  76. PM_LOCAL_COLLECT_PROC CollectExProcessObjectData;
  77. PM_LOCAL_COLLECT_PROC CollectImageObjectData;
  78. PM_LOCAL_COLLECT_PROC CollectLongImageObjectData;
  79. PM_LOCAL_COLLECT_PROC CollectThreadDetailsObjectData;
  80. PM_LOCAL_COLLECT_PROC CollectJobObjectData;
  81. PM_LOCAL_COLLECT_PROC CollectJobDetailData;
  82. PUNICODE_STRING
  83. GetProcessShortName (
  84. PSYSTEM_PROCESS_INFORMATION pProcess
  85. );
  86. PUNICODE_STRING
  87. GetProcessSlowName (
  88. PSYSTEM_PROCESS_INFORMATION pProcess
  89. );
  90. BOOL
  91. GetProcessExeName(
  92. HANDLE hProcessID,
  93. PUNICODE_STRING pusName
  94. );
  95. PPROCESS_VA_INFO
  96. GetSystemVaData (
  97. IN PSYSTEM_PROCESS_INFORMATION
  98. );
  99. BOOL
  100. FreeSystemVaData (
  101. IN PPROCESS_VA_INFO
  102. );
  103. ULONG
  104. PerfIntegerToWString(
  105. IN ULONG Value,
  106. IN ULONG Base,
  107. IN LONG OutputLength,
  108. OUT LPWSTR String
  109. );