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