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