[145] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: killproc.c 1880 2015-10-12 18:26:16Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Kill a process
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1498] | 9 | Copyright (c) 2005, 2010 Steven H. Levine
|
---|
[145] | 10 |
|
---|
| 11 | 24 May 05 SHL Rework Win_Error usage
|
---|
[350] | 12 | 14 Jul 06 SHL Use Runtime_Error
|
---|
[404] | 13 | 29 Jul 06 SHL Use xfgets
|
---|
[533] | 14 | 03 Nov 06 SHL Renames
|
---|
| 15 | 03 Nov 06 SHL Count thread usage
|
---|
[775] | 16 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[793] | 17 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[828] | 18 | 02 Sep 07 GKY Replaced DosQProcStatus with DosQuerySysState to fix trap in thunk code
|
---|
[829] | 19 | 02 Sep 07 SHL Expand FillKillListThread2 stack to avoid exception in __TNK
|
---|
[1075] | 20 | 16 JUL 08 GKY Use TMP directory for temp files
|
---|
[1335] | 21 | 10 Dec 08 SHL Integrate exception handler support
|
---|
[1402] | 22 | 08 Mar 09 GKY Removed variable aurguments from docopyf and unlinkf (not used)
|
---|
[1480] | 23 | 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
|
---|
[1482] | 24 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
|
---|
| 25 | profile calls for user settings that work and are setable in more than one
|
---|
| 26 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that
|
---|
| 27 | aren't user settable; realappname should be used for setting applicable to
|
---|
| 28 | one or more miniapp but not to FM/2
|
---|
[1554] | 29 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10).
|
---|
| 30 | Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
| 31 | 20 Nov 10 GKY Check that pTmpDir IsValid and recreate if not found; Fixes hangs caused
|
---|
| 32 | by temp file creation failures.
|
---|
[1627] | 33 | 26 Aug 11 GKY Add a low mem version of xDosAlloc* wrappers; move error checking into all the
|
---|
| 34 | xDosAlloc* wrappers.
|
---|
[1738] | 35 | 22 Aug 14 JBS Ticket #519: Corrected mis-coded but probably harmless calls to strtol
|
---|
| 36 | and removed unneeded second parameter variables.
|
---|
[1859] | 37 | 12 Aug 15 JBS Ticket #522: Ensure no "highmem-unsafe" functions are called directly
|
---|
[1846] | 38 | Calls to unsafe Dos... functions have been changed to call the wrapped xDos... functions
|
---|
[145] | 39 |
|
---|
| 40 | ***********************************************************************/
|
---|
| 41 |
|
---|
[2] | 42 | #include <stdlib.h>
|
---|
| 43 | #include <string.h>
|
---|
| 44 | #include <ctype.h>
|
---|
| 45 | #include <limits.h>
|
---|
[350] | 46 |
|
---|
[907] | 47 | #define INCL_DOS
|
---|
| 48 | #define INCL_DOSERRORS
|
---|
| 49 | #define INCL_WIN
|
---|
| 50 | #define INCL_LONGLONG // dircnrs.h
|
---|
| 51 |
|
---|
[1188] | 52 | #include "fm3dll.h"
|
---|
[1224] | 53 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1209] | 54 | #include "init.h" // Data declaration(s)
|
---|
| 55 | #include "notebook.h" // Data declaration(s)
|
---|
| 56 | #include "mainwnd.h" // Data declaration(s)
|
---|
[2] | 57 | #include "fm3dlg.h"
|
---|
| 58 | #include "fm3str.h"
|
---|
[828] | 59 | #include "procstat.h"
|
---|
[907] | 60 | #include "errutil.h" // Dos_Error...
|
---|
| 61 | #include "strutil.h" // GetPString
|
---|
[1077] | 62 | #include "pathutil.h" // BldFullPathName
|
---|
[1163] | 63 | #include "killproc.h"
|
---|
| 64 | #include "systemf.h" // ShowSession
|
---|
[1188] | 65 | #include "common.h" // DecrThreadUsage, IncrThreadUsage
|
---|
| 66 | #include "notify.h" // Notify
|
---|
| 67 | #include "copyf.h" // unlinkf
|
---|
| 68 | #include "wrappers.h" // xfgets
|
---|
| 69 | #include "stristr.h" // stristr
|
---|
| 70 | #include "misc.h" // PostMsg
|
---|
[1036] | 71 | #include "fortify.h"
|
---|
[1335] | 72 | #include "excputil.h" // xbeginthread
|
---|
[1554] | 73 | #include "valid.h" // IsValidDir
|
---|
[2] | 74 |
|
---|
[1209] | 75 | // Data definitions
|
---|
[2] | 76 | #pragma data_seg(DATA2)
|
---|
| 77 |
|
---|
[350] | 78 | static PSZ pszSrcFile = __FILE__;
|
---|
[2] | 79 |
|
---|
[1209] | 80 | #pragma data_seg(GLOBAL1)
|
---|
| 81 | BOOL fUseQProcStat;
|
---|
| 82 | BOOL fUseQSysState;
|
---|
| 83 | PID mypid;
|
---|
| 84 |
|
---|
[551] | 85 | CHAR *GetDosPgmName(PID pid, CHAR * string)
|
---|
[350] | 86 | {
|
---|
[2] | 87 | HSWITCH hs;
|
---|
| 88 | SWCNTRL swctl;
|
---|
[551] | 89 | PCH pch;
|
---|
[2] | 90 |
|
---|
| 91 | *string = 0;
|
---|
[551] | 92 | hs = WinQuerySwitchHandle(0, pid);
|
---|
| 93 | if (hs) {
|
---|
| 94 | WinQuerySwitchEntry(hs, &swctl);
|
---|
[2] | 95 | pch = swctl.szSwtitle;
|
---|
[551] | 96 | while (*pch) {
|
---|
| 97 | if (*pch < 0x10)
|
---|
| 98 | if (pch != swctl.szSwtitle && *(pch - 1) == 0x20)
|
---|
| 99 | memmove(pch, pch + 1, strlen(pch));
|
---|
| 100 | else {
|
---|
| 101 | *pch = 0x20;
|
---|
| 102 | pch++;
|
---|
| 103 | }
|
---|
[2] | 104 | else
|
---|
[551] | 105 | pch++;
|
---|
[2] | 106 | }
|
---|
[551] | 107 | strcpy(string, swctl.szSwtitle);
|
---|
[2] | 108 | }
|
---|
[551] | 109 | if (!*string)
|
---|
| 110 | strcpy(string, GetPString(IDS_UNKNOWNDOSPROCTEXT));
|
---|
[2] | 111 | return string;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[551] | 114 | static VOID FillKillListThread2(VOID * arg)
|
---|
[350] | 115 | {
|
---|
[551] | 116 | HWND hwnd = *(HWND *) arg;
|
---|
| 117 | CHAR s[1036];
|
---|
| 118 | HAB thab;
|
---|
| 119 | HMQ thmq;
|
---|
| 120 | INT rc;
|
---|
| 121 | PROCESSINFO *ppi;
|
---|
| 122 | BUFFHEADER *pbh;
|
---|
| 123 | MODINFO *pmi;
|
---|
[2] | 124 |
|
---|
[1038] | 125 | # ifdef FORTIFY
|
---|
| 126 | Fortify_EnterScope();
|
---|
[1063] | 127 | # endif
|
---|
[2] | 128 | thab = WinInitialize(0);
|
---|
[551] | 129 | thmq = WinCreateMsgQueue(thab, 0);
|
---|
| 130 | WinCancelShutdown(thmq, TRUE);
|
---|
[533] | 131 | IncrThreadUsage();
|
---|
[2] | 132 |
|
---|
[551] | 133 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1628] | 134 | if (!xDosAllocMem((PVOID) & pbh, USHRT_MAX + 4096, pszSrcFile, __LINE__)) {
|
---|
[829] | 135 | rc = DosQProcStatus((ULONG *)pbh, USHRT_MAX);
|
---|
[350] | 136 | if (!rc) {
|
---|
[2] | 137 | ppi = pbh->ppi;
|
---|
[551] | 138 | while (ppi->ulEndIndicator != PROCESS_END_INDICATOR) {
|
---|
| 139 | if (ppi->pid != mypid) {
|
---|
| 140 | pmi = pbh->pmi;
|
---|
| 141 | while (pmi && ppi->hModRef != pmi->hMod)
|
---|
| 142 | pmi = pmi->pNext;
|
---|
| 143 | if (pmi) {
|
---|
| 144 | sprintf(s, "%04x ", ppi->pid);
|
---|
| 145 | if (!stricmp(pmi->szModName, "SYSINIT"))
|
---|
| 146 | GetDosPgmName(ppi->pid, s + strlen(s));
|
---|
[1077] | 147 | else {
|
---|
[551] | 148 | if (*pmi->szModName)
|
---|
[1077] | 149 | strcat(s, pmi->szModName);
|
---|
[551] | 150 | else
|
---|
| 151 | strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
|
---|
[350] | 152 | }
|
---|
[551] | 153 | if (WinIsWindow(thab, hwnd)) {
|
---|
| 154 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_INSERTITEM,
|
---|
| 155 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 156 | MPFROMP(s));
|
---|
| 157 | }
|
---|
| 158 | else
|
---|
| 159 | break;
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
| 162 | ppi = (PPROCESSINFO) (ppi->ptiFirst + ppi->usThreadCount);
|
---|
| 163 | } // while
|
---|
[2] | 164 | }
|
---|
| 165 | DosFreeMem(pbh);
|
---|
| 166 | }
|
---|
[350] | 167 |
|
---|
[551] | 168 | if (WinIsWindow(thab, hwnd))
|
---|
| 169 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
[2] | 170 | WinDestroyMsgQueue(thmq);
|
---|
[533] | 171 | DecrThreadUsage();
|
---|
[2] | 172 | WinTerminate(thab);
|
---|
[1038] | 173 | # ifdef FORTIFY
|
---|
[1063] | 174 | Fortify_LeaveScope();
|
---|
| 175 | # endif
|
---|
[2] | 176 | }
|
---|
| 177 |
|
---|
[828] | 178 | static VOID FillKillListThread3(VOID * arg)
|
---|
| 179 | {
|
---|
| 180 | HWND hwnd = *(HWND *) arg;
|
---|
| 181 | CHAR s[1036];
|
---|
| 182 | HAB thab;
|
---|
| 183 | HMQ thmq;
|
---|
| 184 | INT rc;
|
---|
| 185 | QSPREC *ppi;
|
---|
| 186 | QSPTRREC *pbh;
|
---|
| 187 | QSLREC *pmi;
|
---|
| 188 |
|
---|
[1038] | 189 | # ifdef FORTIFY
|
---|
| 190 | Fortify_EnterScope();
|
---|
[1063] | 191 | # endif
|
---|
[828] | 192 | thab = WinInitialize(0);
|
---|
| 193 | thmq = WinCreateMsgQueue(thab, 0);
|
---|
| 194 | WinCancelShutdown(thmq, TRUE);
|
---|
| 195 | IncrThreadUsage();
|
---|
| 196 |
|
---|
| 197 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1628] | 198 | if (!xDosAllocMem((PVOID) & pbh, USHRT_MAX + 4096, pszSrcFile, __LINE__)) {
|
---|
[828] | 199 | rc = DosQuerySysState(QS_PROCESS | QS_MTE, 0, 0, 0, pbh, USHRT_MAX);
|
---|
| 200 | if (!rc) {
|
---|
| 201 | ppi = pbh->pProcRec;
|
---|
| 202 | while (ppi->RecType == 1) {
|
---|
| 203 | if (ppi->pid != mypid) {
|
---|
| 204 | pmi = pbh->pLibRec;
|
---|
| 205 | while (pmi && ppi->hMte != pmi->hmte)
|
---|
| 206 | pmi = pmi->pNextRec;
|
---|
| 207 | if (pmi) {
|
---|
| 208 | sprintf(s, "%04x ", ppi->pid);
|
---|
| 209 | if (!stricmp((CHAR *) pmi->pName, "SYSINIT"))
|
---|
| 210 | GetDosPgmName(ppi->pid, s + strlen(s));
|
---|
[1077] | 211 | else {
|
---|
[828] | 212 | if (*pmi->pName)
|
---|
[1077] | 213 | strcat(s, (CHAR *) pmi->pName);
|
---|
[828] | 214 | else
|
---|
| 215 | strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
|
---|
| 216 | }
|
---|
| 217 | if (WinIsWindow(thab, hwnd)) {
|
---|
| 218 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_INSERTITEM,
|
---|
| 219 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 220 | MPFROMP(s));
|
---|
| 221 | }
|
---|
| 222 | else
|
---|
| 223 | break;
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
[1077] | 226 | ppi = (QSPREC *) (ppi->pThrdRec + ppi->cTCB); // 22 Jun 08 SHL fixme to know why this looks odd
|
---|
[828] | 227 | } // while
|
---|
| 228 | }
|
---|
| 229 | DosFreeMem(pbh);
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | if (WinIsWindow(thab, hwnd))
|
---|
| 233 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
| 234 | WinDestroyMsgQueue(thmq);
|
---|
| 235 | DecrThreadUsage();
|
---|
| 236 | WinTerminate(thab);
|
---|
[1038] | 237 | # ifdef FORTIFY
|
---|
[1063] | 238 | Fortify_LeaveScope();
|
---|
| 239 | # endif
|
---|
[828] | 240 | }
|
---|
| 241 |
|
---|
[551] | 242 | static VOID FillKillListThread(VOID * arg)
|
---|
[350] | 243 | {
|
---|
[551] | 244 | HWND hwnd = *(HWND *) arg;
|
---|
| 245 | CHAR s[1036], progname[1027], *p;
|
---|
| 246 | HAB thab;
|
---|
| 247 | HMQ thmq;
|
---|
[2] | 248 | FILE *fp;
|
---|
[551] | 249 | BOOL foundstart = FALSE;
|
---|
| 250 | INT rc;
|
---|
[2] | 251 | CHAR *startstring = "Process and Thread Information";
|
---|
| 252 | CHAR *endstring = "System Semaphore Information";
|
---|
[551] | 253 | PID pid;
|
---|
| 254 | HFILE oldstdout, newstdout;
|
---|
[1544] | 255 | CHAR *mode;
|
---|
[2] | 256 |
|
---|
| 257 | DosError(FERR_DISABLEHARDERR);
|
---|
| 258 |
|
---|
[1038] | 259 | # ifdef FORTIFY
|
---|
| 260 | Fortify_EnterScope();
|
---|
[1063] | 261 | # endif
|
---|
[2] | 262 | thab = WinInitialize(0);
|
---|
[551] | 263 | thmq = WinCreateMsgQueue(thab, 0);
|
---|
| 264 | WinCancelShutdown(thmq, TRUE);
|
---|
[533] | 265 | IncrThreadUsage();
|
---|
[2] | 266 |
|
---|
[551] | 267 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1554] | 268 | if (pTmpDir && !IsValidDir(pTmpDir))
|
---|
| 269 | DosCreateDir(pTmpDir, 0);
|
---|
[1075] | 270 | BldFullPathName(s, pTmpDir, "$PSTAT#$.#$#");
|
---|
[1402] | 271 | unlinkf(s);
|
---|
[1544] | 272 | mode = "w";
|
---|
| 273 | fp = xfopen(s, mode, pszSrcFile, __LINE__, TRUE);
|
---|
[551] | 274 | if (!fp) {
|
---|
| 275 | Win_Error(NULLHANDLE, HWND_DESKTOP, __FILE__, __LINE__,
|
---|
| 276 | GetPString(IDS_REDIRECTERRORTEXT));
|
---|
[350] | 277 | goto Abort;
|
---|
| 278 | }
|
---|
| 279 | else {
|
---|
[2] | 280 | newstdout = -1;
|
---|
[1846] | 281 | rc = xDosDupHandle(fileno(stdout), &newstdout);
|
---|
[350] | 282 | if (rc)
|
---|
[1398] | 283 | Dos_Error(MB_CANCEL, rc, hwnd, __FILE__, __LINE__, PCSZ_DOSDUPHANDLE);
|
---|
[2] | 284 | oldstdout = fileno(stdout);
|
---|
[1846] | 285 | xDosDupHandle(fileno(fp), &oldstdout);
|
---|
[2] | 286 | rc = runemf2(SEPARATE | INVISIBLE | FULLSCREEN | BACKGROUND | WAIT,
|
---|
[1077] | 287 | hwnd, pszSrcFile, __LINE__, NULL, NULL,
|
---|
| 288 | "%s", "PSTAT.EXE /C");
|
---|
[2] | 289 | oldstdout = fileno(stdout);
|
---|
[1846] | 290 | xDosDupHandle(newstdout, &oldstdout);
|
---|
[2] | 291 | DosClose(newstdout);
|
---|
| 292 | fclose(fp);
|
---|
[451] | 293 | // fixme to be gone?
|
---|
[551] | 294 | if (rc == -1) {
|
---|
[2] | 295 | saymsg(MB_CANCEL,
|
---|
[551] | 296 | hwnd,
|
---|
| 297 | GetPString(IDS_ARGHTEXT), GetPString(IDS_CANTRUNPSTATTEXT));
|
---|
[2] | 298 | goto Abort;
|
---|
| 299 | }
|
---|
| 300 | }
|
---|
[1544] | 301 | mode = "r";
|
---|
| 302 | fp = xfopen(s, mode, pszSrcFile, __LINE__, TRUE);
|
---|
[404] | 303 | if (fp) {
|
---|
| 304 | while (!feof(fp)) {
|
---|
[551] | 305 | strset(s, 0);
|
---|
| 306 | if (!xfgets(s, 1025, fp, pszSrcFile, __LINE__))
|
---|
| 307 | break;
|
---|
[404] | 308 | if (!foundstart) {
|
---|
[551] | 309 | if (*s == ' ' && strstr(s, startstring))
|
---|
| 310 | foundstart = TRUE;
|
---|
[2] | 311 | }
|
---|
| 312 | else {
|
---|
[551] | 313 | if (*s == ' ' && strstr(s, endstring))
|
---|
| 314 | break;
|
---|
| 315 | if (*s == ' ' && s[5] == ' ' && isxdigit(s[1]) &&
|
---|
| 316 | isxdigit(s[2]) && isxdigit(s[3]) && isxdigit(s[4])) {
|
---|
[1738] | 317 | pid = strtol(&s[1], NULL, 16);
|
---|
[551] | 318 | if (pid && pid != mypid) {
|
---|
| 319 | strcpy(progname, &s[30]);
|
---|
| 320 | p = strchr(progname, ' ');
|
---|
| 321 | if (p)
|
---|
| 322 | *p = 0;
|
---|
| 323 | if (!stristr(progname, "\\PSTAT.EXE")) {
|
---|
| 324 | sprintf(s, "%04x %s", pid, progname);
|
---|
| 325 | WinSendDlgItemMsg(hwnd,
|
---|
| 326 | KILL_LISTBOX,
|
---|
| 327 | LM_INSERTITEM,
|
---|
| 328 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 329 | MPFROMP(s));
|
---|
| 330 | }
|
---|
| 331 | }
|
---|
| 332 | }
|
---|
[2] | 333 | }
|
---|
| 334 | }
|
---|
| 335 | fclose(fp);
|
---|
| 336 | }
|
---|
| 337 | Abort:
|
---|
[1075] | 338 | BldFullPathName(s, pTmpDir, "$PSTAT#$.#$#");
|
---|
[1846] | 339 | xDosForceDelete(s);
|
---|
[551] | 340 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
[2] | 341 | WinDestroyMsgQueue(thmq);
|
---|
[533] | 342 | DecrThreadUsage();
|
---|
[2] | 343 | WinTerminate(thab);
|
---|
[1038] | 344 | # ifdef FORTIFY
|
---|
[1063] | 345 | Fortify_LeaveScope();
|
---|
| 346 | # endif
|
---|
[2] | 347 | }
|
---|
| 348 |
|
---|
[551] | 349 | MRESULT EXPENTRY KillDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[350] | 350 | {
|
---|
[551] | 351 | SHORT sSelect;
|
---|
| 352 | PID pid;
|
---|
| 353 | static BOOL listdone;
|
---|
| 354 | static HPOINTER hptrIcon = (HPOINTER) 0;
|
---|
[2] | 355 |
|
---|
[551] | 356 | switch (msg) {
|
---|
| 357 | case WM_INITDLG:
|
---|
| 358 | hptrIcon = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, KILL_FRAME);
|
---|
| 359 | WinDefDlgProc(hwnd, WM_SETICON, MPFROMLONG(hptrIcon), MPVOID);
|
---|
| 360 | WinCheckButton(hwnd, KILL_CHECKBOX, fUseQProcStat);
|
---|
[828] | 361 | WinCheckButton(hwnd, KILL2_CHECKBOX, fUseQSysState);
|
---|
| 362 | if (WinQueryButtonCheckstate(hwnd, KILL2_CHECKBOX)) {
|
---|
| 363 | WinCheckButton(hwnd, KILL_CHECKBOX, FALSE);
|
---|
| 364 | WinEnableWindow(WinWindowFromID(hwnd, KILL_CHECKBOX), FALSE);
|
---|
| 365 | }
|
---|
| 366 | if (WinQueryButtonCheckstate(hwnd, KILL_CHECKBOX)) {
|
---|
| 367 | WinCheckButton(hwnd, KILL2_CHECKBOX, FALSE);
|
---|
| 368 | WinEnableWindow(WinWindowFromID(hwnd, KILL2_CHECKBOX), FALSE);
|
---|
| 369 | }
|
---|
[551] | 370 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(KILL_RESCAN, 0), MPVOID);
|
---|
| 371 | break;
|
---|
[2] | 372 |
|
---|
[551] | 373 | case UM_CONTAINER_FILLED:
|
---|
| 374 | listdone = TRUE;
|
---|
| 375 | if ((SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 376 | KILL_LISTBOX,
|
---|
| 377 | LM_QUERYITEMCOUNT, MPVOID, MPVOID) == 0) {
|
---|
| 378 | if (!fUseQProcStat)
|
---|
| 379 | saymsg(MB_CANCEL,
|
---|
| 380 | hwnd,
|
---|
| 381 | GetPString(IDS_ICHOKEDTEXT), GetPString(IDS_ISPSTATTHERETEXT));
|
---|
| 382 | else
|
---|
| 383 | saymsg(MB_CANCEL,
|
---|
| 384 | hwnd,
|
---|
| 385 | GetPString(IDS_ICHOKEDTEXT),
|
---|
| 386 | GetPString(IDS_DOSQPROCSTATFAILEDTEXT));
|
---|
| 387 | }
|
---|
| 388 | return 0;
|
---|
[2] | 389 |
|
---|
[551] | 390 | case WM_CONTROL:
|
---|
| 391 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 392 | case KILL_CHECKBOX:
|
---|
| 393 | fUseQProcStat = WinQueryButtonCheckstate(hwnd, KILL_CHECKBOX);
|
---|
[1505] | 394 | PrfWriteProfileData(fmprof, FM3Str, "UseQProcStat",
|
---|
[1482] | 395 | &fUseQProcStat, sizeof(BOOL));
|
---|
[551] | 396 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(KILL_RESCAN, 0), MPVOID);
|
---|
[828] | 397 | if (WinQueryButtonCheckstate(hwnd, KILL_CHECKBOX)) {
|
---|
| 398 | WinCheckButton(hwnd, KILL2_CHECKBOX, FALSE);
|
---|
| 399 | WinEnableWindow(WinWindowFromID(hwnd, KILL2_CHECKBOX), FALSE);
|
---|
| 400 | }
|
---|
| 401 | else
|
---|
| 402 | WinEnableWindow(WinWindowFromID(hwnd, KILL2_CHECKBOX), TRUE);
|
---|
[551] | 403 | break;
|
---|
[828] | 404 | case KILL2_CHECKBOX:
|
---|
| 405 | fUseQSysState = WinQueryButtonCheckstate(hwnd, KILL2_CHECKBOX);
|
---|
[1505] | 406 | PrfWriteProfileData(fmprof, FM3Str, "UseQSysState",
|
---|
[1482] | 407 | &fUseQSysState, sizeof(BOOL));
|
---|
[828] | 408 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(KILL_RESCAN, 0), MPVOID);
|
---|
| 409 | if (WinQueryButtonCheckstate(hwnd, KILL2_CHECKBOX)) {
|
---|
| 410 | WinCheckButton(hwnd, KILL_CHECKBOX, FALSE);
|
---|
| 411 | WinEnableWindow(WinWindowFromID(hwnd, KILL_CHECKBOX), FALSE);
|
---|
| 412 | }
|
---|
| 413 | else
|
---|
| 414 | WinEnableWindow(WinWindowFromID(hwnd, KILL_CHECKBOX), TRUE);
|
---|
| 415 | break;
|
---|
[2] | 416 |
|
---|
[551] | 417 | case KILL_LISTBOX:
|
---|
| 418 | switch (SHORT2FROMMP(mp2)) {
|
---|
| 419 | case LN_ENTER:
|
---|
| 420 | WinSendDlgItemMsg(hwnd, DID_OK, BM_CLICK, MPFROMSHORT(TRUE), MPVOID);
|
---|
| 421 | break;
|
---|
[2] | 422 | }
|
---|
[551] | 423 | break;
|
---|
[2] | 424 |
|
---|
[551] | 425 | default:
|
---|
[2] | 426 | break;
|
---|
[551] | 427 | }
|
---|
| 428 | return 0;
|
---|
[2] | 429 |
|
---|
[551] | 430 | case WM_ADJUSTWINDOWPOS:
|
---|
| 431 | PostMsg(hwnd, UM_STRETCH, MPVOID, MPVOID);
|
---|
| 432 | break;
|
---|
[2] | 433 |
|
---|
[551] | 434 | case UM_STRETCH:
|
---|
| 435 | {
|
---|
| 436 | SWP swpC, swp, swpH;
|
---|
| 437 |
|
---|
| 438 | WinQueryWindowPos(hwnd, &swp);
|
---|
| 439 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE))) {
|
---|
| 440 | WinQueryWindowPos(WinWindowFromID(hwnd, KILL_LISTBOX), &swpC);
|
---|
| 441 | WinQueryWindowPos(WinWindowFromID(hwnd, KILL_HDR), &swpH);
|
---|
| 442 | WinSetWindowPos(WinWindowFromID(hwnd, KILL_LISTBOX), HWND_TOP,
|
---|
| 443 | SysVal(SV_CXSIZEBORDER),
|
---|
| 444 | swpC.y,
|
---|
| 445 | swp.cx - (SysVal(SV_CXSIZEBORDER) * 2),
|
---|
| 446 | ((swp.cy - swpC.y) - (SysVal(SV_CYTITLEBAR) +
|
---|
| 447 | SysVal(SV_CYSIZEBORDER)) -
|
---|
| 448 | (swpH.cy + 8)), SWP_MOVE | SWP_SIZE);
|
---|
| 449 | WinSetWindowPos(WinWindowFromID(hwnd, KILL_HDR), HWND_TOP,
|
---|
| 450 | SysVal(SV_CXSIZEBORDER) + 4,
|
---|
| 451 | swpC.y + ((swp.cy - swpC.y) -
|
---|
| 452 | (SysVal(SV_CYTITLEBAR) +
|
---|
| 453 | SysVal(SV_CYSIZEBORDER)) -
|
---|
| 454 | (swpH.cy + 4)), swpH.cx, swpH.cy, SWP_MOVE);
|
---|
[2] | 455 | }
|
---|
[551] | 456 | }
|
---|
| 457 | return 0;
|
---|
[2] | 458 |
|
---|
[551] | 459 | case WM_COMMAND:
|
---|
| 460 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 461 | case KILL_RESCAN:
|
---|
| 462 | listdone = FALSE;
|
---|
| 463 | if (fUseQProcStat) {
|
---|
[1335] | 464 | if (xbeginthread(FillKillListThread2,
|
---|
| 465 | 65536 + 8192,
|
---|
| 466 | &hwnd,
|
---|
| 467 | pszSrcFile,
|
---|
| 468 | __LINE__) == -1)
|
---|
| 469 | {
|
---|
| 470 | WinDismissDlg(hwnd, 0);
|
---|
| 471 | }
|
---|
| 472 | else
|
---|
[1880] | 473 | DosSleep(100);
|
---|
[551] | 474 | }
|
---|
[828] | 475 | else if (fUseQSysState)
|
---|
[1335] | 476 | if (xbeginthread(FillKillListThread3,
|
---|
| 477 | 65536,
|
---|
| 478 | &hwnd,
|
---|
| 479 | pszSrcFile,
|
---|
| 480 | __LINE__) == -1)
|
---|
| 481 | {
|
---|
| 482 | WinDismissDlg(hwnd, 0);
|
---|
| 483 | }
|
---|
| 484 | else
|
---|
[1880] | 485 | DosSleep(100);
|
---|
[1335] | 486 | else {
|
---|
| 487 | if (xbeginthread(FillKillListThread,
|
---|
| 488 | 65536,
|
---|
| 489 | &hwnd,
|
---|
| 490 | pszSrcFile,
|
---|
| 491 | __LINE__) == -1)
|
---|
| 492 | {
|
---|
| 493 | WinDismissDlg(hwnd, 0);
|
---|
| 494 | }
|
---|
[828] | 495 | else
|
---|
[1077] | 496 | DosSleep(100); // 05 Aug 07 GKY 250
|
---|
[551] | 497 | }
|
---|
| 498 | break;
|
---|
[2] | 499 |
|
---|
[551] | 500 | case KILL_SHOW:
|
---|
| 501 | case DID_OK:
|
---|
| 502 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 503 | KILL_LISTBOX,
|
---|
| 504 | LM_QUERYSELECTION,
|
---|
| 505 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
| 506 | if (sSelect >= 0) {
|
---|
[2] | 507 |
|
---|
[1738] | 508 | CHAR s[31];
|
---|
[551] | 509 | APIRET error;
|
---|
[2] | 510 |
|
---|
[551] | 511 | *s = 0;
|
---|
| 512 | WinSendDlgItemMsg(hwnd,
|
---|
| 513 | KILL_LISTBOX,
|
---|
| 514 | LM_QUERYITEMTEXT,
|
---|
| 515 | MPFROM2SHORT(sSelect, 30), MPFROMP(s));
|
---|
| 516 | if (*s) {
|
---|
[1738] | 517 | pid = strtol(s, NULL, 16);
|
---|
[551] | 518 | if (pid) {
|
---|
| 519 | if (SHORT1FROMMP(mp1) == DID_OK) {
|
---|
| 520 | error = DosKillProcess(DKP_PROCESS, pid);
|
---|
| 521 | if (error && error != ERROR_INVALID_PROCID) {
|
---|
| 522 | Dos_Error(MB_CANCEL,
|
---|
| 523 | error,
|
---|
| 524 | hwnd,
|
---|
| 525 | __FILE__,
|
---|
| 526 | __LINE__, GetPString(IDS_DOSKILLFAILEDTEXT));
|
---|
| 527 | }
|
---|
| 528 | else
|
---|
| 529 | WinSendDlgItemMsg(hwnd,
|
---|
| 530 | KILL_LISTBOX,
|
---|
| 531 | LM_DELETEITEM,
|
---|
| 532 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
| 533 | }
|
---|
| 534 | else if (!ShowSession(hwnd, pid))
|
---|
| 535 | Notify(GetPString(IDS_SORRYCANTSHOWTEXT));
|
---|
| 536 | }
|
---|
| 537 | }
|
---|
[2] | 538 | }
|
---|
[551] | 539 | break;
|
---|
[2] | 540 |
|
---|
[551] | 541 | case DID_CANCEL:
|
---|
| 542 | if (!listdone)
|
---|
| 543 | Runtime_Error(pszSrcFile, __LINE__, "busy");
|
---|
| 544 | else
|
---|
| 545 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 546 | break;
|
---|
| 547 |
|
---|
[551] | 548 | case IDM_HELP:
|
---|
| 549 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
| 550 | hwnd,
|
---|
| 551 | GetPString(IDS_KILLPROCHELPTITLETEXT),
|
---|
| 552 | GetPString(IDS_KILLPROCHELPTEXT));
|
---|
[2] | 553 | break;
|
---|
[551] | 554 | }
|
---|
| 555 | return 0;
|
---|
| 556 |
|
---|
| 557 | case WM_CLOSE:
|
---|
| 558 | if (!listdone) {
|
---|
| 559 | Runtime_Error(pszSrcFile, __LINE__, "busy");
|
---|
| 560 | return 0;
|
---|
| 561 | }
|
---|
| 562 | break;
|
---|
| 563 |
|
---|
| 564 | case WM_DESTROY:
|
---|
| 565 | if (hptrIcon)
|
---|
| 566 | WinDestroyPointer(hptrIcon);
|
---|
| 567 | hptrIcon = (HPOINTER) 0;
|
---|
| 568 | break;
|
---|
[2] | 569 | }
|
---|
[551] | 570 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 571 | }
|
---|
[793] | 572 |
|
---|
| 573 | #pragma alloc_text(KILLPROC,FillKillListThread,FillKillListThread2,GetDosPgmName,KillDlgProc)
|
---|
[830] | 574 | #pragma alloc_text(KILLPROC,FillKillListThread3)
|
---|