EvilZone

Programming and Scripting => Projects and Discussion => : gh0st May 29, 2011, 02:44:59 AM

: [VB2010exp] ending a process
: gh0st May 29, 2011, 02:44:59 AM
well guys I would like to make a tool in visual basic 2010 express which ends a specific process by just pressing f1 or any other buttom
any kind of suggestion will be apreciated thanx in advance
 
 
: Re: [VB2010exp] ending a process
: ande May 29, 2011, 03:39:13 AM
:
shell("tskill NAME")

That will kill your process, by name NAME. To make it work with a hotkey(globally), you have to look into the GetAsyncKeyState(). Here is an example:

:
<DllImport("user32.dll")> _
Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As integer
End Function

Sub BackgroundThreadThatWillLoopForever()
while (1)
     Dim x as integer = GetAsyncKeyState(keys.f1)
     If x = 1 or x = -32767 then
          shell("tskill NAME")
     End if
     System.threading.thread.sleep(1)
     application.doevents()
loop
End sub

I coded that by hand now, and have not tested it but im pretty sure that should work ;)
: Re: [VB2010exp] ending a process
: iMorg May 29, 2011, 05:07:53 AM
I would suggest using TerminateProcess and provide a handle to the process. That way if your program doesnt have the access rights to kill the selected process you can update the security token of the program.


Example:
:
// iMorg->EvilZone

bool KillProc(unsigned long pid)
{
     HANDLE pHandle = OpenProcess(PROCESS_ALL_ACCESS,
                                                         FALSE,
                                                         pid);
     if (pHandle == NULL)
          return false;
     if( !TerminateProcess(pHandle, 0) )
        return false;
     else
        return true;
}


To do it when a key is pressed you can use GetAsyncKeyState() as ande said or you can hook the keyboard and look for the correct message.


EDIT: Shit didnt see the VB, nvm. Ill leave it if you ever need a c++ example anyway.



E