// fkill forces a kill -- it will attempt to enable SeDebugPrivilege // before opening its process handles, allowing it to kill processes // running under builtin\system (LocalSystem, to the users out there).
int main( int argc, char *argv[] ); void getDebugPriv( void );
if ( errors || pidCount == 0 ) { puts( "Usage: fkill pid [...]" ); puts( "fkill tries to kill the processes specified by the PIDs. If the" ); puts( "user has debug privileges, fkill is able to kill system processes." ); puts( "PIDs may be decimal, octal (starts with 0), or hex (starts with 0x)." ); return MAXPID + 1; }
// try to acquire SeDebugPrivilege getDebugPriv(); //см. faq выше
errors = 0; // for each PID: for ( i = 0; i < pidCount; i ++ ) { printf( "pid %lu: ", pid[i] );
// open process hProcess = OpenProcess( PROCESS_TERMINATE, FALSE, pid[i] ); if ( isBadHandle( hProcess ) ) printf( "OpenProcess() failed, err = %lu\n", GetLastError() ); else { // kill process if ( ! TerminateProcess( hProcess, (DWORD) -1 ) ) printf( "TerminateProcess() failed, err = %lu\n", GetLastError() ); else puts( "killed." );