❓ How to make public process ?

Posts 1–10 of 10 · Page 1 of 1
❓ How to make public process ?
This is my code

Code:
Private Const ProcName = "game"

    Dim GaMe As Process() = Process.GetProcessesByName(ProcName)

    Dim pID As IntPtr = GaMe(0).Handle

    Dim base As IntPtr = GaMe(0).MainModule.BaseAddress

    Dim offsets() As IntPtr = {&H0}
i put it in my form but it is working only if the game is open

if the game is not open my hack is crashing i cant open my hack cuz the process of the game is not open

if i open the game first my hack will open

i want to be able to open the hack even if the game is not open

---------------------------------------------------------------------------------------------

i fixed it by deleting the code from the form ---> and put it in every button and timer

but i do not want to do that cuz its constants so i do not want copy and paste it in every button

how to do that

Thanks in advance
This line will cause an error
Code:
Dim pID As IntPtr = GaMe(0).Handle
You need to check it the process was found first.
Quote Originally Posted by Pingo View Post
This line will cause an error
Code:
Dim pID As IntPtr = GaMe(0).Handle
You need to check it the process was found first.
How to make this check to make the hack start

i mean i want to make the hack start even if the game is not open

write the code that i have to use
You can't declare and set anything if the process isn't actually there.
Think about it. How would you set something that hasn't been created yet?
What DawgiiStylz said, hence why you check the process first.

Code:
    If GaMe.Length = 0 Then
        Return
    End If
Added to your code
Code:
    Private Const ProcName = "game"

    Dim GaMe As Process() = Process.GetProcessesByName(ProcName)

    If GaMe.Length = 0 Then
        Return
    End If

    Dim pID As IntPtr = GaMe(0).Handle

    Dim base As IntPtr = GaMe(0).MainModule.BaseAddress

    Dim offsets() As IntPtr = {&H0}
Also just a note
Code:
Dim pID As IntPtr = GaMe(0).Handle
I'm guessing pID stands for process id. You should change that so you don't get confused.
pID to pHandle
Code:
Dim pHandle As IntPtr = GaMe(0).Handle
Dim pID As Integer = GaMe(0).Id
@Pingo and @DawgiiStylz

Ok i will keep copy and paste it in every button no problem with it but i thought there is a solution for it

ok another question ---> How i can make a button so i can choose the process that i want like cheat engine

get list of all process then choose the game i want like attach process and a button for unattach

i hope there is a solution for this in vb
Quote Originally Posted by Ell0ll View Post
@Pingo and @DawgiiStylz

Ok i will keep copy and paste it in every button no problem with it but i thought there is a solution for it

ok another question ---> How i can make a button so i can choose the process that i want like cheat engine

get list of all process then choose the game i want like attach process and a button for unattach

i hope there is a solution for this in vb
Something like this

Code:
Dim p() As Process = Process.GetProcesses
            For Each x As Process In p
                If x.ProcessName = "" Then
                    i = FindWindow(Nothing, x.MainWindowTitle)
                    pHandle = i
                    pName = txtTarget.Text
                End If
            Next
Quote Originally Posted by DawgiiStylz View Post

Something like this

Code:
Dim p() As Process = Process.GetProcesses
            For Each x As Process In p
                If x.ProcessName = "" Then
                    i = FindWindow(Nothing, x.MainWindowTitle)
                    pHandle = i
                    pName = txtTarget.Text
                End If
            Next
i thought i am not good to do it alone but i made it > by thinking > updated all the module

but thank you any way i may need some help later i will call you
Quote Originally Posted by Ell0ll View Post
i thought i am not good to do it alone but i made it > by thinking > updated all the module

but thank you any way i may need some help later i will call you
Code:
      Dim p() As Process = Process.GetProcesses
            For Each x As Process In p
                If x.ProcessName = "" Then
                   'the name x.processname
                   'handle.. x.handle and ect
                End If
            Next
What i used to do was store the process instead of searching for it everytime.
At the top of my form id declare two variable.
Code:
    Dim ProcActive As Boolean
    Dim GaMe As Process()
Then id create a function to get the proccess but once its found, stop searching untill the process ends.
Code:
    Sub GetProc(ByVal ProcName As String)
        If ProcName = String.Empty Then
            Return
        End If

        If Not ProcActive Then
            GaMe = Process.GetProcessesByName(ProcName)
            ProcActive = GaMe.Length <> 0
        End If
        Try
            ProcActive = Not GaMe(0).HasExited
        Catch
            ProcActive = False
        End Try
    End Sub
Id then run it in a timer
Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        GetProc("Game")
    End Sub
Say you needed to use it on a button or whatever
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ProcActive Then
            'Do stuff here
            'GaMe(0).Handle
            'GaMe(0).MainModule.BaseAddress
        End If
    End Sub
ProcActive will only equal true if the process is running. If the process ends, it will read false.
That way you can avoid getting errors.
Might be useful to someone.
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Talk with us