• Amused
  • Angry
  • Annoyed
  • Awesome
  • Bemused
  • Cocky
  • Cool
  • Crazy
  • Crying
  • Down
  • Drunk
  • Embarrased
  • Enraged
  • Friendly
  • Geeky
  • Godly
  • Happy
  • Hateful
  • Hungry
  • Innocent
  • Meh
  • Piratey
  • Poorly
  • Sad
  • Secret
  • Shy
  • Sneaky
  • Tired
  • Wtf
  • At Work
  • CodenzHub
  • Coding
  • Deejaying
  • Donating
  • Drinking
  • Eating
  • Editing
  • Hacking
  • Hate Mailing
  • Jamin'
  • Lagging
  • Live Streaming
  • Lurking
  • No Status
  • Pawning
  • PC Gaming
  • PS Gaming
  • Raging
  • Reversing
  • Sleeping
  • Steam Gaming
  • Trolling
  • TwitchStreamer
  • Vodka!
  • Watching TV/Movie
  • Xbox Gaming
  • Youtuber
  • Zombies
  • Results 1 to 3 of 3
    1. #1
      Beware the dragonborn
      Teuvin's Avatar
      Join Date
      Dec 2016
      Thanks (-->)
      Thanks (<--)

      Angry Call main when form loads

      Advertise on GuidedHacking
      Hi guys I have a simple code with 1 textField and a Button and I already have the function for getting the module base adress, but the problem is, it only get's called when I close the form (LOL), not when it starts-up I know it has to do something with Form1_Load, but everytime I try to do putting Program.Main(); in the Form1_Load it gives me a error :
      Spoiler: Error
      Exception thrown: 'System.InvalidOperationException' in System.Windows.Forms.dll

      Additional information: SetCompatibleTextRenderingDefault must be called before the first IWin32Window object is created in the application.

      And I have Literally no idea how to solve it.
      Already looked up on Stack overflow and google but the answers are too code-specific.

      And it would be even better instead of you guys helping me how to solve this error I would like to know how would YOU do it? Call a function when the form load

      Current code:
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Threading.Tasks;
      using System.Windows.Forms;
      using System.Diagnostics;

      namespace WindowsFormsApplication2

      public class Program
      public static int baseAdress;
      public class valor
      private static int valuee;
      public int Valor
      get { return valuee; }
      set { valuee = value; }
      public class adress
      private static int adressf;
      public int Adress
      get {return adressf; }
      set {adressf = value; }

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      static void Main()

      Application.Run(new Adicionar());

      if (getmodule()) {
      adress d = new adress();
      d.Adress = (0x6C7FC + baseAdress + 0xA82020);
      static bool getmodule()
      Process[] p = Process.GetProcessesByName("ePSXe");
      if(p.Length > 0)
      foreach(ProcessModule m in p[0].Modules)
      if(m.ModuleName == "ePSXe.exe")
      baseAdress = (int)m.BaseAddress;
      return true;
      return true;
      return false;
      catch(Exception ex)
      return false;
      return true;

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows.Forms;

      namespace WindowsFormsApplication2
      public partial class Adicionar : Form
      public Adicionar()

      private void dValor_TextChanged(object sender, EventArgs e)
      Program.valor valorText = new Program.valor();
      valorText.Valor = Convert.ToInt32(dValor.Text);

      private void btn_Click(object sender, EventArgs e)
      MessageBox.Show("Working on it...");
      //TODO ALL THE WRITING TO MEMORY STUF... :( // int addr = (0x6C7FC + Program.baseAdress + 0xA82020);


      private void Form1_Load(object sender, EventArgs e)
      Last edited by Teuvin; 12-08-2016 at 09:32 PM.

    2. #2
      Global Moderator
      Certified Asshole
      Traxin's Avatar
      Join Date
      Aug 2015
      Thanks (-->)
      Thanks (<--)
      First of all, stay the fuck out Program.cs.

      Put all of YOUR code either in another new class, or in the Form. I usually like to opt for the first option, so the Form code looks a bit cleaner...
      Either way, what you're basically doing by calling Program.Main() is calling the entry point of the Program... This doesn't make sense. Why would a program call it's own entry point?

      Why is your code executing AFTER you close your program? Simple...
      The program enters a loop when Aapplication.Run is called and any code below this call isn't not executed UNTIL AFTER the loop is finished(aka you close the program.)

      Just crank up a new solution, stay out of program.cs, and put all of your code in the Form.cs.

      BTW, maybe you'd like to try starting out with something that isn't emulated? I see you're targeting ePSXe, just thought you should know emulation adds a whole nother layer of complexity to the process, something you probably don't need right now.

      We recommend AssaultCube and that you follow along with the tutorials here on GH

      Best of luck to ya!

    3. #3
      Learning to hack games!
      Feeling Normal
      HexMurder's Avatar
      Join Date
      Jun 2012
      Thanks (-->)
      Thanks (<--)
      Advertise on GuidedHacking
      Not trying to be redundant, but unless you really know what you are doing, you should NEVER touch Program.cs. Leave that to visual studios.
      If you want something to be executed when the from loads, simply go to your form's designer view, and double click the background. This should generate some On-Load code. Anything you put in there will happen as soon as the form loads.

    Similar Game Hacker Threads

    1. [VB.NET] Form IN DLL [DLL Project]
      By Devolten in forum Visual Basic
      Replies: 7
      Last Post: 08-27-2016, 09:44 PM
    2. Cs:Go Main Cpp
      By Fleep#2 in forum Hacking Help
      Replies: 8
      Last Post: 03-16-2015, 10:15 AM
    3. Free GUI Form Pro VS
      By Crazywink in forum CrazywinkStudios C++ Tutorials
      Replies: 0
      Last Post: 05-14-2014, 02:08 AM
    4. [Off Topic] Custom Form Designing
      By Crazywink in forum Off Topic
      Replies: 0
      Last Post: 02-23-2014, 07:18 PM
    5. How to get the main address of a programm
      By AlexR in forum Visual Basic
      Replies: 7
      Last Post: 04-23-2013, 11:46 AM

    Tags for this Thread