jedijosh920

Simple God Mode Hack

Jul 8th, 2018
1,324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.Diagnostics;
  8. using System.Runtime.InteropServices;
  9.  
  10. namespace GodMode
  11. {
  12.     class Program
  13.     {
  14.         /*
  15.          "gta-sa.exe"+0076F3B8
  16.          Offset: 540
  17.         */
  18.  
  19.         // get key press states
  20.         [DllImport("user32.dll")]
  21.         static extern short GetAsyncKeyState(int vKey);
  22.  
  23.         // game exe name
  24.         static string processName = "gta-sa";
  25.  
  26.         // addresses & offsets
  27.         static int playerAddress = 0x76F3B8;
  28.         static int playerHealthOffset = 0x540;
  29.  
  30.         // toggles
  31.         static bool godMode;
  32.  
  33.         static void Main(string[] args) // Main Function
  34.         {
  35.             // attach to process
  36.             VAMemory vam = new VAMemory(processName);
  37.  
  38.             // get base address of the process
  39.             int baseAddress = (int)Process.GetProcessesByName(processName)[0].MainModule.BaseAddress;
  40.  
  41.             // get player base address by adding base address & player address
  42.             int playerBaseAddress = vam.ReadInt32((IntPtr)baseAddress + playerAddress);
  43.  
  44.             // get player health address by adding player base address & player health offset
  45.             int playerHealthAddress = playerBaseAddress + playerHealthOffset;
  46.  
  47.             // read player health at player health address
  48.             var playerHealth = vam.ReadFloat((IntPtr)playerHealthAddress);
  49.  
  50.             // log current player health in console
  51.             Console.WriteLine("Current Player Health: " + playerHealth);
  52.  
  53.             while (true) // infinite loop
  54.             {
  55.                 if (GetAsyncKeyState(74) != 0) // check if J key is pressed
  56.                 {
  57.                     godMode = !godMode; // toggle god mode state
  58.                     Console.WriteLine("God Mode: " + godMode); // log current god mode state
  59.                     Console.Beep(godMode ? 5000 : 500, 250); // sound to distinguish god mode state in-game
  60.                     Thread.Sleep(250); // sleep to delay key press
  61.                 }
  62.  
  63.                 if (godMode) // if god mode loop
  64.                 {
  65.                     vam.WriteFloat((IntPtr)playerHealthAddress, 100); // constantly write 100 (max health value) at player health address for god mode
  66.                 }
  67.  
  68.                 Thread.Sleep(10); // sleep to reduce cpu load
  69.             }
  70.         }
  71.     }
  72. }
Add Comment
Please, Sign In to add comment