/*++ Copyright (c) 1994 Microsoft Corporation Module Name: kill.c Abstract: This module implements a task killer application. Author: Wesley Witt (wesw) 20-May-1994 Environment: User Mode --*/ #include #include #include #include #include "common.h" #define MAX_TASKS 256 BOOL ForceKill; DWORD pid; CHAR pname[MAX_PATH]; TASK_LIST tlist[MAX_TASKS]; VOID GetCommandLineArgs(VOID); VOID Usage(VOID); int _cdecl main( int argc, char *argv[] ) { DWORD i; DWORD numTasks; TASK_LIST_ENUM te; int rval = 0; char tname[PROCESS_SIZE]; LPSTR p; DWORD ThisPid; GetCommandLineArgs(); if (pid == 0 && pname[0] == 0) { printf( "missing pid or task name\n" ); return 1; } // // lets be god // EnableDebugPriv(); if (pid) { tlist[0].dwProcessId = pid; if (KillProcess( tlist, TRUE )) { printf( "process #%d killed\n", pid ); return 0; } else { printf( "process #%d could not be killed\n" ); return 1; } } // // get the task list for the system // numTasks = GetTaskList( tlist, MAX_TASKS ); // // enumerate all windows and try to get the window // titles for each task // te.tlist = tlist; te.numtasks = numTasks; GetWindowTitles( &te ); ThisPid = GetCurrentProcessId(); for (i=0; i | >\n\n" ); fprintf( stderr, " [options]:\n" ); fprintf( stderr, " -f Force process kill\n\n" ); fprintf( stderr, " \n" ); fprintf( stderr, " This is the process id for the task\n" ); fprintf( stderr, " to be killed. Use TLIST to get a\n" ); fprintf( stderr, " valid pid\n\n" ); fprintf( stderr, " \n" ); fprintf( stderr, " The pattern can be a complete task\n" ); fprintf( stderr, " name or a regular expression pattern\n" ); fprintf( stderr, " to use as a match. Kill matches the\n" ); fprintf( stderr, " supplied pattern against the task names\n" ); fprintf( stderr, " and the window titles.\n" ); ExitProcess(0); }