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