source: trunk/include/helpers/procstat.h@ 245

Last change on this file since 245 was 240, checked in by umoeller, 23 years ago

Misc fixes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 31.8 KB
Line 
1
2/*
3 *@@sourcefile procstat.h:
4 * header file for procstat.c (querying process information).
5 * See remarks there.
6 *
7 * Note: Version numbering in this file relates to XWorkplace version
8 * numbering.
9 *
10 *@@include #include <os2.h>
11 *@@include #include "helpers\procstat.h"
12 */
13
14/*
15 * This file Copyright (C) 1992-99 Ulrich M”ller,
16 * Kai Uwe Rommel.
17 * This file is part of the "XWorkplace helpers" source package.
18 * This is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published
20 * by the Free Software Foundation, in version 2 as it comes in the
21 * "COPYING" file of the XWorkplace main distribution.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 */
27
28#if __cplusplus
29extern "C" {
30#endif
31
32#ifndef PROCSTAT_HEADER_INCLUDED
33 #define PROCSTAT_HEADER_INCLUDED
34
35 #pragma pack(1)
36
37 /********************************************************************
38 *
39 * DosQProcStatus declarations (16-bit)
40 *
41 ********************************************************************/
42
43 #define PTR(ptr, ofs) ((void *) ((char *) (ptr) + (ofs)))
44
45 /* DosQProcStatus() = DOSCALLS.154 */
46 USHORT APIENTRY16 DosQProcStatus(PVOID pBuf, USHORT cbBuf);
47 /* DosGetPrty = DOSCALLS.9 */
48 USHORT APIENTRY16 DosGetPrty(USHORT usScope, PUSHORT pusPriority, USHORT pid);
49
50 /*
51 *@@ QPROCSTAT16:
52 * "header" structure returned by DosQProcStat,
53 * containing the offsets to the other data
54 */
55
56 typedef struct _QPROCSTAT16
57 {
58 ULONG ulGlobal; // offset to global data section (QGLOBAL16)
59 ULONG ulProcesses; // offset to process data section (QPROCESS16)
60 ULONG ulSemaphores; // offset to semaphore data section
61 ULONG ulUnknown1;
62 ULONG ulSharedMem; // offset to shared mem data section
63 ULONG ulModules; // offset to DLL data section (QMODULE16)
64 ULONG ulUnknown2;
65 ULONG ulUnknown3;
66 } QPROCSTAT16, *PQPROCSTAT16;
67
68 /*
69 *@@ QGLOBAL16:
70 * at offset QPROCSTAT.ulGlobal, contains
71 * global system information (no. of threads)
72 */
73
74 typedef struct _QGLOBAL16
75 {
76 ULONG ulThreads; // total number of threads;
77 ULONG ulReserved1,
78 ulReserved2;
79 } QGLOBAL16, *PQGLOBAL16;
80
81 /*
82 *@@ QPROCESS16:
83 * DosQProcStat structure for process info
84 */
85
86 typedef struct _QPROCESS16
87 {
88 ULONG ulType; // 1 for processes
89 ULONG ulThreadList; // ofs to array of QTHREAD16 structs
90 USHORT usPID;
91 USHORT usParentPID;
92 ULONG ulSessionType;
93 // according to bsedos.h, the PROG_* types are identical
94 // to the SSF_TYPE_* types, so we have:
95 // -- PROG_DEFAULT 0
96 // -- PROG_FULLSCREEN 1
97 // -- PROG_WINDOWABLEVIO 2
98 // -- PROG_PM 3
99 // -- PROG_GROUP 5
100 // -- PROG_REAL 4
101 // -- PROG_VDM 4
102 // -- PROG_WINDOWEDVDM 7
103 // -- PROG_DLL 6
104 // -- PROG_PDD 8
105 // -- PROG_VDD 9
106 // -- PROG_WINDOW_REAL 10
107 // -- PROG_WINDOW_PROT 11
108 // -- PROG_30_STD 11
109 // -- PROG_WINDOW_AUTO 12
110 // -- PROG_SEAMLESSVDM 13
111 // -- PROG_30_STDSEAMLESSVDM 13
112 // -- PROG_SEAMLESSCOMMON 14
113 // -- PROG_30_STDSEAMLESSCOMMON 14
114 // -- PROG_31_STDSEAMLESSVDM 15
115 // -- PROG_31_STDSEAMLESSCOMMON 16
116 // -- PROG_31_ENHSEAMLESSVDM 17
117 // -- PROG_31_ENHSEAMLESSCOMMON 18
118 // -- PROG_31_ENH 19
119 // -- PROG_31_STD 20
120 // -- PROG_RESERVED 255
121 ULONG ulStatus; // see status #define's below
122 ULONG ulSID; // session (screen group) ID
123 USHORT usHModule; // program module handle for process
124 USHORT usThreads; // # of TCBs in use in process
125 ULONG ulReserved1;
126 ULONG ulReserved2;
127 USHORT usSemaphores; // # of 16-bit semaphores
128 USHORT usDLLs; // # of linked DLLs
129 USHORT usSharedMems;
130 USHORT usReserved3;
131 ULONG ulSemList; // offset to semaphore list
132 ULONG ulDLLList; // offset to DLL list
133 ULONG ulSharedMemList; // offset to shared mem list
134 ULONG ulReserved4;
135 } QPROCESS16, *PQPROCESS16;
136
137 // process status flags
138 #define STAT_EXITLIST 0x01 // processing exit list
139 #define STAT_EXIT1 0x02 // exiting thread 1
140 #define STAT_EXITALL 0x04 // whole process is exiting
141 #define STAT_PARSTAT 0x10 // parent cares about termination
142 #define STAT_SYNCH 0x20 // parent did exec-and-wait
143 #define STAT_DYING 0x40 // process is dying
144 #define STAT_EMBRYO 0x80 // process is in emryonic state
145
146 /*
147 *@@ QTHREAD16:
148 * DosQProcStat structure for thread info
149 */
150
151 typedef struct _QTHREAD16
152 {
153 ULONG ulType; // 0x100 for thread records
154 USHORT usTID; // thread ID
155 USHORT usThreadSlotID; // ???
156 ULONG ulBlockID; // sleep id thread is sleeping on
157 ULONG ulPriority;
158 ULONG ulSysTime;
159 ULONG ulUserTime;
160 UCHAR ucStatus; // TSTAT_* flags
161 UCHAR ucReserved1;
162 USHORT usReserved2;
163 } QTHREAD16, *PQTHREAD16;
164
165 // thread status flags
166 #define TSTAT_VOID 0 // uninitialized
167 #define TSTAT_READY 1 // ready to run (waiting for CPU time)
168 #define TSTAT_BLOCKED 2 // blocked on a block ID
169 #define TSTAT_SUSPENDED 3 // DosSuspendThread
170 #define TSTAT_CRITSEC 4 // blocked by another thread in a critical section
171 #define TSTAT_RUNNING 5 // currently running
172 #define TSTAT_READYBOOST 6 // ready, but apply I/O boost
173 #define TSTAT_TSD 7 // thead waiting for thread swappable data (TSD)
174 #define TSTAT_DELAYED 8 // delayed TKWakeup (almost ready)
175 #define TSTAT_FROZEN 9 // frozen (FF_ICE)
176 #define TSTAT_GETSTACK 10 // incoming thread swappable data (TSD)
177 #define TSTAT_BADSTACK 11 // TSD failed to swap in
178
179 /*
180 *@@ QMODULE16:
181 * DosQProcStat structure for module info
182 */
183
184 typedef struct _QMODULE16
185 {
186 ULONG nextmodule;
187 USHORT modhandle;
188 USHORT modtype;
189 ULONG submodules;
190 ULONG segments;
191 ULONG reserved;
192 ULONG namepointer;
193 USHORT submodule[1]; // varying, see member submodules */
194 } QMODULE16, *PQMODULE16;
195
196 /*
197 *@@ QSEMAPHORE16:
198 * DosQProcStat structure for semaphore info (16-bit only, I guess)
199 */
200
201 typedef struct _QSEMAPHORE16
202 {
203 ULONG nextsem;
204 USHORT owner;
205 UCHAR flag;
206 UCHAR refs;
207 UCHAR requests;
208 UCHAR reserved1;
209 USHORT reserved2;
210 USHORT index;
211 USHORT dummy;
212 UCHAR name[1]; /* varying */
213 } QSEMAPHORE16, *PQSEMAPHORE16;
214
215 /*
216 *@@ QSHAREDMEM16:
217 * DosQProcStat structure for shared memory info
218 */
219
220 typedef struct _QSHAREDMEM16
221 {
222 ULONG nextseg;
223 USHORT handle; // handle for shared memory
224 USHORT selector; // shared memory selector
225 USHORT refs; // reference count
226 UCHAR name[1]; // varying
227 } QSHAREDMEM16, *PQSHAREDMEM16;
228
229 /********************************************************************
230 *
231 * DosQuerySysState declarations (32-bit)
232 *
233 ********************************************************************/
234
235 // #pragma pack(1)
236 #pragma pack(4) // V0.9.10 (2001-04-08) [umoeller]
237
238 #define QS32_PROCESS 0x0001
239 #define QS32_SEMAPHORE 0x0002
240 #define QS32_MTE 0x0004
241 #define QS32_FILESYS 0x0008
242 #define QS32_SHMEMORY 0x0010
243 #define QS32_DISK 0x0020
244 #define QS32_HWCONFIG 0x0040
245 #define QS32_NAMEDPIPE 0x0080
246 #define QS32_THREAD 0x0100
247 #define QS32_MODVER 0x0200
248
249/*
250 #define QS32_SUPPORTED (QS32_PROCESS | QS32_SEMAPHORE | QS32_MTE | QS32_FILESYS \
251 | QS32_SHMEMORY | QS32_MODVER)
252 QS32_SEMAPHORE is broken V0.9.19 (2002-04-14) [pr]
253*/
254 #define QS32_SUPPORTED (QS32_PROCESS | QS32_MTE | QS32_FILESYS \
255 | QS32_SHMEMORY | QS32_MODVER)
256
257 APIRET APIENTRY DosQuerySysState(ULONG EntityList,
258 ULONG EntityLevel,
259 PID pid,
260 TID tid,
261 PVOID pDataBuf,
262 ULONG cbBuf);
263
264 /**********************
265 *
266 * global struct
267 *
268 **********************/
269
270 /*
271 *@@ QGLOBAL32:
272 * Pointed to by QTOPLEVEL32.
273 */
274
275 typedef struct _QGLOBAL32
276 {
277 ULONG ulThreadCount; // thread count
278 // ULONG ulProcCount; // process count wrong V1.0.1 (2003-01-10) [umoeller]
279 ULONG ulSem32Count; // count of 32-bit sems?
280 ULONG ulModuleCount; // module count
281 } QGLOBAL32, *PQGLOBAL32;
282
283 /**********************
284 *
285 * thread struct
286 *
287 **********************/
288
289 /*
290 *@@ QTHREAD32:
291 * Pointed to by QPROCESS32.
292 */
293
294 typedef struct _QTHREAD32
295 {
296 ULONG ulRecType; // 256 for thread
297 USHORT usTID; // thread ID, process-specific
298 USHORT usSlotID; // system-specific slot ID, this identifies the
299 // thread to the kernel
300 ULONG ulSleepID; // sleep ID the kernel uses for blocking threads
301 ULONG ulPriority; // priority flags
302 ULONG ulSystime; // CPU time spent in system code
303 ULONG ulUsertime; // CPU time spent in user code
304 UCHAR ucState; // one of the following:
305 // -- TSTAT_READY 1
306 // -- TSTAT_BLOCKED 2
307 // -- TSTAT_RUNNING 5
308 // -- TSTAT_LOADED 9
309 UCHAR _reserved1_; /* padding to ULONG */
310 USHORT _reserved2_; /* padding to ULONG */
311 } QTHREAD32, *PQTHREAD32;
312
313 /**********************
314 *
315 * open files
316 *
317 **********************/
318
319 // found the following in the "OS/2 Debugging handbook"
320 // (the identifiers are not official, but invented by
321 // me; V0.9.1 (2000-02-12) [umoeller]):
322 // these are the flags for QFDS32.flFlags
323 #define FSF_CONSOLEINPUT 0x0001 // bit 0
324 #define FSF_CONSOLEOUTPUT 0x0002 // bit 1
325 #define FSF_NULLDEVICE 0x0004 // bit 2
326 #define FSF_CLOCKDEVICE 0x0008 // bit 3
327 // #define FSF_UNUSED1 0x0010 // bit 4
328 #define FSF_RAWMODE 0x0020 // bit 5
329 #define FSF_DEVICEIDNOTDIRTY 0x0040 // bit 6
330 #define FSF_LOCALDEVICE 0x0080 // bit 7
331 #define FSF_NO_SFT_HANDLE_ALLOCTD 0x0100 // bit 8
332 #define FSF_THREAD_BLOCKED_ON_SF 0x0200 // bit 9
333 #define FSF_THREAD_BUSY_ON_SF 0x0400 // bit 10
334 #define FSF_NAMED_PIPE 0x0800 // bit 11
335 #define FSF_SFT_USES_FCB 0x1000 // bit 12
336 #define FSF_IS_PIPE 0x2000 // bit 13;
337 // then bit 11 determines whether this pipe is named or unnamed
338 // #define FSF_UNUSED2 0x4000 // bit 14
339 #define FSF_REMOTE_FILE 0x8000 // bit 15
340 // otherwise local file or device
341
342 /*
343 *@@ QFDS32:
344 * open file entry.
345 * Pointed to by QFILEDATA32.
346 */
347
348 typedef struct _QFDS32
349 {
350 USHORT usSFN; // "system file number" of the file.
351 // This is the same as in
352 // the QPROCESS32.pausFds array,
353 // so we can identify files opened
354 // by a process. File handles returned
355 // by DosOpen ("job file numbers", JFN's)
356 // are mapped to SFN's for each process
357 // individually.
358 USHORT usRefCount;
359 ULONG flFlags; // FSF_* flags above
360 ULONG flAccess; // fsOpenMode flags of DosOpen:
361 /* #define OPEN_ACCESS_READONLY 0x0000
362 #define OPEN_ACCESS_WRITEONLY 0x0001
363 #define OPEN_ACCESS_READWRITE 0x0002
364 #define OPEN_SHARE_DENYREADWRITE 0x0010
365 #define OPEN_SHARE_DENYWRITE 0x0020
366 #define OPEN_SHARE_DENYREAD 0x0030
367 #define OPEN_SHARE_DENYNONE 0x0040
368 #define OPEN_FLAGS_NOINHERIT 0x0080
369 #define OPEN_FLAGS_NO_LOCALITY 0x0000
370 #define OPEN_FLAGS_SEQUENTIAL 0x0100
371 #define OPEN_FLAGS_RANDOM 0x0200
372 #define OPEN_FLAGS_RANDOMSEQUENTIAL 0x0300
373 #define OPEN_FLAGS_NO_CACHE 0x1000
374 #define OPEN_FLAGS_FAIL_ON_ERROR 0x2000
375 #define OPEN_FLAGS_WRITE_THROUGH 0x4000
376 #define OPEN_FLAGS_DASD 0x8000
377 #define OPEN_FLAGS_NONSPOOLED 0x00040000
378 #define OPEN_FLAGS_PROTECTED_HANDLE 0x40000000 */
379
380 ULONG ulFileSize; // file size in bytes
381 USHORT usHVolume; // "volume handle"; apparently,
382 // this identifies some kernel
383 // structure, it's the same for
384 // files on the same disk
385 USHORT fsAttribs; // attributes:
386 // 0x20: 'A' (archived)
387 // 0x10: 'D' (directory)
388 // 0x08: 'L' (?!?)
389 // 0x04: 'S' (system)
390 // 0x02: 'H' (hidden)
391 // 0x01: 'R' (read-only)
392 USHORT us_pad_;
393 } QFDS32, *PQFDS32;
394
395 /*
396 *@@ QFILEDATA32:
397 * open files linked-list item.
398 *
399 * First item is pointed to by QTOPLEVEL32.
400 */
401
402 typedef struct _QFILEDATA32
403 {
404 ULONG ulRecType; // 8 for file
405 struct _QFILEDATA32 *pNext; // next record
406 ULONG ulCFiles; // no. of SFT entries for this MFT entry
407 PQFDS32 paFiles; // first entry here
408 char szFilename[1];
409 } QFILEDATA32, *PQFILEDATA32;
410
411 /**********************
412 *
413 * process struct
414 *
415 **********************/
416
417 /*
418 *@@ QPROCESS32:
419 * process description structure.
420 *
421 * Pointed to by QTOPLEVEL32.
422 *
423 * Following this structure is an array
424 * of ulPrivSem32Count 32-bit semaphore
425 * descriptions.
426 */
427
428 typedef struct _QPROCESS32
429 {
430 ULONG ulRecType; // 1 for process
431 PQTHREAD32 pThreads; // thread data array,
432 // apperently with usThreadCount items
433 USHORT usPID; // process ID
434 USHORT usPPID; // parent process ID
435 ULONG ulProgType;
436 // -- 0: Full screen protected mode.
437 // -- 1: Real mode (probably DOS or Windoze).
438 // -- 2: VIO windowable protected mode.
439 // -- 3: Presentation manager protected mode.
440 // -- 4: Detached protected mode.
441 ULONG ulState; // one of the following:
442 // -- STAT_EXITLIST 0x01
443 // -- STAT_EXIT1 0x02
444 // -- STAT_EXITALL 0x04
445 // -- STAT_PARSTAT 0x10
446 // -- STAT_SYNCH 0x20
447 // -- STAT_DYING 0x40
448 // -- STAT_EMBRYO 0x80
449 ULONG ulScreenGroupID; // screen group ID
450 USHORT usHModule; // module handle of main executable
451 USHORT usThreadCount; // no. of threads (TCB's in use)
452 ULONG ulPrivSem32Count; // count of 32-bit semaphores
453 PVOID pvPrivSem32s; // ptr to 32-bit sems array
454 USHORT usSem16Count; // count of 16-bit semaphores in pausSem16 array
455 USHORT usModuleCount; // count of DLLs owned by this process
456 USHORT usShrMemCount; // count of shared memory handles
457 USHORT usFdsCount; // count of open files; this is mostly way too large
458 PUSHORT pausSem16; // ptr to array of 16-bit semaphore handles;
459 // has usSem16Count items
460 PUSHORT pausModules; // ptr to array of modules (MTE);
461 // has usModuleCount items
462 PUSHORT pausShrMems; // ptr to array of shared mem handles;
463 // has usShrMemCount items
464 PUSHORT pausFds; // ptr to array of file handles;
465 // many of these are pseudo-file handles, but
466 // will be the same as the QFDS32.sfn field,
467 // so open files can be identified.
468 } QPROCESS32, *PQPROCESS32;
469
470 /**********************
471 *
472 * 16-bit semaphores
473 *
474 **********************/
475
476 // SysSemFlag values
477
478 #define QS32_SYSSEM_WAITING 0x01 /* a thread is waiting on the sem */
479 #define QS32_SYSSEM_MUXWAITING 0x02 /* a thread is muxwaiting on the sem */
480 #define QS32_SYSSEM_OWNER_DIED 0x04 /* the process/thread owning the sem died */
481 #define QS32_SYSSEM_EXCLUSIVE 0x08 /* indicates a exclusive system semaphore */
482 #define QS32_SYSSEM_NAME_CLEANUP 0x10 /* name table entry needs to be removed */
483 #define QS32_SYSSEM_THREAD_OWNER_DIED 0x20 /* the thread owning the sem died */
484 #define QS32_SYSSEM_EXITLIST_OWNER 0x40 /* the exitlist thread owns the sem */
485
486 /*
487 *@@ QS32SEM16:
488 * 16-bit semaphore description.
489 *
490 *@@added V0.9.10 (2001-04-08) [umoeller]
491 */
492
493 typedef struct _QS32SEM16
494 {
495 struct _QS32SEM16 *pNext;
496 // ULONG NextRec; /* offset to next record in buffer */
497 /* System Semaphore Table Structure */
498 USHORT usSysSemOwner; /* thread owning this semaphore */
499 UCHAR fsSysSemFlags; /* system semaphore flag bit field */
500 UCHAR usSysSemRefCnt ; /* number of references to this sys sem */
501 UCHAR usSysSemProcCnt ; /* number of requests for this owner */
502 UCHAR usSysSemPad ; /* pad byte to round structure up to word */
503 USHORT pad_sh;
504 USHORT SemPtr; /* RMP SysSemPtr field */
505 char szName[1]; /* start of semaphore name string */
506 } QS32SEM16, *PQS32SEM16;
507
508 /*
509 *@@ QS32SEM16HEAD:
510 *
511 *@@added V0.9.10 (2001-04-08) [umoeller]
512 */
513
514 typedef struct _QS32SEM16HEAD
515 {
516 ULONG SRecType; /* offset of SysSemDataTable */
517 ULONG SpNextRec; /* overlays NextRec of 1st QS32SEM16 */
518 ULONG S32SemRec;
519 ULONG S16TblOff;
520 // ULONG pSem16Rec;
521 QS32SEM16 Sem16Rec; // first record, with subsequent following
522 } QS32SEM16HEAD, *PQS32SEM16HEAD;
523
524 /**********************
525 *
526 * shared memory
527 *
528 **********************/
529
530 /*
531 *@@ QSHRMEM32:
532 * describes a shared memory block.
533 *
534 * Pointed to by QTOPLEVEL32.
535 */
536
537 typedef struct _QSHRMEM32
538 {
539 struct _QSHRMEM32 *pNext;
540 USHORT usHandle; // shared memory handle
541 USHORT usSelector; // selector
542 USHORT usRefCount; // reference count
543 CHAR acName[1]; // shared memory name
544 } QSHRMEM32, *PQSHRMEM32;
545
546 /**********************
547 *
548 * 32-bit semaphores
549 *
550 **********************/
551
552 #define QS32_DC_SEM_SHARED 0x0001 // Shared Mutex, Event or MUX semaphore
553 #define QS32_DCMW_WAIT_ANY 0x0002 // Wait on any event/mutex to occur
554 #define QS32_DCMW_WAIT_ALL 0x0004 // Wait on all events/mutexs to occur
555 #define QS32_DCM_MUTEX_SEM 0x0008 // Mutex semaphore
556 #define QS32_DCE_EVENT_SEM 0x0010 // Event semaphore
557 #define QS32_DCMW_MUX_SEM 0x0020 // Muxwait semaphore
558 // #define QS32_DC_SEM_PM 0x0040 // PM Shared Event Semphore
559 #define QS32_DE_POSTED 0x0040 // event sem is in the posted state
560 #define QS32_DM_OWNER_DIED 0x0080 // The owning process died
561 #define QS32_DMW_MTX_MUX 0x0100 // MUX contains mutex sems
562 #define QS32_DHO_SEM_OPEN 0x0200 // Device drivers have opened this semaphore
563 #define QS32_DE_16BIT_MW 0x0400 // Part of a 16-bit MuxWait
564 #define QS32_DCE_POSTONE 0x0800 // Post one flag event semaphore
565 #define QS32_DCE_AUTORESET 0x1000 // Auto-reset event semaphore
566
567 /*
568 *@@ QS32OPENQ:
569 *
570 *@@added V0.9.10 (2001-04-08) [umoeller]
571 */
572
573 typedef struct _QS32OPENQ { /* qsopenq */
574 PID pidOpener; /* process id of opening process */
575 USHORT OpenCt; /* number of opens for this process */
576 } QS32OPENQ, *PQS32OPENQ;
577
578 /*
579 *@@ QS32EVENT:
580 *
581 *@@added V0.9.10 (2001-04-08) [umoeller]
582 */
583
584 typedef struct _QS32EVENT { /* qsevent */
585 QS32OPENQ *pOpenQ; /* pointer to open q entries */
586 UCHAR *pName; /* pointer to semaphore name */
587 ULONG *pMuxQ; /* pointer to the mux queue */
588 USHORT flags;
589 USHORT PostCt; /* # of posts */
590 } QS32EVENT, *PQS32EVENT;
591
592 /*
593 *@@ QS32MUTEX:
594 *
595 *@@added V0.9.10 (2001-04-08) [umoeller]
596 */
597
598 typedef struct _QS32MUTEX { /* qsmutex */
599 QS32OPENQ *pOpenQ; /* pointer to open q entries */
600 UCHAR *pName; /* pointer to semaphore name */
601 ULONG *pMuxQ; /* pointer to the mux queue */
602 USHORT flags;
603 USHORT ReqCt; /* # of requests */
604 USHORT SlotNum; /* slot # of owning thread */
605 USHORT pad_sh;
606 } QS32MUTEX, *PQS32MUTEX;
607
608 /*
609 *@@ QS32MUX:
610 *
611 *@@added V0.9.10 (2001-04-08) [umoeller]
612 */
613
614 typedef struct _QS32MUX { /* qsmux */
615 QS32OPENQ *pOpenQ; /* pointer to open q entries */
616 UCHAR *pName; /* pointer to semaphore name */
617 void *pSemRec; /* array of semaphore record entries */
618 USHORT flags;
619 USHORT cSemRec; /* count of semaphore records */
620 USHORT WaitCt; /* # threads waiting on the mux */
621 USHORT pad_sh;
622 } QS32MUX, *PQS32MUX;
623
624 /*
625 *@@ QS32SHUN:
626 *
627 *@@added V0.9.10 (2001-04-08) [umoeller]
628 */
629
630 typedef union _QS32SHUN { /* qsshun */
631 QS32EVENT qsSEvt; /* shared event sem */
632 QS32MUTEX qsSMtx; /* shared mutex sem */
633 QS32MUX qsSMux; /* shared mux sem */
634 } QS32SHUN, *PQS32SHUN;
635
636 /*
637 *@@ QS32SEM32:
638 *
639 *@@added V0.9.10 (2001-04-08) [umoeller]
640 */
641
642 typedef struct _QS32SEM32 { /* qsS32rec */
643 void *pNext; /* pointer to next record in buffer */
644 ULONG fl; // semaphore flags; THIS FIELD IS MISSING
645 // IN THE ORIGINAL TOOLKIT DEFINITIONS...
646 // only with this field we can determine
647 // if this is a mutex, event, or muxwait
648 PSZ pszName; // or NULL if unnamed
649 ULONG pvDeviceDriver; // ?!? points into kernel memory
650 USHORT usPostCount;
651 USHORT us_;
652 ULONG ulBlockID;
653
654 // can't make sense of the following fields... these
655 // seem to be variable in size
656 ULONG ulHandle;
657 /* USHORT usAlways1;
658 ULONG ulElse;
659 ULONG ulElse2; */
660 } QS32SEM32, *PQS32SEM32; // qsS32rec_t;
661
662 /**********************
663 *
664 * modules
665 *
666 **********************/
667
668 /*
669 *@@ QS32OBJ:
670 * describes an object in a module.
671 * Pointed to by QSMODULE32, but only
672 * if QS32_MTE was set on query.
673 *
674 *@@added V0.9.10 (2001-04-08) [umoeller]
675 */
676
677 typedef struct _QS32OBJ {
678 ULONG oaddr; /* object address */
679 ULONG osize; /* object size */
680 ULONG oflags; /* object flags */
681 } QS32OBJ, *PQS32OBJ;
682
683 /*
684 *@@ QMODULE32:
685 * describes an executable module.
686 *
687 * Pointed to by QTOPLEVEL32.
688 */
689
690 typedef struct _QMODULE32
691 {
692 struct _QMODULE32 *pNext; // next module
693 USHORT usHModule; // module handle (HMTE)
694 USHORT fFlat; // TRUE for 32-bit modules
695 ULONG ulRefCount; // no. of imports
696 ULONG cObjects; // no. of objects in module
697 PQS32OBJ paObjects; // ptr to objects list, if QS32_MTE was queried
698 PCHAR pcName; // module name (fully qualified)
699 USHORT ausModRef[1]; // array of module "references";
700 // this has usRefCount items
701 // and holds other modules (imports)
702 } QMODULE32, *PQMODULE32;
703
704 /**********************
705 *
706 * top-level struct
707 *
708 **********************/
709
710 /*
711 *@@ QTOPLEVEL32:
712 * head of the buffer returned by
713 * DosQuerySysState.
714 */
715
716 typedef struct _QTOPLEVEL32
717 {
718 PQGLOBAL32 pGlobalData;
719 PQPROCESS32 pProcessData;
720 PQS32SEM16HEAD pSem16Data;
721 PQS32SEM32 pSem32Data; // not always present!
722 PQSHRMEM32 pShrMemData;
723 PQMODULE32 pModuleData;
724 PVOID _reserved2_;
725 PQFILEDATA32 pFileData; // only present in FP19 or later or W4
726 } QTOPLEVEL32, *PQTOPLEVEL32;
727
728 /********************************************************************
729 *
730 * New procstat.c declarations
731 *
732 ********************************************************************/
733
734 /*
735 *@@ PRCPROCESS:
736 * additional, more lucid structure
737 * filled by prc16QueryProcessInfo.
738 */
739
740 typedef struct _PRCPROCESS
741 {
742 CHAR szModuleName[CCHMAXPATH]; // module name
743 USHORT usPID, // process ID
744 usParentPID, // parent process ID
745 usThreads; // thread count
746 ULONG ulSID; // session ID
747 ULONG ulSessionType;
748 ULONG ulStatus;
749 ULONG ulCPU; // CPU usage (sum of thread data)
750 } PRCPROCESS, *PPRCPROCESS;
751
752 /*
753 *@@ PRCTHREAD:
754 * additional, more lucid structure
755 * filled by prc16QueryThreadInfo.
756 */
757
758 typedef struct _PRCTHREAD
759 {
760 USHORT usTID; // thread ID
761 USHORT usThreadSlotID; // kernel thread slot ID
762 ULONG ulBlockID; // sleep id thread is sleeping on
763 ULONG ulPriority;
764 ULONG ulSysTime;
765 ULONG ulUserTime;
766 UCHAR ucStatus; // see status #define's below
767 } PRCTHREAD, *PPRCTHREAD;
768
769 #pragma pack()
770
771 /********************************************************************
772 *
773 * DosQProcStat (16-bit) interface
774 *
775 ********************************************************************/
776
777 APIRET prc16GetInfo(PQPROCSTAT16 *ppps);
778
779 APIRET prc16FreeInfo(PQPROCSTAT16 pInfo);
780
781 PQPROCESS16 prc16FindProcessFromName(PQPROCSTAT16 pInfo,
782 const char *pcszName);
783
784 PQPROCESS16 prc16FindProcessFromPID(PQPROCSTAT16 pInfo,
785 ULONG ulPID);
786
787 /********************************************************************
788 *
789 * DosQProcStat (16-bit) helpers
790 *
791 ********************************************************************/
792
793 BOOL prc16QueryProcessInfo(PQPROCSTAT16 pps, USHORT usPID, PPRCPROCESS pprcp);
794
795 ULONG prc16ForEachProcess(PFNWP pfnwpCallback, HWND hwnd, ULONG ulMsg, MPARAM mp1);
796
797 ULONG prc16QueryThreadCount(PQPROCSTAT16 pps, USHORT usPID);
798
799 BOOL prc16QueryThreadInfo(PQPROCSTAT16 pps, USHORT usPID, USHORT usTID, PPRCTHREAD pprct);
800
801 ULONG prc16QueryThreadPriority(PQPROCSTAT16 pps, USHORT usPID, USHORT usTID);
802
803 /********************************************************************
804 *
805 * DosQuerySysState (32-bit) interface
806 *
807 ********************************************************************/
808
809 PQTOPLEVEL32 prc32GetInfo2(ULONG fl,
810 APIRET *parc);
811
812 PQTOPLEVEL32 prc32GetInfo(APIRET *parc);
813
814 VOID prc32FreeInfo(PQTOPLEVEL32 pInfo);
815
816 PQPROCESS32 prc32FindProcessFromName(PQTOPLEVEL32 pInfo,
817 const char *pcszName);
818
819 PQPROCESS32 prc32FindProcessFromPID(PQTOPLEVEL32 pInfo,
820 ULONG pid);
821
822 PQS32SEM16 prc32FindSem16(PQTOPLEVEL32 pInfo,
823 USHORT usSemID);
824
825 PQS32SEM32 prc32FindSem32(PQTOPLEVEL32 pInfo,
826 USHORT usSemID);
827
828 PQSHRMEM32 prc32FindShrMem(PQTOPLEVEL32 pInfo,
829 USHORT usShrMemID);
830
831 PQMODULE32 prc32FindModule(PQTOPLEVEL32 pInfo,
832 USHORT usHModule);
833
834 PQFILEDATA32 prc32FindFileData(PQTOPLEVEL32 pInfo,
835 USHORT usFileID);
836
837#endif
838
839#if __cplusplus
840}
841#endif
842
Note: See TracBrowser for help on using the repository browser.