Leaked source code of windows server 2003
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.

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