Finding the base address of a program via Visual Basic code

280 views Asked by At

I am using Visual Studio 2019 - Visual Basic.

I am trying to find the base address of a program via code. I know the base address already, but I need the program I am making to find it on its own.

I use this and it shows a lot of addresses from the modules:

Dim target As Process = Process.GetProcessesByName("The Program")(0)
For Each mo As ProcessModule In target.Modules
    ListBox1.Items.Add(mo.BaseAddress.ToString())

    'MsgBox(Hex(mo.BaseAddress.ToString()))
Next

(I renamed the name of the program from the above code in case there are issues with the program as in copyright stuff.)

I am trying to get the base address My base address I have is:

Base Address in Hex = 00007FF7BE6B0000
Base Address in Dec = 140702028333056

When I run the above code none of the addresses it lists are the base addresses I have.

I used a PE Editor to see the base address of the program. I used a program called PE Tools from GitHub.

So how do I code to get this Image Base Address?

1

There are 1 answers

1
Link Zelda On

I got it to work with this code:

Dim p As Process = Process.GetProcessesByName(GetCurrentProcessName)(0)
For Each moz As System.Diagnostics.ProcessModule In p.Modules
    If moz.FileName.IndexOf(GetCurrentProcessName) <> -1 Then
      Hex(moz.BaseAddress.ToString)
    End If
Next