0

I want my program to execute a specific function everytime the form is run. The function would be to get the baseAdress of a process. Current code:

[STAThread]
        static void Main()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Adicionar());

            if (getmodule()) {
                MessageBox.Show(Convert.ToString(baseAdress)); //Dunno if this is going to work but it's just to see if it's getting a baseAdress;
                adress d = new adress();
                d.Adress = (0x6C7FC + baseAdress + 0xA82020);
            }
 }
      static bool getmodule(){ .... }

how would that be possible to make?

  • Did this even successfully build? – Yaman Dec 08 '16 at 01:11
  • @Yaman No- `CS0120` is a compiler error. – Brian Rogers Dec 08 '16 at 01:12
  • Yeah, a staitc method can be called without an object (on the class level) so there is no object when you are inside it, you have to declare getmodule static to refer to it. – Yaman Dec 08 '16 at 01:13
  • Ok, that's one part of the problem solved, but how do I make the function getmodule() get called everytime someone runs the program? As I need to have the baseAdress as soon as the programs loads – Matheus Souza Dec 08 '16 at 01:39

1 Answers1

0

Here you can see that main is a static method, you can't call a non static method from a static method, if you want to call meas you have to make it as a static otherwise need an instance under the scope, So make it as static method:

  static bool getmodule()
  {    
    // do somethong here 
  }
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88