Created
August 20, 2019 08:42
-
-
Save Complexicon/2c97e454c74a1d40222f661c84b9ec4d to your computer and use it in GitHub Desktop.
Easy to Interact Game Structure of GTA5 Memory with Offsets for 1.47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MemoryLib; | |
using System.Drawing; | |
namespace YourHack { | |
public class GameStruct { | |
public MemLib Mem; | |
public readonly long WorldPTR; | |
public readonly long BlipPTR; | |
public readonly long GlobalPTR; | |
//Sets up new MemoryLib for GTA5 and Finds WorldPTR, BlipPTR and GlobalPTR. | |
public GameStruct() { | |
try { | |
Mem = new MemLib("GTA5"); | |
long addr = Mem.FindPattern(new byte[] { 0x48, 0x8B, 0x05, 0x0, 0x0, 0x0, 0x0, 0x45, 0x0, 0x0, 0x0, 0x0, 0x48, 0x8B, 0x48, 0x08, 0x48, 0x85, 0xC9, 0x74, 0x07 }, "xxx????x????xxxxxxxxx"); | |
WorldPTR = addr + Mem.ReadInt(addr + 3, null) + 7; | |
long addr2 = Mem.FindPattern(new byte[] { 0x4C, 0x8D, 0x05, 0x0, 0x0, 0x0, 0x0, 0x0F, 0xB7, 0xC1 }, "xxx????xxx"); | |
BlipPTR = addr2 + Mem.ReadInt(addr2 + 3, null) + 7; | |
var addr3 = Mem.FindPattern(new byte[] { 0x4C, 0x8D, 0x05, 0x0, 0x0, 0x0, 0x0, 0x4D, 0x8B, 0x08, 0x4D, 0x85, 0xC9, 0x74, 0x11 }, "xxx????xxxxxxxx"); | |
GlobalPTR = addr3 + Mem.ReadInt(addr3 + 3, null) + 7; | |
} catch { throw new System.Exception(); } | |
} | |
//Game Variables | |
public bool Godmode { | |
get => Mem.ReadBool(WorldPTR, Offset.Godmode); | |
set => Mem.Write(WorldPTR, Offset.Godmode, value); | |
} | |
public bool CarGodmode { | |
get => Mem.ReadBool(WorldPTR, Offset.CarGodmode); | |
set => Mem.Write(WorldPTR, Offset.CarGodmode, value); | |
} | |
public bool CarNeon { | |
get => Mem.ReadInt(WorldPTR, Offset.CarNeonActive) == 0x01010101; | |
set => Mem.Write(WorldPTR, Offset.CarNeonActive, value ? 0x01010101 : 0x00000000); | |
} | |
public float CarAcceleration { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarAcceleration); | |
set { | |
Mem.Write(WorldPTR, Offset.CarAcceleration, value); | |
Mem.Write(WorldPTR, Offset.CarAcceleration1, value); | |
Mem.Write(WorldPTR, Offset.CarAcceleration2, value); | |
} | |
} | |
public float CarGravity { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarGravity); | |
set => Mem.Write(WorldPTR, Offset.CarGravity, value); | |
} | |
public bool Seatbelt { | |
get => Mem.ReadBytes(WorldPTR, Offset.Seatbelt, 1)[0] == 0xc9; | |
set => Mem.Write(WorldPTR, Offset.Seatbelt, value ? new byte[] { 0xc9 } : new byte[] { 0xc8 }); | |
} | |
public float MaxHealth { | |
get => Mem.ReadFloat(WorldPTR, Offset.MaxHealth); | |
set => Mem.Write(WorldPTR, Offset.MaxHealth, value); | |
} | |
public float Health { | |
get => Mem.ReadFloat(WorldPTR, Offset.Health); | |
set => Mem.Write(WorldPTR, Offset.Health, value); | |
} | |
public float Armor { | |
get => Mem.ReadFloat(WorldPTR, Offset.Armor); | |
set => Mem.Write(WorldPTR, Offset.Armor, value); | |
} | |
public void EnableRapidFire() => Mem.Write(WorldPTR, Offset.Firerate, 0.01F); | |
public void EnableRocketFastRecharge() => Mem.Write(WorldPTR, Offset.RocketRecharge, (float)20); | |
public void DisableWeaponSpread() => Mem.Write(WorldPTR, Offset.WeaponSpread, (float)0); | |
public void DisableWeaponRecoil() => Mem.Write(WorldPTR, Offset.WeaponRecoil, (float)0); | |
public void EnableFastReload() => Mem.Write(WorldPTR, Offset.WeaponReloadSpeed, 10F); | |
public float BulletDamage { | |
get => Mem.ReadFloat(WorldPTR, Offset.BulletDamage); | |
set => Mem.Write(WorldPTR, Offset.BulletDamage, value); | |
} | |
public ExplosionType WeaponExplosionType { | |
get { | |
var tmp = Mem.ReadInt(WorldPTR, Offset.WeaponExplosionType); | |
if(System.Enum.IsDefined(typeof(ExplosionType), tmp)) return (ExplosionType)tmp; | |
else return ExplosionType.Unknown; | |
} | |
set => Mem.Write(WorldPTR, Offset.WeaponExplosionType, (int)value); | |
} | |
public int WeaponBulletType { | |
get => Mem.ReadInt(WorldPTR, Offset.WeaponDamageType); | |
set => Mem.Write(WorldPTR, Offset.WeaponDamageType, value); | |
} | |
public bool Superjump { | |
get => Mem.ReadInt(WorldPTR, Offset.PlayerFlags) > 0; | |
set => Mem.Write(WorldPTR, Offset.PlayerFlags, 16384); | |
} | |
public int WantedLevel { | |
get => Mem.ReadInt(WorldPTR, Offset.WantedLevel); | |
set => Mem.Write(WorldPTR, Offset.WantedLevel, value); | |
} | |
public int CurrentAmmo { | |
get => Mem.ReadInt(WorldPTR, Offset.CurrentAmmo); | |
set => Mem.Write(WorldPTR, Offset.CurrentAmmo, value); | |
} | |
public int MaxAmmo => Mem.ReadInt(WorldPTR, Offset.MaxAmmo); | |
public void SetRocketVelocity(float velocity) { | |
if(CurrentWeaponSlot == 6) Mem.Write(WorldPTR, Offset.RocketVelocity, velocity); | |
} | |
public void SetThrowablesGravity(float gravity) { | |
if(CurrentWeaponSlot == 7) Mem.Write(WorldPTR, Offset.ThrowGravity, gravity); | |
} | |
public int CurrentWeaponSlot => Mem.ReadInt(WorldPTR, Offset.WeaponSlot); | |
public float PlayerX { | |
get => Mem.ReadFloat(WorldPTR, Offset.PlayerVecX); | |
set { | |
Mem.Write(WorldPTR, Offset.PlayerVecX, value); | |
Mem.Write(WorldPTR, Offset.PlayerX, value); | |
} | |
} | |
public float PlayerY { | |
get => Mem.ReadFloat(WorldPTR, Offset.PlayerVecY); | |
set { | |
Mem.Write(WorldPTR, Offset.PlayerVecY, value); | |
Mem.Write(WorldPTR, Offset.PlayerY, value); | |
} | |
} | |
public float PlayerZ { | |
get => Mem.ReadFloat(WorldPTR, Offset.PlayerVecZ); | |
set { | |
Mem.Write(WorldPTR, Offset.PlayerVecZ, value); | |
Mem.Write(WorldPTR, Offset.PlayerZ, value); | |
} | |
} | |
public float CarX { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarVecX); | |
set { | |
Mem.Write(WorldPTR, Offset.CarVecX, value); | |
Mem.Write(WorldPTR, Offset.CarX, value); | |
} | |
} | |
public float CarY { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarVecY); | |
set { | |
Mem.Write(WorldPTR, Offset.CarVecY, value); | |
Mem.Write(WorldPTR, Offset.CarY, value); | |
} | |
} | |
public float CarZ { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarVecZ); | |
set { | |
Mem.Write(WorldPTR, Offset.CarVecZ, value); | |
Mem.Write(WorldPTR, Offset.CarZ, value); | |
} | |
} | |
public float CarEngineHealth { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarEngineHealth1); | |
set { | |
Mem.Write(WorldPTR, Offset.CarEngineHealth1, value); | |
Mem.Write(WorldPTR, Offset.CarEngineHealth2, value); | |
} | |
} | |
public float CarDirtLevel { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarDirtLevel); | |
set => Mem.Write(WorldPTR, Offset.CarDirtLevel, value); | |
} | |
public float CarDeformMultiplier { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarDeformationMultiplier); | |
set { | |
Mem.Write(WorldPTR, Offset.CarDeformationMultiplier, value); | |
Mem.Write(WorldPTR, Offset.CarCollisionDeformationMultiplier, value); | |
} | |
} | |
public CarHash CurrenCar { | |
get { | |
if(IsKnownCarHash) return (CarHash)CurrenCarHash; | |
else return CarHash.Elegy; | |
} | |
set => CurrenCarHash = (uint)value; | |
} | |
public uint CurrenCarHash { | |
get => Mem.ReadUInt(WorldPTR, Offset.CurrentCar); | |
set => Mem.Write(WorldPTR, Offset.CurrentCar, value); | |
} | |
public double CarVelocityKMH { | |
get => Mem.ReadFloat(WorldPTR, Offset.CarVelocity) * 3.018762407276696; | |
} | |
public Color CarPrimaryColor { | |
get => Color.FromArgb(Mem.ReadByte(WorldPTR, Offset.CarPrimaryR), Mem.ReadByte(WorldPTR, Offset.CarPrimaryG), Mem.ReadByte(WorldPTR, Offset.CarPrimaryB)); | |
set { | |
Mem.Write(WorldPTR, Offset.CarPrimaryR, value.R); | |
Mem.Write(WorldPTR, Offset.CarPrimaryG, value.G); | |
Mem.Write(WorldPTR, Offset.CarPrimaryB, value.B); | |
} | |
} | |
public byte CarPrimaryType { | |
get => Mem.ReadByte(WorldPTR, Offset.CarPrimaryColorType); | |
set => Mem.Write(WorldPTR, Offset.CarPrimaryColorType, value); | |
} | |
public byte CarSecondaryType { | |
get => Mem.ReadByte(WorldPTR, Offset.CarSecondaryColorType); | |
set => Mem.Write(WorldPTR, Offset.CarSecondaryColorType, value); | |
} | |
public Color CarSecondaryColor { | |
get => Color.FromArgb(Mem.ReadByte(WorldPTR, Offset.CarSecondaryR), Mem.ReadByte(WorldPTR, Offset.CarSecondaryG), Mem.ReadByte(WorldPTR, Offset.CarSecondaryB)); | |
set { | |
Mem.Write(WorldPTR, Offset.CarSecondaryR, value.R); | |
Mem.Write(WorldPTR, Offset.CarSecondaryG, value.G); | |
Mem.Write(WorldPTR, Offset.CarSecondaryB, value.B); | |
} | |
} | |
public Color CarNeonColor { | |
get => Color.FromArgb(Mem.ReadByte(WorldPTR, Offset.CarNeonR), Mem.ReadByte(WorldPTR, Offset.CarNeonG), Mem.ReadByte(WorldPTR, Offset.CarNeonB)); | |
set { | |
Mem.Write(WorldPTR, Offset.CarNeonR, value.R); | |
Mem.Write(WorldPTR, Offset.CarNeonG, value.G); | |
Mem.Write(WorldPTR, Offset.CarNeonB, value.B); | |
} | |
} | |
public Color CarPearlColor { | |
get => Color.FromArgb(Mem.ReadByte(WorldPTR, Offset.CarPearlR), Mem.ReadByte(WorldPTR, Offset.CarPearlG), Mem.ReadByte(WorldPTR, Offset.CarPearlB)); | |
set { | |
Mem.Write(WorldPTR, Offset.CarPearlR, value.R); | |
Mem.Write(WorldPTR, Offset.CarPearlG, value.G); | |
Mem.Write(WorldPTR, Offset.CarPearlB, value.B); | |
} | |
} | |
public void Teleport(Location l) { | |
if(IsPlayerInCar) { | |
CarX = l.x; | |
CarY = l.y; | |
CarZ = l.z; | |
} else { | |
PlayerX = l.x; | |
PlayerY = l.y; | |
PlayerZ = l.z; | |
} | |
} | |
public bool FastWalk { | |
get => Mem.ReadFloat(WorldPTR, Offset.SprintSpeed) != 1; | |
set { | |
Mem.Write(WorldPTR, Offset.SprintSpeed, (float)(value ? 2 : 1)); | |
Mem.Write(WorldPTR, Offset.SwimSpeed, (float)(value ? 2 : 1)); | |
} | |
} | |
public bool IsKnownCarHash { | |
get { | |
if(System.Enum.IsDefined(typeof(CarHash), CurrenCarHash)) return true; | |
else return false; | |
} | |
} | |
public Location WaypointCoords { | |
get { | |
for(int i = 2000; i > 1; i--) { | |
if(Mem.ReadInt(BlipPTR + (i * 8), new int[] { 0x48 }) == 84 && Mem.ReadInt(BlipPTR + (i * 8), new int[] { 0x40 }) == 8) { | |
return new Location(Mem.ReadFloat(BlipPTR + (i * 8), new int[] { 0x10 }), Mem.ReadFloat(BlipPTR + (i * 8), new int[] { 0x14 }), -210F); | |
} | |
} | |
return null; | |
} | |
} | |
//REPLACE CarHash Enum with uint! or create CarHash Enum! | |
public void SpawnCar(CarHash h) { | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnX, PlayerX + 2F); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnY, PlayerY); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnZ, PlayerZ); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnPlate, "PICOHAX1"); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnHash, (uint)h); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnProtect, 2); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnProtect2, 14); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnAttr, 0xF0400FFF); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawnColor, 4294967295); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawn1, 1); | |
Mem.Write(GlobalPTR + 0x48, Offset.CarSpawn2, 1); | |
} | |
//REPLACE Location with float[] or Create your own object to store LocationData! | |
public Location ObjectiveCoords { | |
get { | |
for(int i = 2000; i > 1; i--) { | |
int objDetect = Mem.ReadInt(BlipPTR + (i * 8), new int[] { 0x48 }); | |
if(Mem.ReadInt(BlipPTR + (i * 8), new int[] { 0x40 }) == 1 && ((objDetect == 1) || (objDetect == 66) || (objDetect == 60))) { | |
return new Location( | |
Mem.ReadFloat(BlipPTR + (i * 8), new int[] { 0x10 }), | |
Mem.ReadFloat(BlipPTR + (i * 8), new int[] { 0x14 }), | |
Mem.ReadFloat(BlipPTR + (i * 8), new int[] { 0x18 }) | |
); | |
} | |
} | |
return null; | |
} | |
} | |
public bool IsPlayerInCar => Mem.ReadInt(WorldPTR, Offset.PlayerInCar) == 256; | |
public void RefillAmmo() { | |
if(CurrentWeaponSlot != 4) { | |
Mem.Write(WorldPTR, Offset.CurrentAmmo, Mem.ReadInt(WorldPTR, Offset.MaxAmmo)); | |
} | |
} | |
} | |
public static class Offset { | |
public static int[] Godmode = new int[] { 0x08, 0x189 }; | |
public static int[] MaxHealth = new int[] { 0x08, 0x2A0 }; | |
public static int[] Health = new int[] { 0x08, 0x280 }; | |
public static int[] Armor = new int[] { 0x08, 0x14B8 }; | |
public static int[] Seatbelt = new int[] { 0x08, 0x13EC }; | |
public static int[] WantedLevel = new int[] { 0x08, 0x10b8, 0x818 }; | |
public static int[] SprintSpeed = new int[] { 0x08, 0x10b8, 0x14C }; | |
public static int[] SwimSpeed = new int[] { 0x08, 0x10b8, 0x148 }; | |
public static int[] PlayerFlags = new int[] { 0x08, 0x10b8, 0x01f8 }; | |
public static int[] NoRagdoll = new int[] { 0x08, 0x10A8 }; | |
public static int[] PlayerX = new int[] { 0x08, 0x90 }; | |
public static int[] PlayerY = new int[] { 0x08, 0x94 }; | |
public static int[] PlayerZ = new int[] { 0x08, 0x98 }; | |
public static int[] PlayerVecX = new int[] { 0x08, 0x30, 0x50 }; | |
public static int[] PlayerVecY = new int[] { 0x08, 0x30, 0x54 }; | |
public static int[] PlayerVecZ = new int[] { 0x08, 0x30, 0x58 }; | |
public static int[] PlayerInCar = new int[] { 0x08, 0xE44 }; | |
public static int[] CarGodmode = new int[] { 0x08, 0xd28, 0x189 }; | |
public static int[] CarVelocity = new int[] { 0x8, 0xd28, 0xa80 }; | |
public static int[] CarGravity = new int[] { 0x08, 0xd28, 0xC1C }; | |
public static int[] CarAcceleration = new int[] { 0x08, 0xd28, 0x918, 0x4c }; | |
public static int[] CarAcceleration1 = new int[] { 0x08, 0xd28, 0x918, 0x6c }; | |
public static int[] CarAcceleration2 = new int[] { 0x08, 0xd28, 0x918, 0x7c }; | |
public static int[] CarDeformationMultiplier = new int[] { 0x08, 0xd28, 0x918, 0xF8 }; | |
public static int[] CarCollisionDeformationMultiplier = new int[] { 0x08, 0xd28, 0x918, 0xF0 }; | |
public static int[] CarNeonActive = new int[] { 0x08, 0xd28, 0x48, 0x402 }; | |
public static int[] CarNeonR = new int[] { 0x08, 0xd28, 0x48, 0x3A2 }; | |
public static int[] CarNeonG = new int[] { 0x08, 0xd28, 0x48, 0x3A1 }; | |
public static int[] CarNeonB = new int[] { 0x08, 0xd28, 0x48, 0x3A0 }; | |
public static int[] CarPearlR = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xc2 }; | |
public static int[] CarPearlG = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xc1 }; | |
public static int[] CarPearlB = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xc0 }; | |
public static int[] CarPrimaryColorType = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xcc }; | |
public static int[] CarPrimaryR = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xa6 }; | |
public static int[] CarPrimaryG = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xa5 }; | |
public static int[] CarPrimaryB = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xa4 }; | |
public static int[] CarSecondaryColorType = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xcd }; | |
public static int[] CarSecondaryR = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xaa }; | |
public static int[] CarSecondaryG = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xa9 }; | |
public static int[] CarSecondaryB = new int[] { 0x08, 0xd28, 0x48, 0x20, 0xa8 }; | |
public static int[] CarEngineHealth1 = new int[] { 0x08, 0xd28, 0x280 }; | |
public static int[] CarEngineHealth2 = new int[] { 0x08, 0xd28, 0x89C }; | |
public static int[] CarDirtLevel = new int[] { 0x08, 0xd28, 0x988 }; | |
public static int[] RocketRecharge = new int[] { 0x08, 0xd28, 0x324 }; | |
public static int[] CurrentCar = new int[] { 0x08, 0xd28, 0x20, 0x18 }; | |
public static int[] CarX = new int[] { 0x08, 0xd28, 0x90 }; | |
public static int[] CarY = new int[] { 0x08, 0xd28, 0x94 }; | |
public static int[] CarZ = new int[] { 0x08, 0xd28, 0x98 }; | |
public static int[] CarVecX = new int[] { 0x08, 0xd28, 0x30, 0x50 }; | |
public static int[] CarVecY = new int[] { 0x08, 0xd28, 0x30, 0x54 }; | |
public static int[] CarVecZ = new int[] { 0x08, 0xd28, 0x30, 0x58 }; | |
public static int[] CarSpawn1 = new int[] { 0xc20d0 }; | |
public static int[] CarSpawn2 = new int[] { 0xC20E8 }; | |
public static int[] CarSpawnX = new int[] { 0xC20f8 }; | |
public static int[] CarSpawnY = new int[] { 0xC2100 }; | |
public static int[] CarSpawnZ = new int[] { 0xC2108 }; | |
public static int[] CarSpawnHash = new int[] { 0xC23a8 }; | |
public static int[] CarSpawnPlate = new int[] { 0xC21A0 }; | |
public static int[] CarSpawnProtect = new int[] { 0xC2488 }; | |
public static int[] CarSpawnProtect2 = new int[] { 0xC2490 }; | |
public static int[] CarSpawnAttr= new int[] { 0xC2400 }; | |
public static int[] CarSpawnColor = new int[] { 0xC21c8 }; | |
public static int[] WeaponSpread = new int[] { 0x08, 0x10C8, 0x20, 0x74 }; | |
public static int[] WeaponReloadSpeed = new int[] { 0x08, 0x10C8, 0x20, 0x12C }; | |
public static int[] WeaponRecoil = new int[] { 0x08, 0x10C8, 0x20, 0x2E8 }; | |
public static int[] BulletDamage = new int[] { 0x08, 0x10C8, 0x20, 0xB0 }; | |
public static int[] WeaponDamageType = new int[] { 0x08, 0x10C8, 0x20, 0x20 }; | |
public static int[] WeaponExplosionType = new int[] { 0x08, 0x10C8, 0x20, 0x24 }; | |
public static int[] RocketVelocity = new int[] { 0x08, 0x10C8, 0x20, 0x60, 0x58 }; | |
public static int[] ThrowGravity = new int[] { 0x08, 0x10C8, 0x20, 0x60, 0x68 }; | |
public static int[] WeaponSlot = new int[] { 0x08, 0x10C8, 0x20, 0x58 }; | |
public static int[] Firerate = new int[] { 0x08, 0x10C8, 0x20, 0x134 }; | |
public static int[] CurrentAmmo = new int[] { 0x08, 0x10C8, 0x20, 0x60, 0x8, 0, 0x18 }; | |
public static int[] MaxAmmo = new int[] { 0x08, 0x10C8, 0x20, 0x60, 0x28 }; | |
} | |
public enum ExplosionType { | |
AlienExplosion = 60, | |
Mk2Explosion = 18, | |
WaterSpray = 13, | |
FireSpray = 14, | |
KillAll = 59, | |
Thunder = 58, | |
Nuke = 49, | |
Snowball = 39, | |
Smoke = 19, | |
Flare = 22, | |
Normal = -1, | |
Unknown = -666 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment