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 "procstat.h"
|
---|
12 | */
|
---|
13 |
|
---|
14 | /*
|
---|
15 | * This file Copyright (C) 1992-99 Ulrich Mller,
|
---|
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
|
---|
29 | extern "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 | #define QS32_PROCESS 0x0001
|
---|
236 | #define QS32_SEMAPHORE 0x0002
|
---|
237 | #define QS32_MTE 0x0004
|
---|
238 | #define QS32_FILESYS 0x0008
|
---|
239 | #define QS32_SHMEMORY 0x0010
|
---|
240 | #define QS32_DISK 0x0020
|
---|
241 | #define QS32_HWCONFIG 0x0040
|
---|
242 | #define QS32_NAMEDPIPE 0x0080
|
---|
243 | #define QS32_THREAD 0x0100
|
---|
244 | #define QS32_MODVER 0x0200
|
---|
245 |
|
---|
246 | #define QS32_STANDARD (QS32_PROCESS | QS32_SEMAPHORE | QS32_MTE | QS32_FILESYS | QS32_SHMEMORY)
|
---|
247 |
|
---|
248 | APIRET APIENTRY DosQuerySysState(ULONG flQueries,
|
---|
249 | ULONG arg1,
|
---|
250 | ULONG arg2,
|
---|
251 | ULONG _res_,
|
---|
252 | PVOID buf,
|
---|
253 | ULONG bufsz);
|
---|
254 |
|
---|
255 | /*
|
---|
256 | *@@ QGLOBAL32:
|
---|
257 | * Pointed to by QTOPLEVEL32.
|
---|
258 | */
|
---|
259 |
|
---|
260 | typedef struct _QGLOBAL32
|
---|
261 | {
|
---|
262 | ULONG ulThreadCount; // thread count
|
---|
263 | ULONG ulProcCount; // process count
|
---|
264 | ULONG ulModuleCount; // module count
|
---|
265 | } QGLOBAL32, *PQGLOBAL32;
|
---|
266 |
|
---|
267 | /*
|
---|
268 | *@@ QTHREAD32:
|
---|
269 | * Pointed to by QPROCESS32.
|
---|
270 | */
|
---|
271 |
|
---|
272 | typedef struct _QTHREAD32
|
---|
273 | {
|
---|
274 | ULONG rectype; // 256 for thread
|
---|
275 | USHORT usTID; // thread ID, process-specific
|
---|
276 | USHORT usSlotID; // slot ID, this identifies the thread to the kernel
|
---|
277 | ULONG ulSleepID; // something the kernel uses for blocking threads
|
---|
278 | ULONG ulPriority; // priority flags
|
---|
279 | ULONG ulSystime; // CPU time spent in system code
|
---|
280 | ULONG ulUsertime; // CPU time spent in user code
|
---|
281 | UCHAR ucState; // one of the following:
|
---|
282 | // -- TSTAT_READY 1
|
---|
283 | // -- TSTAT_BLOCKED 2
|
---|
284 | // -- TSTAT_RUNNING 5
|
---|
285 | // -- TSTAT_LOADED 9
|
---|
286 | UCHAR _reserved1_; /* padding to ULONG */
|
---|
287 | USHORT _reserved2_; /* padding to ULONG */
|
---|
288 | } QTHREAD32, *PQTHREAD32;
|
---|
289 |
|
---|
290 | // found the following in the "OS/2 Debugging handbook"
|
---|
291 | // (the identifiers are not official, but invented by
|
---|
292 | // me; V0.9.1 (2000-02-12) [umoeller]):
|
---|
293 | // these are the flags for QFDS32.flFlags
|
---|
294 | #define FSF_CONSOLEINPUT 0x0001 // bit 0
|
---|
295 | #define FSF_CONSOLEOUTPUT 0x0002 // bit 1
|
---|
296 | #define FSF_NULLDEVICE 0x0004 // bit 2
|
---|
297 | #define FSF_CLOCKDEVICE 0x0008 // bit 3
|
---|
298 | // #define FSF_UNUSED1 0x0010 // bit 4
|
---|
299 | #define FSF_RAWMODE 0x0020 // bit 5
|
---|
300 | #define FSF_DEVICEIDNOTDIRTY 0x0040 // bit 6
|
---|
301 | #define FSF_LOCALDEVICE 0x0080 // bit 7
|
---|
302 | #define FSF_NO_SFT_HANDLE_ALLOCTD 0x0100 // bit 8
|
---|
303 | #define FSF_THREAD_BLOCKED_ON_SF 0x0200 // bit 9
|
---|
304 | #define FSF_THREAD_BUSY_ON_SF 0x0400 // bit 10
|
---|
305 | #define FSF_NAMED_PIPE 0x0800 // bit 11
|
---|
306 | #define FSF_SFT_USES_FCB 0x1000 // bit 12
|
---|
307 | #define FSF_IS_PIPE 0x2000 // bit 13;
|
---|
308 | // then bit 11 determines whether this pipe is named or unnamed
|
---|
309 | // #define FSF_UNUSED2 0x4000 // bit 14
|
---|
310 | #define FSF_REMOTE_FILE 0x8000 // bit 15
|
---|
311 | // otherwise local file or device
|
---|
312 |
|
---|
313 | /*
|
---|
314 | *@@ QFDS32:
|
---|
315 | * open file entry.
|
---|
316 | * Pointed to by QFILEDATA32.
|
---|
317 | */
|
---|
318 |
|
---|
319 | typedef struct _QFDS32
|
---|
320 | {
|
---|
321 | USHORT sfn; // "system file number" of the file.
|
---|
322 | // This is the same as in
|
---|
323 | // the QPROCESS32.pausFds array,
|
---|
324 | // so we can identify files opened
|
---|
325 | // by a process. File handles returned
|
---|
326 | // by DosOpen ("job file numbers", JFN's)
|
---|
327 | // are mapped to SFN's for each process
|
---|
328 | // individually.
|
---|
329 | USHORT usRefCount;
|
---|
330 | ULONG flFlags; // FSF_* flags above
|
---|
331 | ULONG flAccess; // fsOpenMode flags of DosOpen:
|
---|
332 | /* #define OPEN_ACCESS_READONLY 0x0000
|
---|
333 | #define OPEN_ACCESS_WRITEONLY 0x0001
|
---|
334 | #define OPEN_ACCESS_READWRITE 0x0002
|
---|
335 | #define OPEN_SHARE_DENYREADWRITE 0x0010
|
---|
336 | #define OPEN_SHARE_DENYWRITE 0x0020
|
---|
337 | #define OPEN_SHARE_DENYREAD 0x0030
|
---|
338 | #define OPEN_SHARE_DENYNONE 0x0040
|
---|
339 | #define OPEN_FLAGS_NOINHERIT 0x0080
|
---|
340 | #define OPEN_FLAGS_NO_LOCALITY 0x0000
|
---|
341 | #define OPEN_FLAGS_SEQUENTIAL 0x0100
|
---|
342 | #define OPEN_FLAGS_RANDOM 0x0200
|
---|
343 | #define OPEN_FLAGS_RANDOMSEQUENTIAL 0x0300
|
---|
344 | #define OPEN_FLAGS_NO_CACHE 0x1000
|
---|
345 | #define OPEN_FLAGS_FAIL_ON_ERROR 0x2000
|
---|
346 | #define OPEN_FLAGS_WRITE_THROUGH 0x4000
|
---|
347 | #define OPEN_FLAGS_DASD 0x8000
|
---|
348 | #define OPEN_FLAGS_NONSPOOLED 0x00040000
|
---|
349 | #define OPEN_FLAGS_PROTECTED_HANDLE 0x40000000 */
|
---|
350 |
|
---|
351 | ULONG ulFileSize; // file size in bytes
|
---|
352 | USHORT hVolume; // "volume handle"; apparently,
|
---|
353 | // this identifies some kernel
|
---|
354 | // structure, it's the same for
|
---|
355 | // files on the same disk
|
---|
356 | USHORT attrib; // attributes:
|
---|
357 | // 0x20: 'A' (archived)
|
---|
358 | // 0x10: 'D' (directory)
|
---|
359 | // 0x08: 'L' (?!?)
|
---|
360 | // 0x04: 'S' (system)
|
---|
361 | // 0x02: 'H' (hidden)
|
---|
362 | // 0x01: 'R' (read-only)
|
---|
363 | USHORT _reserved_;
|
---|
364 | } QFDS32, *PQFDS32;
|
---|
365 |
|
---|
366 | /*
|
---|
367 | *@@ QFILEDATA32:
|
---|
368 | * open files linked-list item.
|
---|
369 | *
|
---|
370 | * First item is pointed to by QTOPLEVEL32.
|
---|
371 | */
|
---|
372 |
|
---|
373 | typedef struct _QFILEDATA32
|
---|
374 | {
|
---|
375 | ULONG rectype; // 8 for file
|
---|
376 | struct _QFILEDATA32 *pNext;
|
---|
377 | ULONG ulOpenCount;
|
---|
378 | PQFDS32 filedata;
|
---|
379 | char acFilename[1];
|
---|
380 | } QFILEDATA32, *PQFILEDATA32;
|
---|
381 |
|
---|
382 | /*
|
---|
383 | *@@ QPROCESS32:
|
---|
384 | * process description structure.
|
---|
385 | *
|
---|
386 | * Pointed to by QTOPLEVEL32.
|
---|
387 | *
|
---|
388 | * Following this structure is an array
|
---|
389 | * of ulPrivSem32Count 32-bit semaphore
|
---|
390 | * descriptions.
|
---|
391 | */
|
---|
392 |
|
---|
393 | typedef struct _QPROCESS32
|
---|
394 | {
|
---|
395 | ULONG rectype; // 1 for process
|
---|
396 | PQTHREAD32 pThreads; // thread data array; apperently with usThreadCount items
|
---|
397 | USHORT pid; // process ID
|
---|
398 | USHORT ppid; // parent process ID
|
---|
399 | ULONG ulProgType;
|
---|
400 | // -- 0: Full screen protected mode.
|
---|
401 | // -- 1: Real mode (probably DOS or Windoze).
|
---|
402 | // -- 2: VIO windowable protected mode.
|
---|
403 | // -- 3: Presentation manager protected mode.
|
---|
404 | // -- 4: Detached protected mode.
|
---|
405 | ULONG ulState; // one of the following:
|
---|
406 | // -- STAT_EXITLIST 0x01
|
---|
407 | // -- STAT_EXIT1 0x02
|
---|
408 | // -- STAT_EXITALL 0x04
|
---|
409 | // -- STAT_PARSTAT 0x10
|
---|
410 | // -- STAT_SYNCH 0x20
|
---|
411 | // -- STAT_DYING 0x40
|
---|
412 | // -- STAT_EMBRYO 0x80
|
---|
413 | ULONG sessid; // session ID
|
---|
414 | USHORT usHModule; // module handle of main executable
|
---|
415 | USHORT usThreadCount; // no. of threads
|
---|
416 | ULONG ulPrivSem32Count; // count of 32-bit semaphores
|
---|
417 | ULONG ulPrivSem32s; // should be ptr to 32-bit sems array; 0 always
|
---|
418 | USHORT usSem16Count; // count of 16-bit semaphores in pausSem16 array
|
---|
419 | USHORT usModuleCount; // count of DLLs owned by this process
|
---|
420 | USHORT usShrMemCount; // count of shared memory items
|
---|
421 | USHORT usFdsCount; // count of open files; this is mostly way too large
|
---|
422 | PUSHORT pausSem16; // ptr to array of 16-bit semaphore handles;
|
---|
423 | // has usSem16Count items
|
---|
424 | PUSHORT pausModules; // ptr to array of modules (MTE);
|
---|
425 | // has usModuleCount items
|
---|
426 | PUSHORT pausShrMems; // ptr to array of shared mem items;
|
---|
427 | // has usShrMemCount items
|
---|
428 | PUSHORT pausFds; // ptr to array of file handles;
|
---|
429 | // many of these are pseudo-file handles, but
|
---|
430 | // will be the same as the QFDS32.sfn field,
|
---|
431 | // so open files can be identified.
|
---|
432 | } QPROCESS32, *PQPROCESS32;
|
---|
433 |
|
---|
434 | /*
|
---|
435 | *@@ QSEMA32:
|
---|
436 | * Member of QSEM16STRUC32.
|
---|
437 | */
|
---|
438 |
|
---|
439 | typedef struct _QSEMA32
|
---|
440 | {
|
---|
441 | struct _QSEMA32 *pNext;
|
---|
442 | USHORT usRefCount;
|
---|
443 | UCHAR ucSysFlags;
|
---|
444 | UCHAR ucSysProcCount;
|
---|
445 | ULONG _reserved1_;
|
---|
446 | USHORT usIndex;
|
---|
447 | CHAR acName[1];
|
---|
448 | } QSEMA32, *PQSEMA32;
|
---|
449 |
|
---|
450 | /*
|
---|
451 | *@@ QSEM16STRUC32:
|
---|
452 | * Apparently 16-bit semaphores.
|
---|
453 | *
|
---|
454 | * Pointed to by QTOPLEVEL32.
|
---|
455 | */
|
---|
456 |
|
---|
457 | typedef struct _QSEM16STRUC32
|
---|
458 | {
|
---|
459 | ULONG rectype; /**/
|
---|
460 | ULONG _reserved1_;
|
---|
461 | USHORT _reserved2_;
|
---|
462 | USHORT usSysSemIndex;
|
---|
463 | ULONG ulIndex;
|
---|
464 | QSEMA32 sema;
|
---|
465 | } QSEM16STRUC32, *PQSEM16STRUC32;
|
---|
466 |
|
---|
467 | /*
|
---|
468 | *@@ QSEM32OWNER32:
|
---|
469 | * Pointed to by QSEM16SMUX32, QSEM16EV32, QSEM16MUX32.
|
---|
470 | */
|
---|
471 |
|
---|
472 | typedef struct _QSEM32OWNER32
|
---|
473 | {
|
---|
474 | USHORT pid;
|
---|
475 | USHORT usOpenCount; // or owner?!?
|
---|
476 | } QSEM32OWNER32, *PQSEM32OWNER32;
|
---|
477 |
|
---|
478 | /*
|
---|
479 | *@@ QSEM32SMUX32:
|
---|
480 | * member of QSEM32STRUC32.
|
---|
481 | */
|
---|
482 |
|
---|
483 | typedef struct _QSEM32SMUX32
|
---|
484 | {
|
---|
485 | PQSEM32OWNER32 pOwner;
|
---|
486 | PCHAR pszName;
|
---|
487 | PVOID semrecs; // array of associated sema's
|
---|
488 | USHORT flags;
|
---|
489 | USHORT semreccnt;
|
---|
490 | USHORT waitcnt;
|
---|
491 | USHORT _reserved_; // padding to ULONG
|
---|
492 | } QSEM32SMUX32, *PQSEM32SMUX32;
|
---|
493 |
|
---|
494 | /*
|
---|
495 | *@@ QSEM32EV32:
|
---|
496 | * describes an event semaphore.
|
---|
497 | * Member of QSEM32STRUC32.
|
---|
498 | */
|
---|
499 |
|
---|
500 | typedef struct _QSEM32EV32
|
---|
501 | {
|
---|
502 | PQSEM32OWNER32 pOwner;
|
---|
503 | PCHAR pacName;
|
---|
504 | PQSEM32SMUX32 pMux;
|
---|
505 | USHORT flags;
|
---|
506 | USHORT postcnt;
|
---|
507 | } QSEM32EV32, *PQSEM32EV32;
|
---|
508 |
|
---|
509 | /*
|
---|
510 | *@@ QSEM32MUX32:
|
---|
511 | * member of QSEM32STRUC32.
|
---|
512 | */
|
---|
513 |
|
---|
514 | typedef struct _QSEM32MUX32
|
---|
515 | {
|
---|
516 | PQSEM32OWNER32 pOwner;
|
---|
517 | PCHAR name;
|
---|
518 | PQSEM32SMUX32 mux;
|
---|
519 | USHORT flags;
|
---|
520 | USHORT usRefCount;
|
---|
521 | USHORT thrdnum;
|
---|
522 | USHORT _reserved_; /* padding to ULONG */
|
---|
523 | } QSEM32MUX32, *PQSEM32MUX32;
|
---|
524 |
|
---|
525 | /*
|
---|
526 | *@@ QSEM32STRUC32:
|
---|
527 | * apparently describes a 32-bit semaphore.
|
---|
528 | *
|
---|
529 | * Pointed to by QTOPLEVEL32.
|
---|
530 | */
|
---|
531 |
|
---|
532 | typedef struct _QSEM32STRUC32
|
---|
533 | {
|
---|
534 | struct _QSEM32STRUC32 *pNext;
|
---|
535 | QSEM32EV32 EventSem;
|
---|
536 | QSEM32MUX32 MuxSem;
|
---|
537 | QSEM32SMUX32 SmuxSem;
|
---|
538 | } QSEM32STRUC32, *PQSEM32STRUC32;
|
---|
539 |
|
---|
540 | /*
|
---|
541 | *@@ QSHRMEM32:
|
---|
542 | * describes a shared memory block.
|
---|
543 | *
|
---|
544 | * Pointed to by QTOPLEVEL32.
|
---|
545 | */
|
---|
546 |
|
---|
547 | typedef struct _QSHRMEM32
|
---|
548 | {
|
---|
549 | struct _QSHRMEM32 *pNext;
|
---|
550 | USHORT usHandle;
|
---|
551 | USHORT usSelector;
|
---|
552 | USHORT usRefCount;
|
---|
553 | CHAR acName[1];
|
---|
554 | } QSHRMEM32, *PQSHRMEM32;
|
---|
555 |
|
---|
556 | /*
|
---|
557 | *@@ QMODULE32:
|
---|
558 | * describes an executable module.
|
---|
559 | *
|
---|
560 | * Pointed to by QTOPLEVEL32.
|
---|
561 | */
|
---|
562 |
|
---|
563 | typedef struct _QMODULE32
|
---|
564 | {
|
---|
565 | struct _QMODULE32 *pNext; // next module
|
---|
566 | USHORT usHModule; // module handle
|
---|
567 | USHORT type;
|
---|
568 | ULONG ulRefCount;
|
---|
569 | ULONG ulSegmentCount;
|
---|
570 | PVOID _reserved_;
|
---|
571 | PCHAR pcName; // module name (fully qualified)
|
---|
572 | USHORT ausModRef[1]; // array of module "references";
|
---|
573 | // this has usRefCount items
|
---|
574 | // and holds other modules (imports)
|
---|
575 | } QMODULE32, *PQMODULE32;
|
---|
576 |
|
---|
577 | /*
|
---|
578 | *@@ QTOPLEVEL32:
|
---|
579 | * head of the buffer returned by
|
---|
580 | * DosQuerySysState.
|
---|
581 | */
|
---|
582 |
|
---|
583 | typedef struct _QTOPLEVEL32
|
---|
584 | {
|
---|
585 | PQGLOBAL32 pGlobalData;
|
---|
586 | PQPROCESS32 pProcessData;
|
---|
587 | PQSEM16STRUC32 pSem16Data;
|
---|
588 | PQSEM32STRUC32 pSem32Data; // not always present!
|
---|
589 | PQSHRMEM32 pShrMemData;
|
---|
590 | PQMODULE32 pModuleData;
|
---|
591 | PVOID _reserved2_;
|
---|
592 | PQFILEDATA32 pFileData; // only present in FP19 or later or W4
|
---|
593 | } QTOPLEVEL32, *PQTOPLEVEL32;
|
---|
594 |
|
---|
595 | /********************************************************************
|
---|
596 | *
|
---|
597 | * New procstat.c declarations
|
---|
598 | *
|
---|
599 | ********************************************************************/
|
---|
600 |
|
---|
601 | /*
|
---|
602 | *@@ PRCPROCESS:
|
---|
603 | * additional, more lucid structure
|
---|
604 | * filled by prc16QueryProcessInfo.
|
---|
605 | */
|
---|
606 |
|
---|
607 | typedef struct _PRCPROCESS
|
---|
608 | {
|
---|
609 | CHAR szModuleName[CCHMAXPATH]; // module name
|
---|
610 | USHORT usPID, // process ID
|
---|
611 | usParentPID, // parent process ID
|
---|
612 | usThreads; // thread count
|
---|
613 | ULONG ulSID; // session ID
|
---|
614 | ULONG ulSessionType;
|
---|
615 | ULONG ulStatus;
|
---|
616 | ULONG ulCPU; // CPU usage (sum of thread data)
|
---|
617 | } PRCPROCESS, *PPRCPROCESS;
|
---|
618 |
|
---|
619 | /*
|
---|
620 | *@@ PRCTHREAD:
|
---|
621 | * additional, more lucid structure
|
---|
622 | * filled by prc16QueryThreadInfo.
|
---|
623 | */
|
---|
624 |
|
---|
625 | typedef struct _PRCTHREAD
|
---|
626 | {
|
---|
627 | USHORT usTID; // thread ID
|
---|
628 | USHORT usThreadSlotID; // kernel thread slot ID
|
---|
629 | ULONG ulBlockID; // sleep id thread is sleeping on
|
---|
630 | ULONG ulPriority;
|
---|
631 | ULONG ulSysTime;
|
---|
632 | ULONG ulUserTime;
|
---|
633 | UCHAR ucStatus; // see status #define's below
|
---|
634 | } PRCTHREAD, *PPRCTHREAD;
|
---|
635 |
|
---|
636 | #pragma pack()
|
---|
637 |
|
---|
638 | /********************************************************************
|
---|
639 | *
|
---|
640 | * DosQProcStat (16-bit) interface
|
---|
641 | *
|
---|
642 | ********************************************************************/
|
---|
643 |
|
---|
644 | PQPROCSTAT16 prc16GetInfo(APIRET *parc);
|
---|
645 |
|
---|
646 | VOID prc16FreeInfo(PQPROCSTAT16 pInfo);
|
---|
647 |
|
---|
648 | PQPROCESS16 prc16FindProcessFromName(PQPROCSTAT16 pInfo,
|
---|
649 | const char *pcszName);
|
---|
650 |
|
---|
651 | PQPROCESS16 prc16FindProcessFromPID(PQPROCSTAT16 pInfo,
|
---|
652 | ULONG ulPID);
|
---|
653 |
|
---|
654 | /********************************************************************
|
---|
655 | *
|
---|
656 | * DosQProcStat (16-bit) helpers
|
---|
657 | *
|
---|
658 | ********************************************************************/
|
---|
659 |
|
---|
660 | BOOL prc16QueryProcessInfo(PQPROCSTAT16 pps, USHORT usPID, PPRCPROCESS pprcp);
|
---|
661 |
|
---|
662 | ULONG prc16ForEachProcess(PFNWP pfnwpCallback, HWND hwnd, ULONG ulMsg, MPARAM mp1);
|
---|
663 |
|
---|
664 | ULONG prc16QueryThreadCount(PQPROCSTAT16 pps, USHORT usPID);
|
---|
665 |
|
---|
666 | BOOL prc16QueryThreadInfo(PQPROCSTAT16 pps, USHORT usPID, USHORT usTID, PPRCTHREAD pprct);
|
---|
667 |
|
---|
668 | ULONG prc16QueryThreadPriority(PQPROCSTAT16 pps, USHORT usPID, USHORT usTID);
|
---|
669 |
|
---|
670 | /********************************************************************
|
---|
671 | *
|
---|
672 | * DosQuerySysState (32-bit) interface
|
---|
673 | *
|
---|
674 | ********************************************************************/
|
---|
675 |
|
---|
676 | PQTOPLEVEL32 prc32GetInfo(APIRET *parc);
|
---|
677 |
|
---|
678 | VOID prc32FreeInfo(PQTOPLEVEL32 pInfo);
|
---|
679 |
|
---|
680 | PQPROCESS32 prc32FindProcessFromName(PQTOPLEVEL32 pInfo,
|
---|
681 | const char *pcszName);
|
---|
682 |
|
---|
683 | PQSEMA32 prc32FindSem16(PQTOPLEVEL32 pInfo,
|
---|
684 | USHORT usSemID);
|
---|
685 |
|
---|
686 | PQSEM32STRUC32 prc32FindSem32(PQTOPLEVEL32 pInfo,
|
---|
687 | USHORT usSemID);
|
---|
688 |
|
---|
689 | PQSHRMEM32 prc32FindShrMem(PQTOPLEVEL32 pInfo,
|
---|
690 | USHORT usShrMemID);
|
---|
691 |
|
---|
692 | PQMODULE32 prc32FindModule(PQTOPLEVEL32 pInfo,
|
---|
693 | USHORT usHModule);
|
---|
694 |
|
---|
695 | PQFILEDATA32 prc32FindFileData(PQTOPLEVEL32 pInfo,
|
---|
696 | USHORT usFileID);
|
---|
697 |
|
---|
698 | #endif
|
---|
699 |
|
---|
700 | #if __cplusplus
|
---|
701 | }
|
---|
702 | #endif
|
---|
703 |
|
---|