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.

653 lines
39 KiB

  1. /*======================================================================================//
  2. | Windows 2000 Process Control //
  3. | //
  4. |Copyright (c) 1998, 1999 Sequent Computer Systems, Incorporated. All rights reserved //
  5. | //
  6. |File Name: ProcConAPI.h //
  7. | //
  8. |Description: This is the ProcCon header file used by both clients and servers //
  9. | //
  10. |Created: Jarl McDonald 07-98 //
  11. | //
  12. |Rev History: //
  13. | //
  14. |=======================================================================================*/
  15. #ifndef _PROCCONAPI_H_
  16. #define _PROCCONAPI_H_
  17. #include "ProcConLibMsg.h" // ProcCon error codes
  18. #define PCERROR_SUCCESS ERROR_SUCCESS // ProcCon non-error error code
  19. //--------------------------------------------------------------------------------------//
  20. // Consts, typedefs, enums, etc. //
  21. //--------------------------------------------------------------------------------------//
  22. #define PC_MIN_BUF_SIZE 2048
  23. #define PC_MAX_BUF_SIZE 65536
  24. #define PC_MAX_RETRIES 5 // max retries on communications error
  25. #define PC_MIN_POLL_DELAY 2 // seconds
  26. #define PC_MAX_POLL_DELAY 900 // seconds
  27. #define PC_MIN_TIMEOUT 100 // milliseconds: 100 = one-tenth second
  28. #define PC_MAX_TIMEOUT 120000 // milliseconds: 120000 = 120 seconds == 2 minutes
  29. #define PC_MIN_TIME_LIMIT 10000000 // CNS - hundred nano-seconds: 10,000,000 = 1 second
  30. //--------------------------------------------------------------------------------------//
  31. // These are the types of name rule matches allowed. //
  32. // These values appear in the match type field of a name rule and may be either case. //
  33. //--------------------------------------------------------------------------------------//
  34. const WCHAR MATCH_PGM = TEXT('P');
  35. const WCHAR MATCH_DIR = TEXT('D');
  36. const WCHAR MATCH_ANY = TEXT('A');
  37. //--------------------------------------------------------------------------------------//
  38. // These strings are patterns that may appear in the process name field of a name rule. //
  39. // Example: match type is 'D', match string is 'system32', proc name is 'S32:<p>'... //
  40. // For program mmc.exe, which has \system32\ in its exe path, will be listed //
  41. // in ProcCon with a process name of S32:mmc //
  42. // Example: match type is 'A', match string is '%systemroot%', proc name is '<H>'... //
  43. // Any program which has the system root directory as part of its path name //
  44. // will not appear (is hidden) in ProcCon process lists. //
  45. //--------------------------------------------------------------------------------------//
  46. #define COPY_PGM_NAME TEXT("<P>") // replace this pattern with the exe name (all match types)
  47. #define COPY_DIR_NAME TEXT("<D>") // replace this patter with the node name (DIR match only)
  48. #define HIDE_THIS_PROC TEXT("<H>") // hide this process -- useful to hide std Win2000 procs.
  49. const int PROC_NAME_LEN = 63; // does not include terminating NULL
  50. const int PROFILE_NAME_LEN = 15; // does not include terminating NULL
  51. const int JOB_NAME_LEN = 63; // does not include terminating NULL
  52. const int MATCH_STRING_LEN = 63; // does not include terminating NULL
  53. const int NAME_DESCRIPTION_LEN = 63; // does not include terminating NULL
  54. const int RULE_DESCRIPTION_LEN = 63; // does not include terminating NULL
  55. const int IMAGE_NAME_LEN = 63; // does not include terminating NULL
  56. const int VERSION_STRING_LEN = 23; // does not include terminating NULL
  57. typedef unsigned char BYTE;
  58. typedef unsigned __int16 PCUSHORT16;
  59. typedef unsigned __int32 PCUINT32;
  60. typedef unsigned long PCULONG32;
  61. typedef unsigned __int64 PCUINT64;
  62. typedef __int16 PCINT16;
  63. typedef __int32 PCINT32;
  64. typedef __int64 PCINT64;
  65. typedef unsigned __int32 PC_MGMT_FLAGS;
  66. typedef unsigned __int32 PC_LIST_FLAGS;
  67. typedef unsigned __int64 AFFINITY; // Rightmost (least significant) bit = proc 0
  68. typedef unsigned __int32 PRIORITY; // Valid values are shown in PCPriorities enum below
  69. typedef unsigned __int32 SCHEDULING_CLASS; // Valid values are 0-9
  70. typedef unsigned __int32 PROC_COUNT;
  71. typedef unsigned __int64 MEMORY_VALUE;
  72. typedef unsigned __int64 PID_VALUE;
  73. typedef unsigned __int16 MATCH_TYPE;
  74. typedef __int64 TIME_VALUE;
  75. typedef __int32 PCid;
  76. typedef WCHAR MATCH_STRING[MATCH_STRING_LEN + 1];
  77. typedef WCHAR PROC_NAME[PROC_NAME_LEN + 1];
  78. typedef WCHAR PROFILE_NAME[PROFILE_NAME_LEN + 1];
  79. typedef WCHAR JOB_NAME[JOB_NAME_LEN + 1];
  80. typedef WCHAR IMAGE_NAME[IMAGE_NAME_LEN + 1];
  81. typedef WCHAR NAME_DESCRIPTION[NAME_DESCRIPTION_LEN + 1];
  82. typedef WCHAR RULE_DESCRIPTION[RULE_DESCRIPTION_LEN + 1];
  83. typedef WCHAR VERSION_STRING[VERSION_STRING_LEN + 1];
  84. typedef struct _PCSystemParms {
  85. PCINT32 manageIntervalSeconds; // ProcCon process scan interval in seconds (Read and Write)
  86. PCINT32 numberOfProcessors; // System number of processors (Read only)
  87. PCINT32 memoryPageSize; // System memory page size (Read only)
  88. PCINT32 timeoutValueMs; // Connect and request time out in milliseconds (Read and Write)
  89. AFFINITY processorMask; // System processor mask (Read only)
  90. PCINT32 future[16];
  91. } PCSystemParms;
  92. typedef struct _PCSystemInfo {
  93. PCINT32 fixedSignature;
  94. PCINT32 fixedFileVersionMS;
  95. PCINT32 fixedFileVersionLS;
  96. PCINT32 fixedProductVersionMS;
  97. PCINT32 fixedProductVersionLS;
  98. PCINT32 fixedFileFlags;
  99. PCINT32 fixedFileOS;
  100. PCINT32 fixedFileType;
  101. PCINT32 fixedFileSubtype;
  102. PCINT32 fixedFileDateMS;
  103. PCINT32 fixedFileDateLS;
  104. VERSION_STRING productVersion; // Service product version
  105. VERSION_STRING fileVersion; // Service file version
  106. VERSION_STRING fileFlags; // Service file flags
  107. VERSION_STRING medProductVersion; // Mediator product version
  108. VERSION_STRING medFileVersion; // Mediator file version
  109. VERSION_STRING medFileFlags; // Mediator file flags
  110. PCINT32 future[32];
  111. PCSystemParms sysParms;
  112. } PCSystemInfo;
  113. //--------------------------------------------------------------------------//
  114. // A name table entry that defines a process name.
  115. // Names are derived by matching against a processes path name or exe name.
  116. //
  117. // Match type denotes the method used to test for a match:
  118. // MATCH_PGM matches against the program (or exe) name excluding the suffix.
  119. // Program name matches always start at the first character of the program name and
  120. // are equvalent to 'matches full program name' matching.
  121. //
  122. // MATCH_DIR matches against the directory (path) node names.
  123. // A 'path node name' is any name before a backslash ('\') in the full path name.
  124. // Directory name matches always start at the first character of a path node name and
  125. // are equvalent to 'matches a full path node name' matching.
  126. //
  127. // MATCH_ANY matches against any part of the full name including the path and exe name.
  128. // This form of matching is a string match against any position in the name and is
  129. // equivalent to 'path name contains' matching.
  130. //
  131. // A matchString may contain wildcard characters as follows:
  132. // ? to match any single character,
  133. // * to match any number of trailing characters.
  134. // ProcCon does NOT support embedded * wildcards -- they will be treated literally.
  135. //
  136. // A procName may contain one of the patterns shown above such as <P> or <h>.
  137. //
  138. typedef struct _PCNameRule {
  139. #pragma pack(1)
  140. MATCH_STRING matchString; // match string may include * and ? wildcard characters.
  141. PROC_NAME procName; // process name to use when match succeeds.
  142. NAME_DESCRIPTION description; // short description with NULL terminator
  143. MATCH_TYPE matchType; // value is MATCH_PGM, MATCH_DIR, or MATCH_ANY.
  144. BYTE fill[2]; // Improve alignment of entire structure
  145. #pragma pack()
  146. } PCNameRule;
  147. //--------------------------------------------------------------------------//
  148. // The parameters that defined process group or process behavior and that can be changed by ProcCon.
  149. // Profile refers to a profile defined in ProcCon as a time of day/week/month/etc.
  150. typedef struct _MGMT_PARMS {
  151. #pragma pack(1)
  152. PROFILE_NAME profileName; // Definition is for this profile or, if null, default profile
  153. RULE_DESCRIPTION description; // Description text for this rule
  154. PC_MGMT_FLAGS mFlags; // Flags indicating which mgmt data to actually apply, etc.
  155. AFFINITY affinity; // processor affinity to apply (0 => not changed)
  156. PRIORITY priority; // Windows 2000 priority to apply (0 => not changed)
  157. MEMORY_VALUE minWS; // Minimum working set to apply (0 => not changed)
  158. MEMORY_VALUE maxWS; // Maximum working set to apply (0 => not changed)
  159. SCHEDULING_CLASS schedClass; // Scheduling class to apply (groups only, not procs)
  160. PROC_COUNT procCountLimit; // Number of processes in the process group (groups only).
  161. TIME_VALUE procTimeLimitCNS; // Per process time limit in 100ns (CNS) units or 0.
  162. TIME_VALUE jobTimeLimitCNS; // Per process group time limit in 100ns (CNS) units or 0.
  163. MEMORY_VALUE procMemoryLimit; // Hard memory commit limit per process (groups only).
  164. MEMORY_VALUE jobMemoryLimit; // Hard memory commit limit per process group (groups only).
  165. BYTE future[64];
  166. #pragma pack()
  167. } MGMT_PARMS;
  168. //--------------------------------------------------------------------------//
  169. // The statistics associated with a process group. These are read-only values.
  170. // All these statistics are maintained by Windows 2000 and are part of process group object accounting.
  171. typedef struct _JOB_STATISTICS {
  172. #pragma pack(1)
  173. TIME_VALUE TotalUserTime; // User time for all procs ever run in the process group
  174. TIME_VALUE TotalKernelTime; // Kernel time for all procs ever run in the process group
  175. TIME_VALUE ThisPeriodTotalUserTime; // User time for all procs ever run in the process group since limit last set
  176. TIME_VALUE ThisPeriodTotalKernelTime; // Kernel time for all procs ever run in the process group since limit last set
  177. PCUINT32 TotalPageFaultCount; // Page fault count for all procs ever run in the process group
  178. PROC_COUNT TotalProcesses; // Number of processes ever run or attempted in this process group
  179. PROC_COUNT ActiveProcesses; // Number of processes currently running in this process group (may be 0)
  180. PROC_COUNT TotalTerminatedProcesses; // Number of processes terminated for a limit violation
  181. PCUINT64 ReadOperationCount; // Read count for all procs ever in the process group
  182. PCUINT64 WriteOperationCount; // Write count for all procs ever in the process group
  183. PCUINT64 OtherOperationCount; // Other I/O count for all procs ever in the process group
  184. PCUINT64 ReadTransferCount; // Read byte count for all procs ever in the process group
  185. PCUINT64 WriteTransferCount; // Write byte count for all procs ever in the process group
  186. PCUINT64 OtherTransferCount; // Other I/O byte count for all procs ever in the process group
  187. MEMORY_VALUE PeakProcessMemoryUsed; // Largest process memory used by any process ever in the process group
  188. MEMORY_VALUE PeakJobMemoryUsed; // Largest process group memory ever used
  189. #pragma pack()
  190. } JOB_STATISTICS;
  191. //--------------------------------------------------------------------------//
  192. // The statistics associated with a process. These are read-only values.
  193. // Additional stats could be obtained via the PerfMon interface but that is
  194. // currently beyond the scope of ProcCon.
  195. // Identifying a particular process within ProcCon is done via both the pid and create time.
  196. typedef struct _PROC_STATISTICS {
  197. #pragma pack(1)
  198. PID_VALUE pid; // process PID (or 0 if not running)
  199. TIME_VALUE createTime; // to uniquely identify with pid (if running)
  200. TIME_VALUE TotalUserTime; // Total user time assigned to the proc
  201. TIME_VALUE TotalKernelTime; // Total kernel time assigned to the proc
  202. #pragma pack()
  203. } PROC_STATISTICS;
  204. //--------------------------------------------------------------------------//
  205. // Summary data about a process definition.
  206. // Summary data includes the name, process group membership, and process management rules.
  207. typedef struct _PCProcSummary {
  208. #pragma pack(1)
  209. PROC_NAME procName;
  210. JOB_NAME memberOfJobName; // member of this process group or null
  211. MGMT_PARMS mgmtParms;
  212. BYTE future[16];
  213. #pragma pack()
  214. } PCProcSummary;
  215. //--------------------------------------------------------------------------//
  216. // Summary data about a process group definition.
  217. // Summary data includes the name and process group management rules.
  218. typedef struct _PCJobSummary {
  219. #pragma pack(1)
  220. JOB_NAME jobName;
  221. MGMT_PARMS mgmtParms;
  222. BYTE future[16];
  223. #pragma pack()
  224. } PCJobSummary;
  225. //--------------------------------------------------------------------------//
  226. // Detail data about a process definition.
  227. // Detail data consists of the summary data and a block of variable length character data.
  228. typedef struct _PCProcDetail {
  229. #pragma pack(1)
  230. PCProcSummary base;
  231. WCHAR future[64];
  232. PCINT16 vLength; // length of the variable portion which follows, in bytes
  233. WCHAR vData[2]; // variable length portion
  234. #pragma pack()
  235. } PCProcDetail;
  236. //--------------------------------------------------------------------------//
  237. // Detail data about a process group definition.
  238. // Detail data consists of the summary data and a block of variable length character data.
  239. typedef struct _PCJobDetail {
  240. #pragma pack(1)
  241. PCJobSummary base;
  242. WCHAR future[64];
  243. PCINT16 vLength; // length of the variable portion which follows, in bytes
  244. WCHAR vData[2]; // variable length portion
  245. #pragma pack()
  246. } PCJobDetail;
  247. //--------------------------------------------------------------------------//
  248. // A process group list entry.
  249. // The process group list consists of all groups that are currently defined, named in a
  250. // process definition, or are running. (Any process group that has or may need a definition).
  251. typedef struct _PCJobListItem {
  252. #pragma pack(1)
  253. JOB_NAME jobName;
  254. PC_LIST_FLAGS lFlags; // shows where found, running or not, etc.
  255. PRIORITY actualPriority; // actual base priority (if running)
  256. AFFINITY actualAffinity; // actual affinity mask (if running)
  257. SCHEDULING_CLASS actualSchedClass; // actual scheduling class (if running)
  258. JOB_STATISTICS jobStats; // process group statistics (if running)
  259. #pragma pack()
  260. } PCJobListItem;
  261. //--------------------------------------------------------------------------//
  262. // A process list entry.
  263. // The process list consists of all processes that are currently defined, named in a
  264. // name rule, or are running. (Any process that has or may need a definition).
  265. typedef struct _PCProcListItem {
  266. #pragma pack(1)
  267. PROC_NAME procName; // PC assigned process name
  268. PC_LIST_FLAGS lFlags; // shows where found, running or not, etc.
  269. PRIORITY actualPriority; // actual base priority (if running)
  270. AFFINITY actualAffinity; // actual affinity mask (if running)
  271. PROC_STATISTICS procStats; // process statistics (if running)
  272. IMAGE_NAME imageName; // Windows 2000 'image' (exe) name (if running)
  273. JOB_NAME jobName; // If 'in a process group' flagged, name of group
  274. #pragma pack()
  275. } PCProcListItem;
  276. //--------------------------------------------------------------------------//
  277. typedef enum _PCPriorities {
  278. PCPrioRealTime = 24,
  279. PCPrioHigh = 13,
  280. PCPrioAboveNormal = 10,
  281. PCPrioNormal = 8,
  282. PCPrioBelowNormal = 6,
  283. PCPrioIdle = 4,
  284. } PCPriorities;
  285. // List response flags -- present in lists only -- not stored as part of any data.
  286. typedef enum _PCListRspFlags {
  287. PCLFLAG_IS_RUNNING = 0x00800000, // Name (process group or process) is currently running.
  288. PCLFLAG_IS_DEFINED = 0x00400000, // Name has a definition in ProcCon (but may not request mgmt).
  289. PCLFLAG_IS_MANAGED = 0x00200000, // Name has at least one management behavior requested.
  290. PCLFLAG_IS_IN_A_JOB = 0x00100000, // Process is assigned to a process group.
  291. PCLFLAG_HAS_NAME_RULE = 0x00080000, // Name appears in a name rule as process name.
  292. PCLFLAG_HAS_MEMBER_OF_JOB = 0x00040000, // Name appears in a process def as "member of process group".
  293. } PCListRspFlags;
  294. // List request flags -- used with flags argument to PCGetProcList and PCGetJobList.
  295. typedef enum _PCListReqFlags {
  296. PC_LIST_ONLY_RUNNING = 0x00000001, // restrict list to only procs or groups that are running
  297. PC_LIST_STARTING_WITH = 0x00000002, // ON = start list with supplied entry or higher (grpname or procname+pid),
  298. // OFF = start with following entry (used for list continuation)
  299. PC_LIST_MEMBERS_OF = 0x00000004, // ON = list only processes that are members of named group,
  300. // (other flags still apply).
  301. // OFF = list all items (subject to other flags).
  302. PC_LIST_MATCH_ONLY = 0x00000008, // ON = list matching entries only (grp name or proc name+pid).
  303. } PCListReqFlags;
  304. // Management flags -- part of MGMT_PARMS, stored with process/profile data.
  305. // The 'no rules' and 'bad rules' bits will only be set if there are database errors (missing
  306. // or invalid data). Not stored with data but set if data cannot be read or decoded.
  307. //
  308. // The 'apply' bits are set or cleared by clients to control the use of the related management
  309. // setting. This way the management setting can be left intact even when not being used.
  310. //
  311. // Note that the process group name is not part of the MGMT_PARMS structure while the 'apply' flag for it
  312. // DOES appears in MGMT_PARMS. This is a reflection of the fact that while process group name IS part of
  313. // the management data, it cannot be varied by profile since Windows 2000 does not support changes to
  314. // process group membership on the fly at present. So the process group name is moved out of the
  315. // management parms to show that it is not part of the profile-dependent data.
  316. typedef enum _PCMgmtFlags {
  317. PCMFLAG_NORULES = 0x80000000, // No profile or default rules found (not managed)
  318. PCMFLAG_BADRULES = 0x40000000, // Rules found but could not be used (bad data)
  319. PCMFLAG_PROC_HAS_JOB_REFERENCE = 0x08000000, // Process definition includes a process group name
  320. PCMFLAG_SET_PROC_BREAKAWAY_OK = 0x00080000, // Procs can be created outside process group if requested (groups only).
  321. PCMFLAG_SET_SILENT_BREAKAWAY = 0x00040000, // All procs are created outside process group (groups only)
  322. PCMFLAG_SET_DIE_ON_UH_EXCEPTION = 0x00020000, // Die on unhandled exception flag = no GPF msg box (groups only)
  323. PCMFLAG_MSG_ON_JOB_TIME_LIMIT_HIT = 0x00008000, // Hitting process group time limit = logmsg, else fail group (groups only)
  324. PCMFLAG_END_JOB_WHEN_EMPTY = 0x00004000, // Process group is terminated (closed) when empty (groups only)
  325. PCMFLAG_APPLY_JOB_MEMBERSHIP = 0x00000800, // Apply 'member of process group' attribute if supplied
  326. PCMFLAG_APPLY_PROC_MEMORY_LIMIT = 0x00000200, // Apply hard per-proc memory limit (groups only)
  327. PCMFLAG_APPLY_JOB_MEMORY_LIMIT = 0x00000100, // Apply hard per-group memory limit (groups only)
  328. PCMFLAG_APPLY_AFFINITY = 0x00000080, // Apply affinity settings if supplied
  329. PCMFLAG_APPLY_PRIORITY = 0x00000040, // Apply priority settings if supplied
  330. PCMFLAG_APPLY_WS_MINMAX = 0x00000020, // Apply working set min & max if supplied
  331. PCMFLAG_APPLY_SCHEDULING_CLASS = 0x00000010, // Apply scheduling class if supplied (groups only)
  332. PCMFLAG_APPLY_JOB_TIME_LIMIT = 0x00000008, // Apply process group time limit if supplied (groups only)
  333. PCMFLAG_APPLY_PROC_TIME_LIMIT = 0x00000004, // Apply proc time limit if supplied (groups only)
  334. PCMFLAG_APPLY_PROC_COUNT_LIMIT = 0x00000002, // Apply proc count limit if supplied (groups only)
  335. PCMFLAG_APPLY_ANY_RULE = 0x00000bfe, // Apply at least one management rule
  336. PCMFLAG_SAVEABLE_BITS = 0x000ecbfe, // Bits that can be stored in the database (avoid undefined bits)
  337. } PCMgmtFlags;
  338. // Control flags -- use with caution! Input to PCControlFunction.
  339. // These flags are for high-level (non user oriented) control operations.
  340. typedef enum _PCCtlFlags {
  341. PCCFLAG_START_MEDIATOR = 0x40000000, // Attempt to start the mediator process
  342. PCCFLAG_STOP_MEDIATOR = 0x20000000, // Attempt to stop the mediator process
  343. PCCFLAG_DELALL_NAME_RULES = 0x00400000, // Delete all name rules from DB
  344. PCCFLAG_DELALL_PROC_DEFS = 0x00200000, // Delete all process definitions from DB
  345. PCCFLAG_DELALL_JOB_DEFS = 0x00100000, // Delete all process group definitions from DB
  346. PCCFLAG_SIGNATURE = 0x80070002, // These bits must be on in all valid flags
  347. PCCFLAG_ANTI_SIGNATURE = 0x0c0000c0, // These bits must be off in all valid flags
  348. } PCCtlFlags;
  349. //--------------------------------------------------------------------------------------//
  350. // API function prototypes //
  351. //--------------------------------------------------------------------------------------//
  352. //--------------------------------------------------------------------------------------
  353. // Infrastructure and Utility Functions...
  354. // PCOpen -- establish connection to PC on named machine.
  355. // Returns: PCid to use with future PC calls or 0 on error (use PCGetLastError).
  356. // Arguments: 0) pointer to target computer name,
  357. // 1) buffer to be used in server communication or NULL (library allocates).
  358. // 2) size of buffer supplied or to be allocated in bytes.
  359. PCid PCOpen( const WCHAR *targetComputer, char *buffer, PCUINT32 bufSize );
  360. // PCClose -- break connection to PC on previously connected machine.
  361. // Returns: TRUE on success.
  362. // FALSE on failure, use PCGetLastError.
  363. // Arguments: 0) PCid from PCOpen,
  364. BOOL PCClose( PCid target );
  365. // PCGetLastError -- return last error reported for a target
  366. // Returns: last PC API error for this client.
  367. // Arguments: 0) PCid from PCOpen,
  368. PCULONG32 PCGetLastError( PCid target );
  369. // PCGetServiceInfo -- get ProcCon Service indentification and parameters.
  370. // Returns: TRUE on success.
  371. // FALSE on failure, use PCGetLastError.
  372. // Arguments: 0) PCid from PCOpen,
  373. // 1) pointer to area to receive system information,
  374. // 2) size of this area in bytes,
  375. BOOL PCGetServiceInfo( PCid target, PCSystemInfo *sysInfo, PCINT32 nByteCount );
  376. // PCSetServiceParms -- set ProcCon Service parameters.
  377. // Returns: TRUE on success.
  378. // FALSE on failure, use PCGetLastError.
  379. // Arguments: 0) PCid from PCOpen,
  380. // 1) pointer to area containing new system parameters,
  381. // 2) size of this area in bytes,
  382. BOOL PCSetServiceParms( PCid target, PCSystemParms *sysParms, PCINT32 nByteCount );
  383. // PCControlFunction -- various ProcCon control functions to support restore, etc.
  384. // Returns: TRUE on success.
  385. // FALSE on failure, use PCGetLastError.
  386. // Arguments: 0) PCid from PCOpen,
  387. // 1) control flags to describe desired control functions,
  388. // 2) [optional] data that modifies control function.
  389. BOOL PCControlFunction( PCid target, PCINT32 ctlFlags, PCINT32 ctlData = 0 );
  390. // PCKillProcess -- kill the specified process
  391. // Returns: TRUE on success.
  392. // FALSE on failure, use PCGetLastError.
  393. // Arguments: 0) PCid from PCOpen,
  394. // 1) Pid of the process to kill from PCGetProcList statistics,
  395. // 2) Create time of the process to kill from PCGetProcList statistics.
  396. BOOL PCKillProcess( PCid target, PID_VALUE processPid, TIME_VALUE createTime );
  397. // PCKillJob -- kill the specified process group (job)
  398. // Returns: TRUE on success.
  399. // FALSE on failure, use PCGetLastError.
  400. // Arguments: 0) PCid from PCOpen,
  401. // 1) Name of the process group to kill.
  402. BOOL PCKillJob( PCid target, JOB_NAME jobName );
  403. //--------------------------------------------------------------------------------------
  404. // General Retrieval Functions...
  405. // PCGetNameRules -- get fixed-format table containing name rules, one entry per rule.
  406. // Returns: 1 or greater to indicate the number of items in the response (may be incomplete).
  407. // -1 on failure, use PCGetLastError.
  408. // Arguments: 0) PCid from PCOpen,
  409. // 1) pointer to table to receive name rule list,
  410. // 2) size of this table in bytes,
  411. // 3) [optional, default is 0] index of first entry to return (0-relative),
  412. // 4) [optional] location to store update counter to be supplied on update.
  413. // Notes: If PCGetLastError returns PCERROR_MORE_DATA, there is more data to retrieve.
  414. // Name rule order is significant: rules are executed from top to bottom.
  415. PCINT32 PCGetNameRules( PCid target, PCNameRule *pRuleList, PCINT32 nByteCount,
  416. PCINT32 nFirst = 0, PCINT32 *nUpdateCtr = NULL );
  417. // PCGetProcSummary -- get fixed-format table summarizing all defined processes.
  418. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  419. // -1 on failure, use PCGetLastError.
  420. // Arguments: 0) PCid from PCOpen,
  421. // 1) pointer to table to receive rule summary list, first entry indicates start point,
  422. // 2) size of this table in bytes.
  423. // 3) a set of flags used to further specify or limit list operation.
  424. // Notes: If PCGetLastError returns PCERROR_MORE_DATA, there is more data to retrieve.
  425. // List entries are in alphabetic order by process name.
  426. PCINT32 PCGetProcSummary( PCid target, PCProcSummary *pProcList, PCINT32 nByteCount,
  427. PCUINT32 listFlags = 0 );
  428. // PCGetJobSummary -- get fixed-format table summarizing all defined process groups.
  429. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  430. // -1 on failure, use PCGetLastError.
  431. // Arguments: 0) PCid from PCOpen,
  432. // 1) pointer to table to receive rule summary list, first entry indicates start point,
  433. // 2) size of this table in bytes.
  434. // 3) a set of flags used to further specify or limit list operation.
  435. // Notes: If PCGetLastError returns PCERROR_MORE_DATA, there is more data to retrieve.
  436. // List entries are in alphabetic order by process group name.
  437. PCINT32 PCGetJobSummary( PCid target, PCJobSummary *pJobList, PCINT32 nByteCount,
  438. PCUINT32 listFlags = 0 );
  439. // PCGetJobList -- get list of all defined process groups, both running and not.
  440. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  441. // -1 on failure, use PCGetLastError.
  442. // Arguments: 0) PCid from PCOpen,
  443. // 1) pointer to structure to receive process group list,
  444. // 2) size of this structure in bytes.
  445. // 3) a set of flags used to further specify or limit list operation.
  446. // Notes: If PCGetLastError returns PCERROR_MORE_DATA, there is more data to retrieve.
  447. // List entries are in alphabetic order by process group name.
  448. PCINT32 PCGetJobList( PCid target, PCJobListItem *pJobList, PCINT32 nByteCount,
  449. PCUINT32 listFlags = 0 );
  450. // PCGetProcList -- get list of all defined process names, both running and not.
  451. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  452. // -1 on failure, use PCGetLastError.
  453. // Arguments: 0) PCid from PCOpen,
  454. // 1) pointer to structure to receive process list,
  455. // 2) size of this structure in bytes.
  456. // 3) a set of flags used to further specify or limit list operation.
  457. // Notes: If PCGetLastError returns PCERROR_MORE_DATA, there is more data to retrieve.
  458. // List entries are in alphabetic order by process name.
  459. PCINT32 PCGetProcList( PCid target, PCProcListItem *pProcList, PCINT32 nByteCount,
  460. PCUINT32 listFlags = 0 );
  461. // PCGetProcDetail -- get full management and descriptive data associated with a process name.
  462. // Returns: TRUE on success.
  463. // FALSE on failure, use PCGetLastError.
  464. // Arguments: 0) PCid from PCOpen,
  465. // 1) pointer to structure to receive process data,
  466. // 2) size of this structure in bytes,
  467. // 3) [optional] location to store update counter to be supplied on update.
  468. // Note: If the process is a member of a process group, the group's management rules will be
  469. // used instead of the process rules unless the process group definition is missing.
  470. BOOL PCGetProcDetail( PCid target, PCProcDetail *pProcDetail, PCINT32 nByteCount, PCINT32 *nUpdateCtr = NULL );
  471. // PCGetJobDetail -- get full management and descriptive data associated with a process group name.
  472. // Returns: TRUE on success.
  473. // FALSE on failure, use PCGetLastError.
  474. // Arguments: 0) PCid from PCOpen,
  475. // 1) pointer to structure to receive process group data,
  476. // 2) size of this structure in bytes,
  477. // 3) [optional] location to store update counter to be supplied on update.
  478. BOOL PCGetJobDetail( PCid target, PCJobDetail *pJobDetail, PCINT32 nByteCount, PCINT32 *nUpdateCtr = NULL );
  479. //--------------------------------------------------------------------------------------
  480. // Name Rule Update Functions...
  481. // PCAddNameRule -- add a name rule to the name rule table.
  482. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  483. // -1 on failure, use PCGetLastError.
  484. // Arguments: 0) PCid from PCOpen,
  485. // 1) pointer to name rule to add,
  486. // 2) index of name rule line BEFORE which this addition is to occur (0-based),
  487. // 3) update counter returned from PCGetNameRules,
  488. // 4-7) [optional] same args as PCGetNameRules to return updated name rule table.
  489. // Note: If also retrieving list, PCGetLastError returns PCERROR_MORE_DATA if there is
  490. // more data to retrieve. List entries are in alphabetic order by process name.
  491. PCINT32 PCAddNameRule( PCid target, PCNameRule *pRule, PCINT32 nIndex, PCINT32 nUpdateCtr,
  492. PCNameRule *pRuleList = NULL, PCINT32 nByteCount = 0,
  493. PCINT32 nFirst = 0, PCINT32 *nNewUpdateCtr = NULL );
  494. // PCReplNameRule -- Replace a name rule in the name rule table.
  495. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  496. // -1 on failure, use PCGetLastError.
  497. // Arguments: 0) PCid from PCOpen,
  498. // 1) pointer to name rule replacement data,
  499. // 2) index of name rule line to replace (0-based),
  500. // 3) update counter returned from PCGetNameRules,
  501. // 4-7) [optional] same args as PCGetNameRules to return updated name rule table.
  502. // Note: If also retrieving list, PCGetLastError returns PCERROR_MORE_DATA if there is
  503. // more data to retrieve. List entries are in alphabetic order by process name.
  504. PCINT32 PCReplNameRule( PCid target, PCNameRule *pRule, PCINT32 nIndex, PCINT32 nUpdateCtr,
  505. PCNameRule *pRuleList = NULL, PCINT32 nByteCount = 0,
  506. PCINT32 nFirst = 0, PCINT32 *nNewUpdateCtr = NULL );
  507. // PCDeleteNameRule -- Delete a name rule from the name rule table.
  508. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  509. // -1 on failure, use PCGetLastError.
  510. // Arguments: 0) PCid from PCOpen,
  511. // 1) index of name rule line to delete (0-based),
  512. // 2) update counter returned from PCGetNameRules,
  513. // 3-6) [optional] same args as PCGetNameRules to return updated name rule table.
  514. // Note: If also retrieving list, PCGetLastError returns PCERROR_MORE_DATA if there is
  515. // more data to retrieve. List entries are in alphabetic order by process name.
  516. PCINT32 PCDeleteNameRule( PCid target, PCINT32 nIndex, PCINT32 nUpdateCtr,
  517. PCNameRule *pRuleList = NULL, PCINT32 nByteCount = 0,
  518. PCINT32 nFirst = 0, PCINT32 *nNewUpdateCtr = NULL );
  519. // PCSwapNameRules -- Swap the order of two adjacent entries in the name rule table.
  520. // Note: This API is needed because the order of entires in the table is significant.
  521. // Returns: 0 or greater to indicate the number of items in the response (may be incomplete).
  522. // -1 on failure, use PCGetLastError.
  523. // Arguments: 0) PCid from PCOpen,
  524. // 1) index of name rule line to swap with line index+1 (0-based),
  525. // 2) update counter returned from PCGetNameRules,
  526. // 3-5) [optional] same args as PCGetNameRules to return updated name rule table.
  527. // Note: If also retrieving list, PCGetLastError returns PCERROR_MORE_DATA if there is
  528. // more data to retrieve. List entries are in alphabetic order by process name.
  529. PCINT32 PCSwapNameRules( PCid target, PCINT32 nIndex, PCINT32 nUpdateCtr,
  530. PCNameRule *pRuleList = NULL, PCINT32 nByteCount = 0,
  531. PCINT32 nFirst = 0, PCINT32 *nNewUpdateCtr = NULL );
  532. //--------------------------------------------------------------------------------------
  533. // Process data Update Functions...
  534. // PCAddProcDetail -- add a new process definition to the process management database.
  535. // Returns: 1 on success (treat as TRUE or as a count if summary item requested).
  536. // FALSE on failure, use PCGetLastError.
  537. // Arguments: 0) PCid from PCOpen,
  538. // 1) pointer to process detail to add, name must not exist.
  539. // 2) [optional] pointer to buffer to retrieve updated proc summary for this entry.
  540. // Note: No update counter is needed for adding since add fails if the name
  541. // exists.
  542. BOOL PCAddProcDetail( PCid target, PCProcDetail *pProcDetail, PCProcSummary *pProcList = NULL );
  543. // PCDeleteProcDetail -- Delete a process definition from the process management database.
  544. // Returns: TRUE on success.
  545. // FALSE on failure, use PCGetLastError.
  546. // Arguments: 0) PCid from PCOpen,
  547. // 1) pointer to process detail to Delete, name must exist,
  548. // Notes: 1) No update counter is needed for deleting since delete fails if the name
  549. // doesn't exist.
  550. // 2) Since this is a delete operation, a complete PCProcDetail is not necessary.
  551. // The pointer may also point to a PCProcSummary item.
  552. BOOL PCDeleteProcDetail( PCid target, PCProcDetail *pProcDetail );
  553. // PCReplProcDetail -- Replace a process definition in the process management database.
  554. // Returns: 1 on success (treat as TRUE or as a count if summary item requested).
  555. // FALSE on failure, use PCGetLastError.
  556. // Arguments: 0) PCid from PCOpen,
  557. // 1) pointer to process detail to replace, name must exist,
  558. // 2) update counter from PCGetProcDetail.
  559. // 3) [optional] pointer to buffer to retrieve updated proc summary for this entry.
  560. BOOL PCReplProcDetail( PCid target, PCProcDetail *pProcDetail, PCINT32 nUpdateCtr,
  561. PCProcSummary *pProcList = NULL );
  562. //--------------------------------------------------------------------------------------
  563. // Process Group (Job) data Update Functions...
  564. // PCAddJobDetail -- add a new process group definition to the process group management database.
  565. // Returns: 1 on success (treat as TRUE or as a count if summary item requested).
  566. // FALSE on failure, use PCGetLastError.
  567. // Arguments: 0) PCid from PCOpen,
  568. // 1) pointer to process group detail to add, name must not exist,
  569. // 2) [optional] pointer to buffer to retrieve updated process group summary for this entry.
  570. // Note: No update counter is needed for adding since add fails if the name
  571. // exists.
  572. BOOL PCAddJobDetail( PCid target, PCJobDetail *pJobDetail, PCJobSummary *pJobList = NULL );
  573. // PCDeleteJobDetail -- Delete a process group definition from the process group management database.
  574. // Returns: TRUE on success.
  575. // FALSE on failure, use PCGetLastError.
  576. // Arguments: 0) PCid from PCOpen,
  577. // 1) pointer to process group detail to Delete, name must exist,
  578. // Notes: 1) No update counter is needed for deleting since delete fails if the name
  579. // doesn't exist.
  580. // 2) Since this is a delete operation, a complete PCJobDetail is not necessary.
  581. // The pointer may also point to a PCJobSummary item.
  582. BOOL PCDeleteJobDetail( PCid target, PCJobDetail *pJobDetail );
  583. // PCReplJobDetail -- Replace a process group definition in the process group management database.
  584. // Returns: 1 on success (treat as TRUE or as a count if summary item requested).
  585. // FALSE on failure, use PCGetLastError.
  586. // Arguments: 0) PCid from PCOpen,
  587. // 1) pointer to process group detail to replace, name must exist,
  588. // 2) update counter from PCGetJobDetail.
  589. // 3) [optional] pointer to buffer to retrieve updated process group summary for this entry.
  590. BOOL PCReplJobDetail( PCid target, PCJobDetail *pJobDetail, PCINT32 nUpdateCtr,
  591. PCJobSummary *pJobList = NULL );
  592. #endif // _PROCCONAPI_H_