[145] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: killproc.c 1544 2010-09-30 13:00:59Z 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
|
---|
[1498] | 29 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
[145] | 30 |
|
---|
| 31 | ***********************************************************************/
|
---|
| 32 |
|
---|
[2] | 33 | #include <stdlib.h>
|
---|
| 34 | #include <string.h>
|
---|
| 35 | #include <ctype.h>
|
---|
[1335] | 36 | // #include <process.h>
|
---|
[2] | 37 | #include <limits.h>
|
---|
[350] | 38 |
|
---|
[907] | 39 | #define INCL_DOS
|
---|
| 40 | #define INCL_DOSERRORS
|
---|
| 41 | #define INCL_WIN
|
---|
| 42 | #define INCL_LONGLONG // dircnrs.h
|
---|
| 43 |
|
---|
[1188] | 44 | #include "fm3dll.h"
|
---|
[1224] | 45 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1209] | 46 | #include "init.h" // Data declaration(s)
|
---|
| 47 | #include "notebook.h" // Data declaration(s)
|
---|
| 48 | #include "mainwnd.h" // Data declaration(s)
|
---|
[2] | 49 | #include "fm3dlg.h"
|
---|
| 50 | #include "fm3str.h"
|
---|
[828] | 51 | #include "procstat.h"
|
---|
[907] | 52 | #include "errutil.h" // Dos_Error...
|
---|
| 53 | #include "strutil.h" // GetPString
|
---|
[1077] | 54 | #include "pathutil.h" // BldFullPathName
|
---|
[1163] | 55 | #include "killproc.h"
|
---|
| 56 | #include "systemf.h" // ShowSession
|
---|
[1188] | 57 | #include "common.h" // DecrThreadUsage, IncrThreadUsage
|
---|
| 58 | #include "notify.h" // Notify
|
---|
| 59 | #include "copyf.h" // unlinkf
|
---|
| 60 | #include "wrappers.h" // xfgets
|
---|
| 61 | #include "stristr.h" // stristr
|
---|
| 62 | #include "misc.h" // PostMsg
|
---|
[1036] | 63 | #include "fortify.h"
|
---|
[1335] | 64 | #include "excputil.h" // xbeginthread
|
---|
[2] | 65 |
|
---|
[1209] | 66 | // Data definitions
|
---|
[2] | 67 | #pragma data_seg(DATA2)
|
---|
| 68 |
|
---|
[350] | 69 | static PSZ pszSrcFile = __FILE__;
|
---|
[2] | 70 |
|
---|
[1209] | 71 | #pragma data_seg(GLOBAL1)
|
---|
| 72 | BOOL fUseQProcStat;
|
---|
| 73 | BOOL fUseQSysState;
|
---|
| 74 | PID mypid;
|
---|
| 75 |
|
---|
[551] | 76 | CHAR *GetDosPgmName(PID pid, CHAR * string)
|
---|
[350] | 77 | {
|
---|
[2] | 78 | HSWITCH hs;
|
---|
| 79 | SWCNTRL swctl;
|
---|
[551] | 80 | PCH pch;
|
---|
[2] | 81 |
|
---|
| 82 | *string = 0;
|
---|
[551] | 83 | hs = WinQuerySwitchHandle(0, pid);
|
---|
| 84 | if (hs) {
|
---|
| 85 | WinQuerySwitchEntry(hs, &swctl);
|
---|
[2] | 86 | pch = swctl.szSwtitle;
|
---|
[551] | 87 | while (*pch) {
|
---|
| 88 | if (*pch < 0x10)
|
---|
| 89 | if (pch != swctl.szSwtitle && *(pch - 1) == 0x20)
|
---|
| 90 | memmove(pch, pch + 1, strlen(pch));
|
---|
| 91 | else {
|
---|
| 92 | *pch = 0x20;
|
---|
| 93 | pch++;
|
---|
| 94 | }
|
---|
[2] | 95 | else
|
---|
[551] | 96 | pch++;
|
---|
[2] | 97 | }
|
---|
[551] | 98 | strcpy(string, swctl.szSwtitle);
|
---|
[2] | 99 | }
|
---|
[551] | 100 | if (!*string)
|
---|
| 101 | strcpy(string, GetPString(IDS_UNKNOWNDOSPROCTEXT));
|
---|
[2] | 102 | return string;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[551] | 105 | static VOID FillKillListThread2(VOID * arg)
|
---|
[350] | 106 | {
|
---|
[551] | 107 | HWND hwnd = *(HWND *) arg;
|
---|
| 108 | CHAR s[1036];
|
---|
| 109 | HAB thab;
|
---|
| 110 | HMQ thmq;
|
---|
| 111 | INT rc;
|
---|
| 112 | PROCESSINFO *ppi;
|
---|
| 113 | BUFFHEADER *pbh;
|
---|
| 114 | MODINFO *pmi;
|
---|
[2] | 115 |
|
---|
[1038] | 116 | # ifdef FORTIFY
|
---|
| 117 | Fortify_EnterScope();
|
---|
[1063] | 118 | # endif
|
---|
[2] | 119 | thab = WinInitialize(0);
|
---|
[551] | 120 | thmq = WinCreateMsgQueue(thab, 0);
|
---|
| 121 | WinCancelShutdown(thmq, TRUE);
|
---|
[533] | 122 | IncrThreadUsage();
|
---|
[2] | 123 |
|
---|
[551] | 124 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1438] | 125 | rc = xDosAllocMem((PVOID) & pbh, USHRT_MAX + 4096,
|
---|
[1439] | 126 | PAG_COMMIT | PAG_READ | PAG_WRITE, pszSrcFile, __LINE__);
|
---|
[350] | 127 | if (rc)
|
---|
[551] | 128 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 129 | GetPString(IDS_OUTOFMEMORY));
|
---|
[350] | 130 | else {
|
---|
[829] | 131 | rc = DosQProcStatus((ULONG *)pbh, USHRT_MAX);
|
---|
[350] | 132 | if (!rc) {
|
---|
[2] | 133 | ppi = pbh->ppi;
|
---|
[551] | 134 | while (ppi->ulEndIndicator != PROCESS_END_INDICATOR) {
|
---|
| 135 | if (ppi->pid != mypid) {
|
---|
| 136 | pmi = pbh->pmi;
|
---|
| 137 | while (pmi && ppi->hModRef != pmi->hMod)
|
---|
| 138 | pmi = pmi->pNext;
|
---|
| 139 | if (pmi) {
|
---|
| 140 | sprintf(s, "%04x ", ppi->pid);
|
---|
| 141 | if (!stricmp(pmi->szModName, "SYSINIT"))
|
---|
| 142 | GetDosPgmName(ppi->pid, s + strlen(s));
|
---|
[1077] | 143 | else {
|
---|
[551] | 144 | if (*pmi->szModName)
|
---|
[1077] | 145 | strcat(s, pmi->szModName);
|
---|
[551] | 146 | else
|
---|
| 147 | strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
|
---|
[350] | 148 | }
|
---|
[551] | 149 | if (WinIsWindow(thab, hwnd)) {
|
---|
| 150 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_INSERTITEM,
|
---|
| 151 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 152 | MPFROMP(s));
|
---|
| 153 | }
|
---|
| 154 | else
|
---|
| 155 | break;
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | ppi = (PPROCESSINFO) (ppi->ptiFirst + ppi->usThreadCount);
|
---|
| 159 | } // while
|
---|
[2] | 160 | }
|
---|
| 161 | DosFreeMem(pbh);
|
---|
| 162 | }
|
---|
[350] | 163 |
|
---|
[551] | 164 | if (WinIsWindow(thab, hwnd))
|
---|
| 165 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
[2] | 166 | WinDestroyMsgQueue(thmq);
|
---|
[533] | 167 | DecrThreadUsage();
|
---|
[2] | 168 | WinTerminate(thab);
|
---|
[1038] | 169 | # ifdef FORTIFY
|
---|
[1063] | 170 | Fortify_LeaveScope();
|
---|
| 171 | # endif
|
---|
[2] | 172 | }
|
---|
| 173 |
|
---|
[828] | 174 | static VOID FillKillListThread3(VOID * arg)
|
---|
| 175 | {
|
---|
| 176 | HWND hwnd = *(HWND *) arg;
|
---|
| 177 | CHAR s[1036];
|
---|
| 178 | HAB thab;
|
---|
| 179 | HMQ thmq;
|
---|
| 180 | INT rc;
|
---|
| 181 | QSPREC *ppi;
|
---|
| 182 | QSPTRREC *pbh;
|
---|
| 183 | QSLREC *pmi;
|
---|
| 184 |
|
---|
[1038] | 185 | # ifdef FORTIFY
|
---|
| 186 | Fortify_EnterScope();
|
---|
[1063] | 187 | # endif
|
---|
[828] | 188 | thab = WinInitialize(0);
|
---|
| 189 | thmq = WinCreateMsgQueue(thab, 0);
|
---|
| 190 | WinCancelShutdown(thmq, TRUE);
|
---|
| 191 | IncrThreadUsage();
|
---|
| 192 |
|
---|
| 193 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1438] | 194 | rc = xDosAllocMem((PVOID) & pbh, USHRT_MAX + 4096,
|
---|
[1439] | 195 | PAG_COMMIT | PAG_READ | PAG_WRITE, pszSrcFile, __LINE__);
|
---|
[828] | 196 | if (rc)
|
---|
| 197 | Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 198 | GetPString(IDS_OUTOFMEMORY));
|
---|
| 199 | else {
|
---|
| 200 | rc = DosQuerySysState(QS_PROCESS | QS_MTE, 0, 0, 0, pbh, USHRT_MAX);
|
---|
| 201 | if (!rc) {
|
---|
| 202 | ppi = pbh->pProcRec;
|
---|
| 203 | while (ppi->RecType == 1) {
|
---|
| 204 | if (ppi->pid != mypid) {
|
---|
| 205 | pmi = pbh->pLibRec;
|
---|
| 206 | while (pmi && ppi->hMte != pmi->hmte)
|
---|
| 207 | pmi = pmi->pNextRec;
|
---|
| 208 | if (pmi) {
|
---|
| 209 | sprintf(s, "%04x ", ppi->pid);
|
---|
| 210 | if (!stricmp((CHAR *) pmi->pName, "SYSINIT"))
|
---|
| 211 | GetDosPgmName(ppi->pid, s + strlen(s));
|
---|
[1077] | 212 | else {
|
---|
[828] | 213 | if (*pmi->pName)
|
---|
[1077] | 214 | strcat(s, (CHAR *) pmi->pName);
|
---|
[828] | 215 | else
|
---|
| 216 | strcat(s, GetPString(IDS_UNKNOWNPROCTEXT));
|
---|
| 217 | }
|
---|
| 218 | if (WinIsWindow(thab, hwnd)) {
|
---|
| 219 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_INSERTITEM,
|
---|
| 220 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
| 221 | MPFROMP(s));
|
---|
| 222 | }
|
---|
| 223 | else
|
---|
| 224 | break;
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
[1077] | 227 | ppi = (QSPREC *) (ppi->pThrdRec + ppi->cTCB); // 22 Jun 08 SHL fixme to know why this looks odd
|
---|
[828] | 228 | } // while
|
---|
| 229 | }
|
---|
| 230 | DosFreeMem(pbh);
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | if (WinIsWindow(thab, hwnd))
|
---|
| 234 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
| 235 | WinDestroyMsgQueue(thmq);
|
---|
| 236 | DecrThreadUsage();
|
---|
| 237 | WinTerminate(thab);
|
---|
[1038] | 238 | # ifdef FORTIFY
|
---|
[1063] | 239 | Fortify_LeaveScope();
|
---|
| 240 | # endif
|
---|
[828] | 241 | }
|
---|
| 242 |
|
---|
[551] | 243 | static VOID FillKillListThread(VOID * arg)
|
---|
[350] | 244 | {
|
---|
[551] | 245 | HWND hwnd = *(HWND *) arg;
|
---|
| 246 | CHAR s[1036], progname[1027], *p;
|
---|
| 247 | HAB thab;
|
---|
| 248 | HMQ thmq;
|
---|
[2] | 249 | FILE *fp;
|
---|
[551] | 250 | BOOL foundstart = FALSE;
|
---|
| 251 | INT rc;
|
---|
[2] | 252 | CHAR *startstring = "Process and Thread Information";
|
---|
| 253 | CHAR *endstring = "System Semaphore Information";
|
---|
[551] | 254 | PID pid;
|
---|
| 255 | HFILE oldstdout, newstdout;
|
---|
[1544] | 256 | CHAR *mode;
|
---|
[2] | 257 |
|
---|
| 258 | DosError(FERR_DISABLEHARDERR);
|
---|
| 259 |
|
---|
[1038] | 260 | # ifdef FORTIFY
|
---|
| 261 | Fortify_EnterScope();
|
---|
[1063] | 262 | # endif
|
---|
[2] | 263 | thab = WinInitialize(0);
|
---|
[551] | 264 | thmq = WinCreateMsgQueue(thab, 0);
|
---|
| 265 | WinCancelShutdown(thmq, TRUE);
|
---|
[533] | 266 | IncrThreadUsage();
|
---|
[2] | 267 |
|
---|
[551] | 268 | WinSendDlgItemMsg(hwnd, KILL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[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])) {
|
---|
| 316 | p = &s[1];
|
---|
| 317 | pid = strtol(&s[1], &p, 16);
|
---|
| 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#$.#$#");
|
---|
| 339 | DosForceDelete(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
|
---|
[829] | 473 | DosSleep(100); // 05 Aug 07 GKY 250
|
---|
[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
|
---|
[828] | 485 | DosSleep(100);//05 Aug 07 GKY 250
|
---|
[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 |
|
---|
[551] | 508 | CHAR s[31], *p;
|
---|
| 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) {
|
---|
| 517 | p = s;
|
---|
| 518 | pid = strtol(s, &p, 16);
|
---|
| 519 | if (pid) {
|
---|
| 520 | if (SHORT1FROMMP(mp1) == DID_OK) {
|
---|
| 521 | error = DosKillProcess(DKP_PROCESS, pid);
|
---|
| 522 | if (error && error != ERROR_INVALID_PROCID) {
|
---|
| 523 | Dos_Error(MB_CANCEL,
|
---|
| 524 | error,
|
---|
| 525 | hwnd,
|
---|
| 526 | __FILE__,
|
---|
| 527 | __LINE__, GetPString(IDS_DOSKILLFAILEDTEXT));
|
---|
| 528 | }
|
---|
| 529 | else
|
---|
| 530 | WinSendDlgItemMsg(hwnd,
|
---|
| 531 | KILL_LISTBOX,
|
---|
| 532 | LM_DELETEITEM,
|
---|
| 533 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
| 534 | }
|
---|
| 535 | else if (!ShowSession(hwnd, pid))
|
---|
| 536 | Notify(GetPString(IDS_SORRYCANTSHOWTEXT));
|
---|
| 537 | }
|
---|
| 538 | }
|
---|
[2] | 539 | }
|
---|
[551] | 540 | break;
|
---|
[2] | 541 |
|
---|
[551] | 542 | case DID_CANCEL:
|
---|
| 543 | if (!listdone)
|
---|
| 544 | Runtime_Error(pszSrcFile, __LINE__, "busy");
|
---|
| 545 | else
|
---|
| 546 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 547 | break;
|
---|
| 548 |
|
---|
[551] | 549 | case IDM_HELP:
|
---|
| 550 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
| 551 | hwnd,
|
---|
| 552 | GetPString(IDS_KILLPROCHELPTITLETEXT),
|
---|
| 553 | GetPString(IDS_KILLPROCHELPTEXT));
|
---|
[2] | 554 | break;
|
---|
[551] | 555 | }
|
---|
| 556 | return 0;
|
---|
| 557 |
|
---|
| 558 | case WM_CLOSE:
|
---|
| 559 | if (!listdone) {
|
---|
| 560 | Runtime_Error(pszSrcFile, __LINE__, "busy");
|
---|
| 561 | return 0;
|
---|
| 562 | }
|
---|
| 563 | break;
|
---|
| 564 |
|
---|
| 565 | case WM_DESTROY:
|
---|
| 566 | if (hptrIcon)
|
---|
| 567 | WinDestroyPointer(hptrIcon);
|
---|
| 568 | hptrIcon = (HPOINTER) 0;
|
---|
| 569 | break;
|
---|
[2] | 570 | }
|
---|
[551] | 571 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 572 | }
|
---|
[793] | 573 |
|
---|
| 574 | #pragma alloc_text(KILLPROC,FillKillListThread,FillKillListThread2,GetDosPgmName,KillDlgProc)
|
---|
[830] | 575 | #pragma alloc_text(KILLPROC,FillKillListThread3)
|
---|