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 | // #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 | #define QS32_SUPPORTED (QS32_PROCESS | QS32_SEMAPHORE | QS32_MTE | QS32_FILESYS \
|
---|
250 | | QS32_SHMEMORY | QS32_MODVER)
|
---|
251 |
|
---|
252 | APIRET APIENTRY DosQuerySysState(ULONG EntityList,
|
---|
253 | ULONG EntityLevel,
|
---|
254 | PID pid,
|
---|
255 | TID tid,
|
---|
256 | PVOID pDataBuf,
|
---|
257 | ULONG cbBuf);
|
---|
258 |
|
---|
259 | /**********************
|
---|
260 | *
|
---|
261 | * global struct
|
---|
262 | *
|
---|
263 | **********************/
|
---|
264 |
|
---|
265 | /*
|
---|
266 | *@@ QGLOBAL32:
|
---|
267 | * Pointed to by QTOPLEVEL32.
|
---|
268 | */
|
---|
269 |
|
---|
270 | typedef struct _QGLOBAL32
|
---|
271 | {
|
---|
272 | ULONG ulThreadCount; // thread count
|
---|
273 | ULONG ulProcCount; // process count
|
---|
274 | ULONG ulModuleCount; // module count
|
---|
275 | } QGLOBAL32, *PQGLOBAL32;
|
---|
276 |
|
---|
277 | /**********************
|
---|
278 | *
|
---|
279 | * thread struct
|
---|
280 | *
|
---|
281 | **********************/
|
---|
282 |
|
---|
283 | /*
|
---|
284 | *@@ QTHREAD32:
|
---|
285 | * Pointed to by QPROCESS32.
|
---|
286 | */
|
---|
287 |
|
---|
288 | typedef struct _QTHREAD32
|
---|
289 | {
|
---|
290 | ULONG ulRecType; // 256 for thread
|
---|
291 | USHORT usTID; // thread ID, process-specific
|
---|
292 | USHORT usSlotID; // system-specific slot ID, this identifies the
|
---|
293 | // thread to the kernel
|
---|
294 | ULONG ulSleepID; // sleep ID the kernel uses for blocking threads
|
---|
295 | ULONG ulPriority; // priority flags
|
---|
296 | ULONG ulSystime; // CPU time spent in system code
|
---|
297 | ULONG ulUsertime; // CPU time spent in user code
|
---|
298 | UCHAR ucState; // one of the following:
|
---|
299 | // -- TSTAT_READY 1
|
---|
300 | // -- TSTAT_BLOCKED 2
|
---|
301 | // -- TSTAT_RUNNING 5
|
---|
302 | // -- TSTAT_LOADED 9
|
---|
303 | UCHAR _reserved1_; /* padding to ULONG */
|
---|
304 | USHORT _reserved2_; /* padding to ULONG */
|
---|
305 | } QTHREAD32, *PQTHREAD32;
|
---|
306 |
|
---|
307 | /**********************
|
---|
308 | *
|
---|
309 | * open files
|
---|
310 | *
|
---|
311 | **********************/
|
---|
312 |
|
---|
313 | // found the following in the "OS/2 Debugging handbook"
|
---|
314 | // (the identifiers are not official, but invented by
|
---|
315 | // me; V0.9.1 (2000-02-12) [umoeller]):
|
---|
316 | // these are the flags for QFDS32.flFlags
|
---|
317 | #define FSF_CONSOLEINPUT 0x0001 // bit 0
|
---|
318 | #define FSF_CONSOLEOUTPUT 0x0002 // bit 1
|
---|
319 | #define FSF_NULLDEVICE 0x0004 // bit 2
|
---|
320 | #define FSF_CLOCKDEVICE 0x0008 // bit 3
|
---|
321 | // #define FSF_UNUSED1 0x0010 // bit 4
|
---|
322 | #define FSF_RAWMODE 0x0020 // bit 5
|
---|
323 | #define FSF_DEVICEIDNOTDIRTY 0x0040 // bit 6
|
---|
324 | #define FSF_LOCALDEVICE 0x0080 // bit 7
|
---|
325 | #define FSF_NO_SFT_HANDLE_ALLOCTD 0x0100 // bit 8
|
---|
326 | #define FSF_THREAD_BLOCKED_ON_SF 0x0200 // bit 9
|
---|
327 | #define FSF_THREAD_BUSY_ON_SF 0x0400 // bit 10
|
---|
328 | #define FSF_NAMED_PIPE 0x0800 // bit 11
|
---|
329 | #define FSF_SFT_USES_FCB 0x1000 // bit 12
|
---|
330 | #define FSF_IS_PIPE 0x2000 // bit 13;
|
---|
331 | // then bit 11 determines whether this pipe is named or unnamed
|
---|
332 | // #define FSF_UNUSED2 0x4000 // bit 14
|
---|
333 | #define FSF_REMOTE_FILE 0x8000 // bit 15
|
---|
334 | // otherwise local file or device
|
---|
335 |
|
---|
336 | /*
|
---|
337 | *@@ QFDS32:
|
---|
338 | * open file entry.
|
---|
339 | * Pointed to by QFILEDATA32.
|
---|
340 | */
|
---|
341 |
|
---|
342 | typedef struct _QFDS32
|
---|
343 | {
|
---|
344 | USHORT usSFN; // "system file number" of the file.
|
---|
345 | // This is the same as in
|
---|
346 | // the QPROCESS32.pausFds array,
|
---|
347 | // so we can identify files opened
|
---|
348 | // by a process. File handles returned
|
---|
349 | // by DosOpen ("job file numbers", JFN's)
|
---|
350 | // are mapped to SFN's for each process
|
---|
351 | // individually.
|
---|
352 | USHORT usRefCount;
|
---|
353 | ULONG flFlags; // FSF_* flags above
|
---|
354 | ULONG flAccess; // fsOpenMode flags of DosOpen:
|
---|
355 | /* #define OPEN_ACCESS_READONLY 0x0000
|
---|
356 | #define OPEN_ACCESS_WRITEONLY 0x0001
|
---|
357 | #define OPEN_ACCESS_READWRITE 0x0002
|
---|
358 | #define OPEN_SHARE_DENYREADWRITE 0x0010
|
---|
359 | #define OPEN_SHARE_DENYWRITE 0x0020
|
---|
360 | #define OPEN_SHARE_DENYREAD 0x0030
|
---|
361 | #define OPEN_SHARE_DENYNONE 0x0040
|
---|
362 | #define OPEN_FLAGS_NOINHERIT 0x0080
|
---|
363 | #define OPEN_FLAGS_NO_LOCALITY 0x0000
|
---|
364 | #define OPEN_FLAGS_SEQUENTIAL 0x0100
|
---|
365 | #define OPEN_FLAGS_RANDOM 0x0200
|
---|
366 | #define OPEN_FLAGS_RANDOMSEQUENTIAL 0x0300
|
---|
367 | #define OPEN_FLAGS_NO_CACHE 0x1000
|
---|
368 | #define OPEN_FLAGS_FAIL_ON_ERROR 0x2000
|
---|
369 | #define OPEN_FLAGS_WRITE_THROUGH 0x4000
|
---|
370 | #define OPEN_FLAGS_DASD 0x8000
|
---|
371 | #define OPEN_FLAGS_NONSPOOLED 0x00040000
|
---|
372 | #define OPEN_FLAGS_PROTECTED_HANDLE 0x40000000 */
|
---|
373 |
|
---|
374 | ULONG ulFileSize; // file size in bytes
|
---|
375 | USHORT usHVolume; // "volume handle"; apparently,
|
---|
376 | // this identifies some kernel
|
---|
377 | // structure, it's the same for
|
---|
378 | // files on the same disk
|
---|
379 | USHORT fsAttribs; // attributes:
|
---|
380 | // 0x20: 'A' (archived)
|
---|
381 | // 0x10: 'D' (directory)
|
---|
382 | // 0x08: 'L' (?!?)
|
---|
383 | // 0x04: 'S' (system)
|
---|
384 | // 0x02: 'H' (hidden)
|
---|
385 | // 0x01: 'R' (read-only)
|
---|
386 | USHORT us_pad_;
|
---|
387 | } QFDS32, *PQFDS32;
|
---|
388 |
|
---|
389 | /*
|
---|
390 | *@@ QFILEDATA32:
|
---|
391 | * open files linked-list item.
|
---|
392 | *
|
---|
393 | * First item is pointed to by QTOPLEVEL32.
|
---|
394 | */
|
---|
395 |
|
---|
396 | typedef struct _QFILEDATA32
|
---|
397 | {
|
---|
398 | ULONG ulRecType; // 8 for file
|
---|
399 | struct _QFILEDATA32 *pNext; // next record
|
---|
400 | ULONG ulCFiles; // no. of SFT entries for this MFT entry
|
---|
401 | PQFDS32 paFiles; // first entry here
|
---|
402 | char szFilename[1];
|
---|
403 | } QFILEDATA32, *PQFILEDATA32;
|
---|
404 |
|
---|
405 | /**********************
|
---|
406 | *
|
---|
407 | * process struct
|
---|
408 | *
|
---|
409 | **********************/
|
---|
410 |
|
---|
411 | /*
|
---|
412 | *@@ QPROCESS32:
|
---|
413 | * process description structure.
|
---|
414 | *
|
---|
415 | * Pointed to by QTOPLEVEL32.
|
---|
416 | *
|
---|
417 | * Following this structure is an array
|
---|
418 | * of ulPrivSem32Count 32-bit semaphore
|
---|
419 | * descriptions.
|
---|
420 | */
|
---|
421 |
|
---|
422 | typedef struct _QPROCESS32
|
---|
423 | {
|
---|
424 | ULONG ulRecType; // 1 for process
|
---|
425 | PQTHREAD32 pThreads; // thread data array,
|
---|
426 | // apperently with usThreadCount items
|
---|
427 | USHORT usPID; // process ID
|
---|
428 | USHORT usPPID; // parent process ID
|
---|
429 | ULONG ulProgType;
|
---|
430 | // -- 0: Full screen protected mode.
|
---|
431 | // -- 1: Real mode (probably DOS or Windoze).
|
---|
432 | // -- 2: VIO windowable protected mode.
|
---|
433 | // -- 3: Presentation manager protected mode.
|
---|
434 | // -- 4: Detached protected mode.
|
---|
435 | ULONG ulState; // one of the following:
|
---|
436 | // -- STAT_EXITLIST 0x01
|
---|
437 | // -- STAT_EXIT1 0x02
|
---|
438 | // -- STAT_EXITALL 0x04
|
---|
439 | // -- STAT_PARSTAT 0x10
|
---|
440 | // -- STAT_SYNCH 0x20
|
---|
441 | // -- STAT_DYING 0x40
|
---|
442 | // -- STAT_EMBRYO 0x80
|
---|
443 | ULONG ulScreenGroupID; // screen group ID
|
---|
444 | USHORT usHModule; // module handle of main executable
|
---|
445 | USHORT usThreadCount; // no. of threads (TCB's in use)
|
---|
446 | ULONG ulPrivSem32Count; // count of 32-bit semaphores
|
---|
447 | PVOID pvPrivSem32s; // ptr to 32-bit sems array
|
---|
448 | USHORT usSem16Count; // count of 16-bit semaphores in pausSem16 array
|
---|
449 | USHORT usModuleCount; // count of DLLs owned by this process
|
---|
450 | USHORT usShrMemCount; // count of shared memory handles
|
---|
451 | USHORT usFdsCount; // count of open files; this is mostly way too large
|
---|
452 | PUSHORT pausSem16; // ptr to array of 16-bit semaphore handles;
|
---|
453 | // has usSem16Count items
|
---|
454 | PUSHORT pausModules; // ptr to array of modules (MTE);
|
---|
455 | // has usModuleCount items
|
---|
456 | PUSHORT pausShrMems; // ptr to array of shared mem handles;
|
---|
457 | // has usShrMemCount items
|
---|
458 | PUSHORT pausFds; // ptr to array of file handles;
|
---|
459 | // many of these are pseudo-file handles, but
|
---|
460 | // will be the same as the QFDS32.sfn field,
|
---|
461 | // so open files can be identified.
|
---|
462 | } QPROCESS32, *PQPROCESS32;
|
---|
463 |
|
---|
464 | /**********************
|
---|
465 | *
|
---|
466 | * 16-bit semaphores
|
---|
467 | *
|
---|
468 | **********************/
|
---|
469 |
|
---|
470 | // SysSemFlag values
|
---|
471 |
|
---|
472 | #define QS32_SYSSEM_WAITING 0x01 /* a thread is waiting on the sem */
|
---|
473 | #define QS32_SYSSEM_MUXWAITING 0x02 /* a thread is muxwaiting on the sem */
|
---|
474 | #define QS32_SYSSEM_OWNER_DIED 0x04 /* the process/thread owning the sem died */
|
---|
475 | #define QS32_SYSSEM_EXCLUSIVE 0x08 /* indicates a exclusive system semaphore */
|
---|
476 | #define QS32_SYSSEM_NAME_CLEANUP 0x10 /* name table entry needs to be removed */
|
---|
477 | #define QS32_SYSSEM_THREAD_OWNER_DIED 0x20 /* the thread owning the sem died */
|
---|
478 | #define QS32_SYSSEM_EXITLIST_OWNER 0x40 /* the exitlist thread owns the sem */
|
---|
479 |
|
---|
480 | /*
|
---|
481 | *@@ QS32SEM16:
|
---|
482 | * 16-bit semaphore description.
|
---|
483 | *
|
---|
484 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
485 | */
|
---|
486 |
|
---|
487 | typedef struct _QS32SEM16
|
---|
488 | {
|
---|
489 | struct _QS32SEM16 *pNext;
|
---|
490 | // ULONG NextRec; /* offset to next record in buffer */
|
---|
491 | /* System Semaphore Table Structure */
|
---|
492 | USHORT usSysSemOwner; /* thread owning this semaphore */
|
---|
493 | UCHAR fsSysSemFlags; /* system semaphore flag bit field */
|
---|
494 | UCHAR usSysSemRefCnt ; /* number of references to this sys sem */
|
---|
495 | UCHAR usSysSemProcCnt ; /* number of requests for this owner */
|
---|
496 | UCHAR usSysSemPad ; /* pad byte to round structure up to word */
|
---|
497 | USHORT pad_sh;
|
---|
498 | USHORT SemPtr; /* RMP SysSemPtr field */
|
---|
499 | char szName[1]; /* start of semaphore name string */
|
---|
500 | } QS32SEM16, *PQS32SEM16;
|
---|
501 |
|
---|
502 | /*
|
---|
503 | *@@ QS32SEM16HEAD:
|
---|
504 | *
|
---|
505 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
506 | */
|
---|
507 |
|
---|
508 | typedef struct _QS32SEM16HEAD
|
---|
509 | {
|
---|
510 | ULONG SRecType; /* offset of SysSemDataTable */
|
---|
511 | ULONG SpNextRec; /* overlays NextRec of 1st QS32SEM16 */
|
---|
512 | ULONG S32SemRec;
|
---|
513 | ULONG S16TblOff;
|
---|
514 | // ULONG pSem16Rec;
|
---|
515 | QS32SEM16 Sem16Rec; // first record, with subsequent following
|
---|
516 | } QS32SEM16HEAD, *PQS32SEM16HEAD;
|
---|
517 |
|
---|
518 | /**********************
|
---|
519 | *
|
---|
520 | * shared memory
|
---|
521 | *
|
---|
522 | **********************/
|
---|
523 |
|
---|
524 | /*
|
---|
525 | *@@ QSHRMEM32:
|
---|
526 | * describes a shared memory block.
|
---|
527 | *
|
---|
528 | * Pointed to by QTOPLEVEL32.
|
---|
529 | */
|
---|
530 |
|
---|
531 | typedef struct _QSHRMEM32
|
---|
532 | {
|
---|
533 | struct _QSHRMEM32 *pNext;
|
---|
534 | USHORT usHandle; // shared memory handle
|
---|
535 | USHORT usSelector; // selector
|
---|
536 | USHORT usRefCount; // reference count
|
---|
537 | CHAR acName[1]; // shared memory name
|
---|
538 | } QSHRMEM32, *PQSHRMEM32;
|
---|
539 |
|
---|
540 | /**********************
|
---|
541 | *
|
---|
542 | * 32-bit semaphores
|
---|
543 | *
|
---|
544 | **********************/
|
---|
545 |
|
---|
546 | #define QS32_DC_SEM_SHARED 0x0001 // Shared Mutex, Event or MUX semaphore
|
---|
547 | #define QS32_DCMW_WAIT_ANY 0x0002 // Wait on any event/mutex to occur
|
---|
548 | #define QS32_DCMW_WAIT_ALL 0x0004 // Wait on all events/mutexs to occur
|
---|
549 | #define QS32_DCM_MUTEX_SEM 0x0008 // Mutex semaphore
|
---|
550 | #define QS32_DCE_EVENT_SEM 0x0010 // Event semaphore
|
---|
551 | #define QS32_DCMW_MUX_SEM 0x0020 // Muxwait semaphore
|
---|
552 | // #define QS32_DC_SEM_PM 0x0040 // PM Shared Event Semphore
|
---|
553 | #define QS32_DE_POSTED 0x0040 // event sem is in the posted state
|
---|
554 | #define QS32_DM_OWNER_DIED 0x0080 // The owning process died
|
---|
555 | #define QS32_DMW_MTX_MUX 0x0100 // MUX contains mutex sems
|
---|
556 | #define QS32_DHO_SEM_OPEN 0x0200 // Device drivers have opened this semaphore
|
---|
557 | #define QS32_DE_16BIT_MW 0x0400 // Part of a 16-bit MuxWait
|
---|
558 | #define QS32_DCE_POSTONE 0x0800 // Post one flag event semaphore
|
---|
559 | #define QS32_DCE_AUTORESET 0x1000 // Auto-reset event semaphore
|
---|
560 |
|
---|
561 | /*
|
---|
562 | *@@ QS32OPENQ:
|
---|
563 | *
|
---|
564 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
565 | */
|
---|
566 |
|
---|
567 | typedef struct _QS32OPENQ { /* qsopenq */
|
---|
568 | PID pidOpener; /* process id of opening process */
|
---|
569 | USHORT OpenCt; /* number of opens for this process */
|
---|
570 | } QS32OPENQ, *PQS32OPENQ;
|
---|
571 |
|
---|
572 | /*
|
---|
573 | *@@ QS32EVENT:
|
---|
574 | *
|
---|
575 | *@@added V [umoeller]
|
---|
576 | */
|
---|
577 |
|
---|
578 | typedef struct _QS32EVENT { /* qsevent */
|
---|
579 | QS32OPENQ *pOpenQ; /* pointer to open q entries */
|
---|
580 | UCHAR *pName; /* pointer to semaphore name */
|
---|
581 | ULONG *pMuxQ; /* pointer to the mux queue */
|
---|
582 | USHORT flags;
|
---|
583 | USHORT PostCt; /* # of posts */
|
---|
584 | } QS32EVENT, *PQS32EVENT;
|
---|
585 |
|
---|
586 | /*
|
---|
587 | *@@ QS32MUTEX:
|
---|
588 | *
|
---|
589 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
590 | */
|
---|
591 |
|
---|
592 | typedef struct _QS32MUTEX { /* qsmutex */
|
---|
593 | QS32OPENQ *pOpenQ; /* pointer to open q entries */
|
---|
594 | UCHAR *pName; /* pointer to semaphore name */
|
---|
595 | ULONG *pMuxQ; /* pointer to the mux queue */
|
---|
596 | USHORT flags;
|
---|
597 | USHORT ReqCt; /* # of requests */
|
---|
598 | USHORT SlotNum; /* slot # of owning thread */
|
---|
599 | USHORT pad_sh;
|
---|
600 | } QS32MUTEX, *PQS32MUTEX;
|
---|
601 |
|
---|
602 | /*
|
---|
603 | *@@ QS32MUX:
|
---|
604 | *
|
---|
605 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
606 | */
|
---|
607 |
|
---|
608 | typedef struct _QS32MUX { /* qsmux */
|
---|
609 | QS32OPENQ *pOpenQ; /* pointer to open q entries */
|
---|
610 | UCHAR *pName; /* pointer to semaphore name */
|
---|
611 | void *pSemRec; /* array of semaphore record entries */
|
---|
612 | USHORT flags;
|
---|
613 | USHORT cSemRec; /* count of semaphore records */
|
---|
614 | USHORT WaitCt; /* # threads waiting on the mux */
|
---|
615 | USHORT pad_sh;
|
---|
616 | } QS32MUX, *PQS32MUX;
|
---|
617 |
|
---|
618 | /*
|
---|
619 | *@@ QS32SHUN:
|
---|
620 | *
|
---|
621 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
622 | */
|
---|
623 |
|
---|
624 | typedef union _QS32SHUN { /* qsshun */
|
---|
625 | QS32EVENT qsSEvt; /* shared event sem */
|
---|
626 | QS32MUTEX qsSMtx; /* shared mutex sem */
|
---|
627 | QS32MUX qsSMux; /* shared mux sem */
|
---|
628 | } QS32SHUN, *PQS32SHUN;
|
---|
629 |
|
---|
630 | /*
|
---|
631 | *@@ QS32SEM32:
|
---|
632 | *
|
---|
633 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
634 | */
|
---|
635 |
|
---|
636 | typedef struct _QS32SEM32 { /* qsS32rec */
|
---|
637 | void *pNext; /* pointer to next record in buffer */
|
---|
638 | ULONG fl; // semaphore flags; THIS FIELD IS MISSING
|
---|
639 | // IN THE ORIGINAL TOOLKIT DEFINITIONS...
|
---|
640 | // only with this field we can determine
|
---|
641 | // if this is a mutex, event, or muxwait
|
---|
642 | PSZ pszName; // or NULL if unnamed
|
---|
643 | ULONG pvDeviceDriver; // ?!? points into kernel memory
|
---|
644 | USHORT usPostCount;
|
---|
645 | USHORT us_;
|
---|
646 | ULONG ulBlockID;
|
---|
647 |
|
---|
648 | // can't make sense of the following fields... these
|
---|
649 | // seem to be variable in size
|
---|
650 | ULONG ulHandle;
|
---|
651 | /* USHORT usAlways1;
|
---|
652 | ULONG ulElse;
|
---|
653 | ULONG ulElse2; */
|
---|
654 | } QS32SEM32, *PQS32SEM32; // qsS32rec_t;
|
---|
655 |
|
---|
656 | /**********************
|
---|
657 | *
|
---|
658 | * modules
|
---|
659 | *
|
---|
660 | **********************/
|
---|
661 |
|
---|
662 | /*
|
---|
663 | *@@ QS32OBJ:
|
---|
664 | * describes an object in a module.
|
---|
665 | * Pointed to by QSMODULE32, but only
|
---|
666 | * if QS32_MTE was set on query.
|
---|
667 | *
|
---|
668 | *@@added V0.9.10 (2001-04-08) [umoeller]
|
---|
669 | */
|
---|
670 |
|
---|
671 | typedef struct _QS32OBJ {
|
---|
672 | ULONG oaddr; /* object address */
|
---|
673 | ULONG osize; /* object size */
|
---|
674 | ULONG oflags; /* object flags */
|
---|
675 | } QS32OBJ, *PQS32OBJ;
|
---|
676 |
|
---|
677 | /*
|
---|
678 | *@@ QMODULE32:
|
---|
679 | * describes an executable module.
|
---|
680 | *
|
---|
681 | * Pointed to by QTOPLEVEL32.
|
---|
682 | */
|
---|
683 |
|
---|
684 | typedef struct _QMODULE32
|
---|
685 | {
|
---|
686 | struct _QMODULE32 *pNext; // next module
|
---|
687 | USHORT usHModule; // module handle (HMTE)
|
---|
688 | USHORT fFlat; // TRUE for 32-bit modules
|
---|
689 | ULONG ulRefCount; // no. of imports
|
---|
690 | ULONG cObjects; // no. of objects in module
|
---|
691 | PQS32OBJ paObjects; // ptr to objects list, if QS32_MTE was queried
|
---|
692 | PCHAR pcName; // module name (fully qualified)
|
---|
693 | USHORT ausModRef[1]; // array of module "references";
|
---|
694 | // this has usRefCount items
|
---|
695 | // and holds other modules (imports)
|
---|
696 | } QMODULE32, *PQMODULE32;
|
---|
697 |
|
---|
698 | /**********************
|
---|
699 | *
|
---|
700 | * top-level struct
|
---|
701 | *
|
---|
702 | **********************/
|
---|
703 |
|
---|
704 | /*
|
---|
705 | *@@ QTOPLEVEL32:
|
---|
706 | * head of the buffer returned by
|
---|
707 | * DosQuerySysState.
|
---|
708 | */
|
---|
709 |
|
---|
710 | typedef struct _QTOPLEVEL32
|
---|
711 | {
|
---|
712 | PQGLOBAL32 pGlobalData;
|
---|
713 | PQPROCESS32 pProcessData;
|
---|
714 | PQS32SEM16HEAD pSem16Data;
|
---|
715 | PQS32SEM32 pSem32Data; // not always present!
|
---|
716 | PQSHRMEM32 pShrMemData;
|
---|
717 | PQMODULE32 pModuleData;
|
---|
718 | PVOID _reserved2_;
|
---|
719 | PQFILEDATA32 pFileData; // only present in FP19 or later or W4
|
---|
720 | } QTOPLEVEL32, *PQTOPLEVEL32;
|
---|
721 |
|
---|
722 | /********************************************************************
|
---|
723 | *
|
---|
724 | * New procstat.c declarations
|
---|
725 | *
|
---|
726 | ********************************************************************/
|
---|
727 |
|
---|
728 | /*
|
---|
729 | *@@ PRCPROCESS:
|
---|
730 | * additional, more lucid structure
|
---|
731 | * filled by prc16QueryProcessInfo.
|
---|
732 | */
|
---|
733 |
|
---|
734 | typedef struct _PRCPROCESS
|
---|
735 | {
|
---|
736 | CHAR szModuleName[CCHMAXPATH]; // module name
|
---|
737 | USHORT usPID, // process ID
|
---|
738 | usParentPID, // parent process ID
|
---|
739 | usThreads; // thread count
|
---|
740 | ULONG ulSID; // session ID
|
---|
741 | ULONG ulSessionType;
|
---|
742 | ULONG ulStatus;
|
---|
743 | ULONG ulCPU; // CPU usage (sum of thread data)
|
---|
744 | } PRCPROCESS, *PPRCPROCESS;
|
---|
745 |
|
---|
746 | /*
|
---|
747 | *@@ PRCTHREAD:
|
---|
748 | * additional, more lucid structure
|
---|
749 | * filled by prc16QueryThreadInfo.
|
---|
750 | */
|
---|
751 |
|
---|
752 | typedef struct _PRCTHREAD
|
---|
753 | {
|
---|
754 | USHORT usTID; // thread ID
|
---|
755 | USHORT usThreadSlotID; // kernel thread slot ID
|
---|
756 | ULONG ulBlockID; // sleep id thread is sleeping on
|
---|
757 | ULONG ulPriority;
|
---|
758 | ULONG ulSysTime;
|
---|
759 | ULONG ulUserTime;
|
---|
760 | UCHAR ucStatus; // see status #define's below
|
---|
761 | } PRCTHREAD, *PPRCTHREAD;
|
---|
762 |
|
---|
763 | #pragma pack()
|
---|
764 |
|
---|
765 | /********************************************************************
|
---|
766 | *
|
---|
767 | * DosQProcStat (16-bit) interface
|
---|
768 | *
|
---|
769 | ********************************************************************/
|
---|
770 |
|
---|
771 | APIRET prc16GetInfo(PQPROCSTAT16 *ppps);
|
---|
772 |
|
---|
773 | APIRET prc16FreeInfo(PQPROCSTAT16 pInfo);
|
---|
774 |
|
---|
775 | PQPROCESS16 prc16FindProcessFromName(PQPROCSTAT16 pInfo,
|
---|
776 | const char *pcszName);
|
---|
777 |
|
---|
778 | PQPROCESS16 prc16FindProcessFromPID(PQPROCSTAT16 pInfo,
|
---|
779 | ULONG ulPID);
|
---|
780 |
|
---|
781 | /********************************************************************
|
---|
782 | *
|
---|
783 | * DosQProcStat (16-bit) helpers
|
---|
784 | *
|
---|
785 | ********************************************************************/
|
---|
786 |
|
---|
787 | BOOL prc16QueryProcessInfo(PQPROCSTAT16 pps, USHORT usPID, PPRCPROCESS pprcp);
|
---|
788 |
|
---|
789 | ULONG prc16ForEachProcess(PFNWP pfnwpCallback, HWND hwnd, ULONG ulMsg, MPARAM mp1);
|
---|
790 |
|
---|
791 | ULONG prc16QueryThreadCount(PQPROCSTAT16 pps, USHORT usPID);
|
---|
792 |
|
---|
793 | BOOL prc16QueryThreadInfo(PQPROCSTAT16 pps, USHORT usPID, USHORT usTID, PPRCTHREAD pprct);
|
---|
794 |
|
---|
795 | ULONG prc16QueryThreadPriority(PQPROCSTAT16 pps, USHORT usPID, USHORT usTID);
|
---|
796 |
|
---|
797 | /********************************************************************
|
---|
798 | *
|
---|
799 | * DosQuerySysState (32-bit) interface
|
---|
800 | *
|
---|
801 | ********************************************************************/
|
---|
802 |
|
---|
803 | PQTOPLEVEL32 prc32GetInfo(APIRET *parc);
|
---|
804 |
|
---|
805 | VOID prc32FreeInfo(PQTOPLEVEL32 pInfo);
|
---|
806 |
|
---|
807 | PQPROCESS32 prc32FindProcessFromName(PQTOPLEVEL32 pInfo,
|
---|
808 | const char *pcszName);
|
---|
809 |
|
---|
810 | PQS32SEM16 prc32FindSem16(PQTOPLEVEL32 pInfo,
|
---|
811 | USHORT usSemID);
|
---|
812 |
|
---|
813 | PQS32SEM32 prc32FindSem32(PQTOPLEVEL32 pInfo,
|
---|
814 | USHORT usSemID);
|
---|
815 |
|
---|
816 | PQSHRMEM32 prc32FindShrMem(PQTOPLEVEL32 pInfo,
|
---|
817 | USHORT usShrMemID);
|
---|
818 |
|
---|
819 | PQMODULE32 prc32FindModule(PQTOPLEVEL32 pInfo,
|
---|
820 | USHORT usHModule);
|
---|
821 |
|
---|
822 | PQFILEDATA32 prc32FindFileData(PQTOPLEVEL32 pInfo,
|
---|
823 | USHORT usFileID);
|
---|
824 |
|
---|
825 | #endif
|
---|
826 |
|
---|
827 | #if __cplusplus
|
---|
828 | }
|
---|
829 | #endif
|
---|
830 |
|
---|