[VB TuT]Suspender

04/01/2011 14:37 CrashXx#1
Hello,
i will show u how to make a simple Suspender in Visual Basic 2010.


What we need :
Visual Basic 2008/2010 or Visual Studio 2008/2010.
Brain.exe


Step one:
Open Visual Basic and create a new Project, Windows Forms and call it how u want.

Step two:
We create 1 Button and 1 TextBox. We call the Button
"Suspend".
Then we make a right click on our Project and go on Add and click on Module.

Step three:
In Module.vb we gonna declare all functions to Suspend and to Resume a Process that our Programm can Suspend or Resume a Process.
PHP Code:
Public Enum ThreadAccess As Integer
        TERMINATE 
= (&H1)
        
SUSPEND_RESUME = (&H2)
        
GET_CONTEXT = (&H8)
        
SET_CONTEXT = (&H10)
        
SET_INFORMATION = (&H20)
        
QUERY_INFORMATION = (&H40)
        
SET_THREAD_TOKEN = (&H80)
        
IMPERSONATE = (&H100)
        
DIRECT_IMPERSONATION = (&H200)
    
End Enum

    
Public Declare Function OpenThread Lib "kernel32.dll" (ByVal dwDesiredAccess As ThreadAccessByVal bInheritHandle As BooleanByVal dwThreadId As UInteger) As IntPtr
    
Public Declare Function SuspendThread Lib "kernel32.dll" (ByVal hThread As IntPtr) As UInteger
    
Public Declare Function ResumeThread Lib "kernel32.dll" (ByVal hThread As IntPtr) As UInteger
    
Public Declare Function CloseHandle Lib "kernel32.dll" (ByVal hHandle As IntPtr) As Boolean 

Step four:
Then we go back to our Form1 and press right click on it and press
"View Code". Here we declare the SuspendProcess and ResumeProcess function in Private Sub.

SuspendProcess function:
PHP Code:
Private Sub SuspendProcess(ByVal process As System.Diagnostics.Process)
        For 
Each t As ProcessThread In process.Threads
            Dim th 
As IntPtr
            th 
OpenThread(ThreadAccess.SUSPEND_RESUMEFalset.Id)
            If 
th <> IntPtr.Zero Then
                SuspendThread
(th)
                
CloseHandle(th)
            
End If
        
Next
    End Sub 
ResumeProcess function:
PHP Code:
Private Sub ResumeProcess(ByVal process As System.Diagnostics.Process)
        For 
Each t As ProcessThread In process.Threads
            Dim th 
As IntPtr
            th 
OpenThread(ThreadAccess.SUSPEND_RESUMEFalset.Id)
            If 
th <> IntPtr.Zero Then
                ResumeThread
(th)
                
CloseHandle(th)
            
End If
        
Next
    End Sub 
Now we go back to our Form and double click on our Button.
Then we write the function that will suspend and resume our Process from the TextBox.
PHP Code:
Dim game As Process() = Process.GetProcessesByName(TextBox1.Text)
        If 
Button1.Text "Suspend" Then
            SuspendProcess
(game(0))
            
Button1.Text "Resume"
        
Else
            
ResumeProcess(game(0))
            
Button1.Text "Suspend"
        
End If 
When you press on Suspend the Button will get the name Resume and when you press Resume the Button will get the name Suspend again.
In the TextBox you write your Process name but without .exe in the end !


I forgot something: Double click on your Form and type in
PHP Code:
Process.EnterDebugMode() 

That code make that the process get suspended with full rights. If you donīt have this code then Game Processes wouldnīt get suspended and resumed only the windows Processes.

If you want to get the current Process List and suspend it from the List box then you make this =>
We add a ListBox and a new Button(we call the Button also
"Suspend") and double click on our Form and write the function that will get our current Process List:
PHP Code:
Dim Processe As Process
        
For Each Processe In Process.GetProcesses
            ListBox1
.Items.Add(Processe.ProcessName)
        
Next 
Then we go back to our Form and double click on the new Button that we added. Then we write the same code as for the TextBox only with ListBox:
PHP Code:
Dim game As Process() = Process.GetProcessesByName(ListBox1.Text)
        If 
Button1.Text "Suspend" Then
            SuspendProcess
(game(0))
            
Button1.Text "Resume"
        
Else
            
ResumeProcess(game(0))
            
Button1.Text "Suspend"
        
End If 
Now we are finished and so we can Debug our Programm =)
In the end you can design your Programm how you want if you want ;)

I hope i explained it to you well and you understood everything well =)

~Have Fun~
04/06/2011 08:59 bestora#2
mhhh Nice
For S4 is it Useless...
But you have copy it or?
04/06/2011 14:19 Kraizy​#3
Does it work for games like Call of Duty or Counter-Strike (games wich run in fullscreen)?
04/07/2011 06:53 bestora#4
ehm fullscreen I don't know... in CoD or CS
You can check it...
My CoD is broken xDDDDD
But games like S4 league, there work it!
04/08/2011 12:18 CrashXx#5
It should work for every game, i didnīt tested it on offline games xD but it should work =)