├── .gitignore
├── BlyadTheftAuto.sln
├── BlyadTheftAuto
├── App.config
├── BlyadTheftAuto.csproj
├── BlyadTheftAuto.csproj.DotSettings
├── BlyadTheftAuto
│ ├── BlyadTheftAuto.cs
│ ├── NativeMethods.cs
│ ├── Program.cs
│ ├── Settings.cs
│ ├── Structs
│ │ ├── ColorRGB.cs
│ │ ├── RECT.cs
│ │ ├── Vector2D.cs
│ │ └── Vector3D.cs
│ └── Utils.cs
├── ConsoleSystem
│ ├── Console.cs
│ └── ConsoleColor.cs
├── Extensions
│ └── Extensions.cs
├── FeatureSystem
│ ├── BoolFeature.cs
│ ├── EventFeature.cs
│ ├── IFeature.cs
│ ├── IntFeature.cs
│ └── TeleportPosition.cs
├── GrandTheftAuto
│ └── Models
│ │ ├── Backup
│ │ ├── BackupVehicle.cs
│ │ ├── BackupVehicleHandling.cs
│ │ └── BackupWeapon.cs
│ │ ├── Entity.cs
│ │ ├── Ped.cs
│ │ ├── PlayerInfo.cs
│ │ ├── Vehicle.cs
│ │ ├── VehicleColors.cs
│ │ ├── VehicleHandling.cs
│ │ ├── Weapon.cs
│ │ └── World.cs
├── MemorySystem
│ ├── Enums
│ │ └── ScanMethod.cs
│ ├── Native
│ │ ├── Enums
│ │ │ ├── AllocationType.cs
│ │ │ ├── CreationFlags.cs
│ │ │ ├── FreeType.cs
│ │ │ ├── MemoryProtection.cs
│ │ │ └── ProcessAccessFlags.cs
│ │ ├── Library
│ │ │ └── Kernel32.cs
│ │ └── Structs
│ │ │ └── MemoryBasicInformation.cs
│ ├── PatternScan.cs
│ ├── ProcessMemory.cs
│ ├── RemoteAllocation.cs
│ ├── RemoteFunction.cs
│ ├── SignatureManager.cs
│ └── TypeCache.cs
├── Properties
│ └── AssemblyInfo.cs
└── app.manifest
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | #Ignore thumbnails created by Windows
3 | Thumbs.db
4 | #Ignore files built by Visual Studio
5 | *.obj
6 | *.exe
7 | *.pdb
8 | *.user
9 | *.aps
10 | *.pch
11 | *.vspscc
12 | *_i.c
13 | *_p.c
14 | *.ncb
15 | *.suo
16 | *.tlb
17 | *.tlh
18 | *.bak
19 | *.cache
20 | *.ilk
21 | *.log
22 | [Bb]in
23 | [Dd]ebug*/
24 | *.lib
25 | *.sbr
26 | obj/
27 | [Rr]elease*/
28 | _ReSharper*/
29 | [Tt]est[Rr]esult*
30 | .vs/
31 | #Nuget packages folder
32 | packages/
33 |
--------------------------------------------------------------------------------
/BlyadTheftAuto.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlyadTheftAuto", "BlyadTheftAuto\BlyadTheftAuto.csproj", "{34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Release|Any CPU = Release|Any CPU
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Debug|x64.ActiveCfg = Debug|x64
19 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Debug|x64.Build.0 = Debug|x64
20 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Release|x64.ActiveCfg = Release|x64
23 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {34FF8D6F-6DF3-4166-AE34-C0E6B6BD80CD}
8 | Exe
9 | Properties
10 | BlyadTheftAuto
11 | BlyadTheftAuto
12 | v4.5.1
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | true
27 | false
28 |
29 |
30 | AnyCPU
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 | false
38 |
39 |
40 | app.manifest
41 |
42 |
43 | true
44 | bin\x64\Debug\
45 | DEBUG;TRACE
46 | true
47 | full
48 | x64
49 | prompt
50 | MinimumRecommendedRules.ruleset
51 | true
52 |
53 |
54 | bin\x64\Release\
55 | TRACE
56 | true
57 | pdbonly
58 | x64
59 | prompt
60 | MinimumRecommendedRules.ruleset
61 | true
62 | true
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
137 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/BlyadTheftAuto.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto
9 | {
10 | internal static class BlyadTheftAuto
11 | {
12 | public static string GameName => "Grand Theft Auto V";
13 | public static string ProcessName => "GTA5";
14 | public static bool IsAttached { get; set; }
15 | public static int Width { get; set; }
16 | public static int Height { get; set; }
17 | public static ProcessMemory Memory { get; set; }
18 | public static PatternScan Game { get; set; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/NativeMethods.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.Structs;
2 | using System;
3 | using System.Runtime.InteropServices;
4 |
5 | namespace BlyadTheftAuto
6 | {
7 | internal class NativeMethods
8 | {
9 | [DllImport("user32.dll")]
10 | public static extern int GetWindowRect(IntPtr hwnd, out RECT lpRect);
11 | [DllImport("user32.dll")]
12 | public static extern int GetAsyncKeyState(int key);
13 | [DllImport("user32.dll")]
14 | public static extern IntPtr SendMessage(IntPtr hwnd, int msg, int wParam, int lParam);
15 | [DllImport("user32.dll")]
16 | public static extern IntPtr GetForegroundWindow();
17 | [DllImport("user32.dll")]
18 | public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BlyadTheftAuto.Extensions;
3 | using BlyadTheftAuto.FeatureSystem;
4 | using BlyadTheftAuto.GrandTheftAuto.Models;
5 | using BlyadTheftAuto.GrandTheftAuto.Models.Backup;
6 | using BlyadTheftAuto.MemorySystem;
7 | using BlyadTheftAuto.Structs;
8 | using System.Collections.Generic;
9 | using System.Diagnostics;
10 | using System.Drawing;
11 | using System.Linq;
12 | using System.Threading;
13 | using System.Windows.Forms;
14 | using Console = BlyadTheftAuto.ConsoleSystem.Console;
15 | using ConsoleColor = BlyadTheftAuto.ConsoleSystem.ConsoleColor;
16 |
17 | namespace BlyadTheftAuto
18 | {
19 | internal class Program
20 | {
21 | public static World World;
22 | public static List TeleportPresets = new List();
23 | private static IntFeature _teleportPreset;
24 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
25 | private static readonly List Features = new List();
26 | private static readonly List Whitelist = new List() { "Teleport", "Teleport High", "Stop Boost", "Save Position", "Set Preset"};
27 | private static readonly Thread KeyThread = new Thread(KeyLoop);
28 | private static readonly Thread InfoThread = new Thread(InfoLoop);
29 | //private static System.IntPtr AmmoPtr;
30 | //private static System.IntPtr ReloadPtr;
31 | //private static byte[] three_nops = { 0x90, 0x90, 0x90 };
32 | //private static byte[] ammo_backup = { 0x41, 0x2B, 0xD1 };
33 | //private static byte[] reload_backup = { 0x41, 0x2B, 0xC9 };
34 |
35 | //private static BackupVehicle _backupVehicle;
36 | private static BackupVehicleHandling _backupVehicleHandling;
37 | private static BackupWeapon _backupWeapon;
38 | private static Weapon _currentWeapon;
39 | private static VehicleHandling _currentVehicleHandling;
40 |
41 | internal static void Main(string[] args)
42 | {
43 | Console.SetWindowSize(Console.WindowWidth, 35);
44 | Console.Title = $"BlyadTheftAuto@{System.Environment.UserName}";
45 | Console.ForegroundColor = ConsoleColor.White;
46 | Console.WriteWatermark();
47 | Console.CursorVisible = false;
48 |
49 | Features.Add(new BoolFeature("Master Toggle", Keys.MButton));
50 | Features.Add(new BoolFeature("God Mode", Keys.NumPad0));
51 | Features.Add(new BoolFeature("Super Bullets", Keys.NumPad1)); //damage, bullet damage, bullet amount, range, no spinup, muzzle velocity
52 | Features.Add(new BoolFeature("Never Wanted", Keys.NumPad2));
53 | Features.Add(new BoolFeature("Car God Mode", Keys.NumPad3));
54 | Features.Add(new BoolFeature("Rank Boost", Keys.NumPad4));
55 |
56 | Features.Add(new EventFeature("Teleport", Teleport, Keys.NumPad5));
57 |
58 | Features.Add(new BoolFeature("Anti NPC", Keys.NumPad6));
59 | Features.Add(new BoolFeature("No Spread", Keys.NumPad7));
60 | Features.Add(new BoolFeature("No Recoil", Keys.NumPad8));
61 | Features.Add(new BoolFeature("No Reload", Keys.NumPad9));
62 |
63 | Features.Add(new BoolFeature("Super Jump", Keys.F5));
64 | Features.Add(new BoolFeature("Explosive Melee", Keys.F6));
65 | Features.Add(new BoolFeature("Explosive Ammo", Keys.F7));
66 | Features.Add(new BoolFeature("Fire Ammo", Keys.F8));
67 |
68 | Features.Add(new EventFeature("Teleport High", Teleport2, Keys.F9));
69 |
70 | Features.Add(new BoolFeature("Rainbow Vehicle", Keys.F11));
71 | Features.Add(new EventFeature("Suicide", Suicide, Keys.F12));
72 | Features.Add(new EventFeature("Stop Boost", StopBoost, Keys.E));
73 |
74 | Features.Add(new IntFeature("Acceleration", Keys.Up, Keys.Down, 1, 1, 10));
75 | Features.Add(new IntFeature("Brake Force", Keys.Right, Keys.Left, 1, 1, 10));
76 | Features.Add(new IntFeature("Traction Curve", Keys.Add, Keys.Subtract, 1, 1, 5));
77 | Features.Add(new IntFeature("Suspension Force", Keys.Multiply, Keys.Divide, 1, 0, 2));
78 | Features.Add(new IntFeature("Shift Rate", Keys.Home, Keys.End, 1, 1, 25));
79 | Features.Add(new IntFeature("Run/Swim Speed", Keys.Insert, Keys.Delete, 1, 1, 5));
80 | Features.Add(new IntFeature("Wanted Level", Keys.F3, Keys.F4, 1, 0, 5, ChangeWantedLevel));
81 | Features.Add(new EventFeature("Save Position", SavePosition, Keys.XButton1));
82 | Features.Add(new EventFeature("Set Preset", SetPreset, Keys.XButton2));
83 |
84 | TeleportPresets = Settings.GetTeleportPresets();
85 | _teleportPreset = new IntFeature("Teleport Preset", Keys.OemPeriod, Keys.Oemcomma, 1, 0, TeleportPresets.Count - 1);
86 |
87 | while (BlyadTheftAuto.Memory is null)
88 | {
89 | Thread.Sleep(100);
90 | Process process;
91 | try
92 | {
93 | process = Process.GetProcessesByName(BlyadTheftAuto.ProcessName).FirstOrDefault();
94 | if (process == null) continue;
95 | }
96 | catch
97 | {
98 | continue;
99 | }
100 |
101 | BlyadTheftAuto.Memory = new ProcessMemory(process);
102 | BlyadTheftAuto.Game = new PatternScan(BlyadTheftAuto.Memory, "GTA5.exe");
103 | }
104 |
105 | Console.WriteLine("\n Offsets:");
106 | Console.WriteOffset("World", SignatureManager.GetWorld().Subtract(BlyadTheftAuto.Memory.MainModule.BaseAddress));
107 | //Console.WriteOffset("Ammo", AmmoPtr = new System.IntPtr(0x0F71C38));
108 | //Console.WriteOffset("Reload", ReloadPtr = new System.IntPtr(0x0F71C7D));
109 |
110 | World = new World(SignatureManager.GetWorld());
111 |
112 | KeyThread.Start();
113 | InfoThread.Start();
114 |
115 | Console.WriteNotification("\n ");
116 |
117 | double rainbow = 0;
118 |
119 | while (Memory.IsProcessRunning)
120 | {
121 | rainbow += 0.01;
122 | if (rainbow >= 1) rainbow = 0;
123 |
124 | var localPlayer = World.GetLocalPlayer();
125 | var info = localPlayer.GetPlayerInfo();
126 | var weapon = localPlayer.GetWeapon();
127 | var vehicle = localPlayer.GetVehicle();
128 | var vehicleColors = vehicle.GetColors();
129 | var vehicleHandling = vehicle.GetHandling();
130 |
131 | if (Features.ByName("Rainbow Vehicle").Value)
132 | {
133 | var clr = GetRainbow(rainbow);
134 | vehicleColors.PrimaryRed = clr.R;
135 | vehicleColors.PrimaryGreen = clr.G;
136 | vehicleColors.PrimaryBlue = clr.B;
137 | vehicleColors.SecondaryRed = clr.R;
138 | vehicleColors.SecondaryGreen = clr.G;
139 | vehicleColors.SecondaryBlue = clr.B;
140 | }
141 |
142 | if (_currentWeapon == null)
143 | _currentWeapon = weapon;
144 | if (_backupWeapon == null)
145 | _backupWeapon = new BackupWeapon(_currentWeapon);
146 | if (_currentVehicleHandling == null)
147 | _currentVehicleHandling = vehicleHandling;
148 | if (_backupVehicleHandling == null)
149 | _backupVehicleHandling = new BackupVehicleHandling(_currentVehicleHandling);
150 |
151 | if (_backupWeapon.NameHash != weapon.NameHash)
152 | {
153 | _currentWeapon.Restore(_backupWeapon);
154 | _currentWeapon = weapon;
155 | _backupWeapon = new BackupWeapon(_currentWeapon);
156 | }
157 |
158 | if (_backupVehicleHandling.Address != vehicleHandling.Address)
159 | {
160 | _currentVehicleHandling.Restore(_backupVehicleHandling);
161 | _currentVehicleHandling = vehicleHandling;
162 | _backupVehicleHandling = new BackupVehicleHandling(_currentVehicleHandling);
163 | }
164 |
165 | localPlayer.GodMode = Features.ByName("God Mode").Value;
166 | localPlayer.CanBeRagdolled = !Features.ByName("God Mode").Value;
167 | localPlayer.HasSeatBelt = Features.ByName("God Mode").Value;
168 | if (Features.ByName("Never Wanted").Value) info.WantedLevel = 0;
169 |
170 | var carGodMode = Features.ByName("Car God Mode").Value;
171 | vehicle.GodMode = carGodMode;
172 | vehicleHandling.CollisionDamage = carGodMode ? 0.0f : 1;
173 | vehicleHandling.EngineDamage = carGodMode ? 0.0f : 1;
174 | vehicleHandling.WeaponDamage = carGodMode ? 0.0f : 1;
175 | vehicleHandling.DeformationDamage = carGodMode ? 0.0f : 1;
176 | if (carGodMode)
177 | vehicle.BulletproofTires = true;
178 | vehicle.BoostAmount = Int32.MaxValue;
179 |
180 | info.RunSpeed = Features.ByName("Run/Swim Speed").Value;
181 | info.SwimSpeed = Features.ByName("Run/Swim Speed").Value;
182 |
183 | vehicleHandling.Acceleration = Features.ByName("Acceleration").Value * _backupVehicleHandling.Acceleration;
184 | vehicleHandling.BrakeForce = Features.ByName("Brake Force").Value * _backupVehicleHandling.BrakeForce;
185 | vehicleHandling.HandBrakeForce = Features.ByName("Brake Force").Value * _backupVehicleHandling.HandBrakeForce;
186 | vehicleHandling.TractionCurveMin = Features.ByName("Traction Curve").Value * _backupVehicleHandling.TractionCurveMin;
187 | vehicleHandling.SuspensionForce = Features.ByName("Suspension Force").Value * _backupVehicleHandling.SuspensionForce;
188 |
189 | var frameFlags = info.FrameFlags;
190 | if (Features.ByName("Super Jump").Value)
191 | frameFlags |= 1 << 14;
192 | if (Features.ByName("Explosive Melee").Value)
193 | frameFlags |= 1 << 13;
194 | if (Features.ByName("Fire Ammo").Value)
195 | frameFlags |= 1 << 12;
196 | if (Features.ByName("Explosive Ammo").Value)
197 | frameFlags |= 1 << 11;
198 |
199 | info.FrameFlags = frameFlags;
200 |
201 | if (Features.ByName("Rank Boost").Value && !Features.ByName("Never Wanted").Value)
202 | {
203 | if (info.WantedLevel >= 5)
204 | info.WantedLevel = 0;
205 | else
206 | info.WantedLevel = 5;
207 | Thread.Sleep(10);
208 | }
209 |
210 | if (Features.ByName("Anti NPC").Value)
211 | {
212 | var attackers = localPlayer.GetAttackers();
213 | foreach (var ped in attackers)
214 | {
215 | ped.Health = 0;
216 | localPlayer.Health = localPlayer.MaxHealth;
217 | }
218 | }
219 |
220 | vehicleHandling.UpShift = _backupVehicleHandling.UpShift * Features.ByName("Shift Rate").Value;
221 |
222 | //weapon.ReloadTime = _backupWeapon.ReloadTime * (Features.ByName("Fast Reload").Value ? 10 : 1);
223 |
224 | var superBullets = Features.ByName("Super Bullets").Value;
225 | weapon.Damage = _backupWeapon.Damage * (superBullets ? 10 : 1);
226 | weapon.BulletBatch = _backupWeapon.BulletBatch * (superBullets ? 25 : 1);
227 | weapon.MuzzleVelocity = _backupWeapon.MuzzleVelocity * (superBullets ? 10 : 1);
228 | weapon.Range = _backupWeapon.Range * (superBullets ? 10 : 1);
229 | weapon.SpinUp = superBullets ? 0 : _backupWeapon.SpinUp;
230 | weapon.Spin = superBullets ? 0 : _backupWeapon.Spin;
231 |
232 | if (Features.ByName("No Reload").Value)
233 | _currentWeapon.PrimaryAmmoCount.AmmoCount = 9999;
234 |
235 | //if (Features.ByName("Infinite Ammo").Value)
236 | // Memory.WriteByteArray(AmmoPtr, three_nops);
237 | //else
238 | // Memory.WriteByteArray(AmmoPtr, ammo_backup);
239 |
240 | Thread.Sleep(10);
241 | }
242 | }
243 |
244 | private static void SetPreset()
245 | {
246 | World.GetLocalPlayer().Position = TeleportPresets[_teleportPreset.Value].Positon;
247 | }
248 |
249 | private static void SavePosition()
250 | {
251 | var pos = World.GetLocalPlayer().Position;
252 | var name = $"Preset{TeleportPresets.Count}";
253 | var telPos = new TeleportPosition(name, pos);
254 | TeleportPresets.Add(telPos);
255 | Settings.SaveTeleportPresets();
256 | }
257 |
258 | private static void StopBoost()
259 | {
260 | for(int i = 0; i < 20; i++)
261 | Memory.Write(World.GetLocalPlayer().GetVehicle().Address + 0x318, 0);
262 | }
263 |
264 | public static Color GetRainbow(double progress)
265 | {
266 | return Hsl2Rgb(progress, 0.5, 0.5);
267 | }
268 |
269 | public static ColorRGB Hsl2Rgb(double h, double sl, double l)
270 | {
271 | double v;
272 | double r, g, b;
273 |
274 | r = l; // default to gray
275 | g = l;
276 | b = l;
277 | v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
278 | if (v > 0)
279 | {
280 | var m = l + l - v;
281 | var sv = (v - m) / v;
282 | h *= 6.0;
283 | var sextant = (int)h;
284 | var fract = h - sextant;
285 | var vsf = v * sv * fract;
286 | var mid1 = m + vsf;
287 | var mid2 = v - vsf;
288 | switch (sextant)
289 | {
290 | case 0:
291 | r = v;
292 | g = mid1;
293 | b = m;
294 | break;
295 | case 1:
296 | r = mid2;
297 | g = v;
298 | b = m;
299 | break;
300 | case 2:
301 | r = m;
302 | g = v;
303 | b = mid1;
304 | break;
305 | case 3:
306 | r = m;
307 | g = mid2;
308 | b = v;
309 | break;
310 | case 4:
311 | r = mid1;
312 | g = m;
313 | b = v;
314 | break;
315 | case 5:
316 | r = v;
317 | g = m;
318 | b = mid2;
319 | break;
320 | }
321 | }
322 | ColorRGB rgb;
323 | rgb.R = System.Convert.ToByte(r * 255.0f);
324 | rgb.G = System.Convert.ToByte(g * 255.0f);
325 | rgb.B = System.Convert.ToByte(b * 255.0f);
326 | return rgb;
327 | }
328 |
329 | private static void InfoLoop()
330 | {
331 | while (Memory.IsProcessRunning)
332 | {
333 | var enabled = Features.ByName("Master Toggle").Value;
334 | var count = 0;
335 | foreach (var feature in Features)
336 | {
337 | if (!enabled && feature.Name != "Master Toggle" && !Whitelist.Contains(feature.Name)) Console.NotificationColor = ConsoleColor.Gray;
338 | else Console.NotificationColor = ConsoleColor.Yellow;
339 |
340 | var key = feature.Key.ToString();
341 | if (feature.SecondaryKey != Keys.None) key += "/" + feature.SecondaryKey;
342 | Console.WriteNotification($" [{key}] {feature.Name}: {feature.ToString()} ");
343 | count++;
344 | }
345 |
346 | Console.NotificationColor = ConsoleColor.Yellow;
347 | var val = _teleportPreset.Value;
348 | Console.WriteNotification($"\n [{_teleportPreset.Key}/{_teleportPreset.SecondaryKey}] {_teleportPreset.Name}: {TeleportPresets[val].Name} ({val}) ");
349 | count+=2;
350 |
351 | Console.SetCursorPosition(0, Console.CursorTop - count);
352 | Thread.Sleep(25);
353 | }
354 | }
355 |
356 | private static void Suicide()
357 | {
358 | World.GetLocalPlayer().Health = 0;
359 | }
360 |
361 | private static void Teleport()
362 | {
363 | var localPlayer = World.GetLocalPlayer();
364 | var vehicle = localPlayer.GetVehicle();
365 | var waypoint = localPlayer.GetWaypoint();
366 | var teleportPos = new Vector3D(waypoint, -225.0f);
367 | if (localPlayer.IsInVehicle)
368 | vehicle.Position = teleportPos;
369 | else
370 | localPlayer.Position = teleportPos;
371 | }
372 |
373 | private static void Teleport2()
374 | {
375 | var localPlayer = World.GetLocalPlayer();
376 | var vehicle = localPlayer.GetVehicle();
377 | var waypoint = localPlayer.GetWaypoint();
378 | var teleportPos = new Vector3D(waypoint, 225.0f);
379 | if (localPlayer.IsInVehicle)
380 | vehicle.Position = teleportPos;
381 | else
382 | localPlayer.Position = teleportPos;
383 | }
384 |
385 | private static void ChangeWantedLevel()
386 | {
387 | var localPlayer = World.GetLocalPlayer();
388 | var info = localPlayer.GetPlayerInfo();
389 | info.WantedLevel = Features.ByName("Wanted Level").Value;
390 | }
391 |
392 | private static void KeyLoop()
393 | {
394 | while(Memory.IsProcessRunning)
395 | {
396 | var enabled = Features.ByName("Master Toggle").Value;
397 | foreach (var feature in Features)
398 | {
399 | if (!enabled && feature.Name != "Master Toggle" && !Whitelist.Contains(feature.Name)) continue;
400 | if (Utils.IsKeyDown(feature.Key))
401 | {
402 | feature.OnKey();
403 | Thread.Sleep(150);
404 | }
405 | else if (Utils.IsKeyDown(feature.SecondaryKey))
406 | {
407 | feature.OnSecondaryKey();
408 | Thread.Sleep(150);
409 | }
410 | }
411 |
412 | if (_teleportPreset != null)
413 | {
414 | var prevVal = _teleportPreset.Value;
415 | _teleportPreset.Value = prevVal;
416 |
417 | if (Utils.IsKeyDown(_teleportPreset.Key))
418 | {
419 | _teleportPreset.OnKey();
420 | Thread.Sleep(150);
421 | }
422 | else if (Utils.IsKeyDown(_teleportPreset.SecondaryKey))
423 | {
424 | _teleportPreset.OnSecondaryKey();
425 | Thread.Sleep(150);
426 | }
427 | }
428 |
429 | Thread.Sleep(25);
430 | }
431 | }
432 | }
433 | }
434 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Settings.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.FeatureSystem;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BlyadTheftAuto
10 | {
11 | internal class Settings
12 | {
13 | private const string File = "./teleports.ini";
14 |
15 | public static List GetTeleportPresets()
16 | {
17 | List ret = new List();
18 | var sections = GetSectionNames();
19 | foreach(var section in sections)
20 | {
21 | var x = ParseFloat(ReadValue(section, "X"));
22 | var y = ParseFloat(ReadValue(section, "Y"));
23 | var z = ParseFloat(ReadValue(section, "Z"));
24 | ret.Add(new TeleportPosition(section, new Structs.Vector3D(x, y, z)));
25 | }
26 | return ret;
27 | }
28 |
29 | public static void SaveTeleportPresets()
30 | {
31 | foreach(var telPos in Program.TeleportPresets)
32 | {
33 | WriteValue(telPos.Name, "X", telPos.Positon.X.ToString());
34 | WriteValue(telPos.Name, "Y", telPos.Positon.Y.ToString());
35 | WriteValue(telPos.Name, "Z", telPos.Positon.Z.ToString());
36 | }
37 | }
38 |
39 |
40 | #region ReadWrite
41 | private static void WriteValue(string section, string key, string value)
42 | {
43 | WritePrivateProfileString(section, key, value, File);
44 | }
45 |
46 | private static string ReadValue(string section, string key)
47 | {
48 | var temp = new StringBuilder(255);
49 | GetPrivateProfileString(section, key, "", temp, 255, File);
50 |
51 | return temp.ToString();
52 | }
53 |
54 | private static string[] GetSectionNames()
55 | {
56 | // Sets the maxsize buffer to 500, if the more
57 | // is required then doubles the size each time.
58 | for (int maxsize = 500; true; maxsize *= 2)
59 | {
60 | // Obtains the information in bytes and stores
61 | // them in the maxsize buffer (Bytes array)
62 | byte[] bytes = new byte[maxsize];
63 | int size = GetPrivateProfileString(0, "", "", bytes, maxsize, File);
64 |
65 | // Check the information obtained is not bigger
66 | // than the allocated maxsize buffer - 2 bytes.
67 | // if it is, then skip over the next section
68 | // so that the maxsize buffer can be doubled.
69 | if (size < maxsize - 2)
70 | {
71 | // Converts the bytes value into an ASCII char. This is one long string.
72 | string Selected = Encoding.ASCII.GetString(bytes, 0,
73 | size - (size > 0 ? 1 : 0));
74 | // Splits the Long string into an array based on the "\0"
75 | // or null (Newline) value and returns the value(s) in an array
76 | return Selected.Split(new char[] { '\0' });
77 | }
78 | }
79 | }
80 | #endregion
81 | #region Parsing
82 | private static bool ParseBoolean(string input, bool defaultVal = false)
83 | {
84 | if (string.IsNullOrEmpty(input))
85 | return defaultVal;
86 |
87 | if (!bool.TryParse(input, out bool output))
88 | return defaultVal;
89 |
90 | return output;
91 | }
92 |
93 | private static int ParseInteger(string input, int defaultVal = 0)
94 | {
95 | if (string.IsNullOrEmpty(input))
96 | return defaultVal;
97 |
98 | if (!int.TryParse(input, out int output))
99 | return defaultVal;
100 |
101 | return output;
102 | }
103 |
104 | private static float ParseFloat(string input, float defaultVal = 0.0f)
105 | {
106 | if (string.IsNullOrEmpty(input))
107 | return defaultVal;
108 |
109 | if (!float.TryParse(input, out float output))
110 | return defaultVal;
111 |
112 | return output;
113 | }
114 | #endregion
115 | #region Native
116 | [DllImport("kernel32")]
117 | static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
118 | [DllImport("kernel32")]
119 | static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); // Third Method
120 | [DllImport("kernel32")]
121 | static extern int GetPrivateProfileString(int Section, string Key, string Value, [MarshalAs(UnmanagedType.LPArray)] byte[] Result, int Size, string FileName);
122 | #endregion
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Structs/ColorRGB.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto.Structs
9 | {
10 | public struct ColorRGB
11 | {
12 | public byte R;
13 | public byte G;
14 | public byte B;
15 | public ColorRGB(Color value)
16 | {
17 | this.R = value.R;
18 | this.G = value.G;
19 | this.B = value.B;
20 | }
21 | public static implicit operator Color(ColorRGB rgb)
22 | {
23 | Color c = Color.FromArgb(rgb.R, rgb.G, rgb.B);
24 | return c;
25 | }
26 | public static explicit operator ColorRGB(Color c)
27 | {
28 | return new ColorRGB(c);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Structs/RECT.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace BlyadTheftAuto.Structs
4 | {
5 | [StructLayout(LayoutKind.Sequential)]
6 | internal struct RECT
7 | {
8 | public int Left;
9 | public int Top;
10 | public int Right;
11 | public int Bottom;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Structs/Vector2D.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.Structs
4 | {
5 | internal struct Vector2D
6 | {
7 | public float X;
8 |
9 | public float Y;
10 |
11 | public Vector2D(float x = 0.0f, float y = 0.0f)
12 | {
13 | X = x;
14 | Y = y;
15 | }
16 |
17 | public bool IsEmpty
18 | {
19 | get
20 | {
21 | return X == 0.0f && Y == 0.0f;
22 | }
23 | }
24 |
25 | public float DistanceFrom(Vector2D pointB)
26 | {
27 | double d1 = X - pointB.X;
28 | double d2 = Y - pointB.Y;
29 |
30 | return (float)Math.Sqrt(d1 * d1 + d2 * d2);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Structs/Vector3D.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.Structs
4 | {
5 | internal struct Vector3D
6 | {
7 | public float X;
8 |
9 | public float Y;
10 |
11 | public float Z;
12 |
13 | public Vector3D(Vector2D vec2, float z)
14 | {
15 | X = vec2.X;
16 | Y = vec2.Y;
17 | Z = z;
18 | }
19 |
20 | public Vector3D(float x, float y, float z)
21 | {
22 | X = x;
23 | Y = y;
24 | Z = z;
25 | }
26 |
27 | public static Vector3D Zero
28 | {
29 | get
30 | {
31 | return new Vector3D();
32 | }
33 | }
34 |
35 | public float Length()
36 | {
37 | return (float)Math.Sqrt((X * X) + (Y * Y) + (Z * Z));
38 | }
39 |
40 | public void Rotate()
41 | {
42 | var ret = new Vector3D()
43 | {
44 | X = this.Z,
45 | Y = this.Y,
46 | Z = this.X
47 | };
48 | this = ret;
49 | }
50 |
51 | public float LengthSqr()
52 | {
53 | return (X * X + Y * Y + Z * Z);
54 | }
55 |
56 | public bool IsEmpty
57 | {
58 | get
59 | {
60 | return this == Zero;
61 | }
62 | }
63 |
64 | public static float Distance(Vector3D a, Vector3D b)
65 | {
66 | var vec3 = a - b;
67 | var single = (float)Math.Sqrt((double)(vec3.X * vec3.X + vec3.Y * vec3.Y + vec3.Z * vec3.Z));
68 | return single;
69 | }
70 |
71 | public float DistanceInMetres(Vector3D other)
72 | {
73 | return Distance(this, other) * 0.01905f;
74 | }
75 |
76 | public float DistanceFrom(Vector3D vec)
77 | {
78 | return Distance(this, vec);
79 | }
80 |
81 | public static float Dot(Vector3D left, Vector3D right)
82 | {
83 | float single = left.X * right.X + left.Y * right.Y + left.Z * right.Z;
84 | return single;
85 | }
86 |
87 | public static Vector3D operator +(Vector3D a, Vector3D b)
88 | {
89 | var vec3 = new Vector3D
90 | {
91 | X = a.X + b.X,
92 | Y = a.Y + b.Y,
93 | Z = a.Z + b.Z
94 | };
95 | return vec3;
96 | }
97 |
98 | public static Vector3D operator *(Vector3D a, float b)
99 | {
100 | var vec3 = new Vector3D
101 | {
102 | X = a.X * b,
103 | Y = a.Y * b,
104 | Z = a.Z * b
105 | };
106 | return vec3;
107 | }
108 |
109 | public static Vector3D operator +(Vector3D a, float b)
110 | {
111 | var vec3 = new Vector3D
112 | {
113 | X = a.X + b,
114 | Y = a.Y + b,
115 | Z = a.Z + b
116 | };
117 | return vec3;
118 | }
119 |
120 | public static Vector3D operator -(Vector3D a, float b)
121 | {
122 | var vec3 = new Vector3D
123 | {
124 | X = a.X - b,
125 | Y = a.Y - b,
126 | Z = a.Z - b
127 | };
128 | return vec3;
129 | }
130 |
131 | public static Vector3D operator /(Vector3D value, float scale)
132 | {
133 | return new Vector3D(value.X / scale, value.Y / scale, value.Z / scale);
134 | }
135 |
136 | public static Vector3D operator *(Vector3D a, Vector3D b)
137 | {
138 | var vec3 = new Vector3D
139 | {
140 | X = a.Y * b.Z - a.Z * b.Y,
141 | Y = a.Z * b.X - a.X * b.Z,
142 | Z = a.X * b.Y - a.Y * b.X
143 | };
144 | return vec3;
145 | }
146 |
147 | public static Vector3D operator -(Vector3D a, Vector3D b)
148 | {
149 | var vec3 = new Vector3D
150 | {
151 | X = a.X - b.X,
152 | Y = a.Y - b.Y,
153 | Z = a.Z - b.Z
154 | };
155 | return vec3;
156 | }
157 |
158 | public override bool Equals(object other)
159 | {
160 | return this == (Vector3D)other;
161 | }
162 |
163 | public static bool operator ==(Vector3D a, Vector3D b)
164 | {
165 | return a.X == b.X && a.Y == b.Y && a.Z == b.Z;
166 | }
167 |
168 | public static bool operator !=(Vector3D a, Vector3D b)
169 | {
170 | return a.X != b.X || a.Y != b.Y || a.Z != b.Z;
171 | }
172 |
173 | public override string ToString()
174 | {
175 | return $"X: {X}, Y: {Y}, Z: {Z}";
176 | }
177 | }
178 | }
--------------------------------------------------------------------------------
/BlyadTheftAuto/BlyadTheftAuto/Utils.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem;
2 | using System;
3 | using System.Diagnostics;
4 | using System.Linq;
5 |
6 | namespace BlyadTheftAuto
7 | {
8 | internal class Utils
9 | {
10 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
11 |
12 | public static bool IsModuleLoaded(Process p, string moduleName)
13 | {
14 | var q = from m in p.Modules.OfType()
15 | select m;
16 | return q.Any(pm => pm.ModuleName == moduleName && (int)pm.BaseAddress != 0);
17 | }
18 |
19 | public static bool IsKeyDown(System.Windows.Forms.Keys key)
20 | {
21 | return IsKeyDown((int)key);
22 | }
23 |
24 | public static bool IsKeyDown(int key)
25 | {
26 | return (NativeMethods.GetAsyncKeyState(key) & 0x8000) != 0;
27 | }
28 |
29 | public static string ByteSizeToString(long size)
30 | {
31 | string[] strArrays = new string[] { "B", "KB", "MB", "GB", "TB" };
32 | int num = 0;
33 | while (size > 1024)
34 | {
35 | size = size / 1024;
36 | num++;
37 | }
38 | string str = string.Format("{0} {1}", size.ToString(), strArrays[num]);
39 | return str;
40 | }
41 |
42 | /*public static bool IsPointInRadius(Vector2D point, Vector2D center, float radius)
43 | {
44 | return Math.Sqrt(((center.X - point.X) * (center.X - point.X)) + ((center.Y - point.Y) * (center.Y - point.Y))) < radius;
45 | }
46 |
47 | public static float DistanceToPoint(Vector2D point, Vector2D otherPoint)
48 | {
49 | float ydist = (otherPoint.Y - point.Y);
50 | float xdist = (otherPoint.X - point.X);
51 | float hypotenuse = Convert.ToSingle(Math.Sqrt(Math.Pow(ydist, 2) + Math.Pow(xdist, 2)));
52 | return hypotenuse;
53 | }*/
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/ConsoleSystem/Console.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.Extensions;
2 | using System.Reflection;
3 |
4 | namespace BlyadTheftAuto.ConsoleSystem
5 | {
6 | internal class Console
7 | {
8 | #region VARIABLES
9 | private static ConsoleColor _notificationColor = ConsoleColor.Yellow;
10 | private static string CommandLine { get; } = ">" + System.Environment.UserName + ": ";
11 | public static string Watermark { get; } = $"BlyadTheftAuto v{Assembly.GetExecutingAssembly().GetName().Version.ToString()} ({Assembly.GetExecutingAssembly().GetLinkerTime()})";
12 | public static string Credits { get; } = "by Requi @ www.requi-dev.de";
13 | public static ConsoleColor NotificationColor
14 | {
15 | get
16 | {
17 | return _notificationColor;
18 | }
19 | set
20 | {
21 | _notificationColor = value;
22 | }
23 | }
24 | #endregion
25 |
26 | #region PROPERTIES
27 | public static ConsoleColor BackgroundColor
28 | {
29 | get
30 | {
31 | return (ConsoleColor)System.Console.BackgroundColor;
32 | }
33 | set
34 | {
35 | System.Console.BackgroundColor = (System.ConsoleColor)value;
36 | }
37 | }
38 |
39 | public static int BufferHeight
40 | {
41 | get
42 | {
43 | return System.Console.BufferHeight;
44 | }
45 | set
46 | {
47 | System.Console.BufferHeight = value;
48 | }
49 | }
50 |
51 | public static int BufferWidth
52 | {
53 | get
54 | {
55 | return System.Console.BufferWidth;
56 | }
57 | set
58 | {
59 | System.Console.BufferWidth = value;
60 | }
61 | }
62 |
63 | public static bool CapsLock
64 | {
65 | get
66 | {
67 | return System.Console.CapsLock;
68 | }
69 | }
70 |
71 | public static int CursorLeft
72 | {
73 | get
74 | {
75 | return System.Console.CursorLeft;
76 | }
77 | set
78 | {
79 | System.Console.CursorLeft = value;
80 | }
81 | }
82 |
83 | public static int CursorSize
84 | {
85 | get
86 | {
87 | return System.Console.CursorSize;
88 | }
89 | set
90 | {
91 | System.Console.CursorSize = value;
92 | }
93 | }
94 |
95 | public static int CursorTop
96 | {
97 | get
98 | {
99 | return System.Console.CursorTop;
100 | }
101 | set
102 | {
103 | System.Console.CursorTop = value;
104 | }
105 | }
106 |
107 | public static bool CursorVisible
108 | {
109 | get
110 | {
111 | return System.Console.CursorVisible;
112 | }
113 | set
114 | {
115 | System.Console.CursorVisible = value;
116 | }
117 | }
118 |
119 | public static System.IO.TextWriter Error
120 | {
121 | get
122 | {
123 | return System.Console.Error;
124 | }
125 | }
126 |
127 | public static ConsoleColor ForegroundColor
128 | {
129 | get
130 | {
131 | return (ConsoleColor)System.Console.ForegroundColor;
132 | }
133 | set
134 | {
135 | System.Console.ForegroundColor = (System.ConsoleColor)value;
136 | }
137 | }
138 |
139 | public static System.IO.TextReader In
140 | {
141 | get
142 | {
143 | return System.Console.In;
144 | }
145 | }
146 |
147 | public static System.Text.Encoding InputEncoding
148 | {
149 | get
150 | {
151 | return System.Console.InputEncoding;
152 | }
153 | set
154 | {
155 | System.Console.InputEncoding = value;
156 | }
157 | }
158 |
159 | public static bool IsErrorRedirected
160 | {
161 | get
162 | {
163 | return System.Console.IsErrorRedirected;
164 | }
165 | }
166 |
167 | public static bool IsInputRedirected
168 | {
169 | get
170 | {
171 | return System.Console.IsInputRedirected;
172 | }
173 | }
174 |
175 | public static bool IsOutputRedirected
176 | {
177 | get
178 | {
179 | return System.Console.IsOutputRedirected;
180 | }
181 | }
182 |
183 | public static bool KeyAvailable
184 | {
185 | get
186 | {
187 | return System.Console.KeyAvailable;
188 | }
189 | }
190 |
191 | public static int LargestWindowHeight
192 | {
193 | get
194 | {
195 | return System.Console.LargestWindowHeight;
196 | }
197 | }
198 |
199 | public static int LargestWindowWidth
200 | {
201 | get
202 | {
203 | return System.Console.LargestWindowWidth;
204 | }
205 | }
206 |
207 | public static bool NumberLock
208 | {
209 | get
210 | {
211 | return System.Console.NumberLock;
212 | }
213 | }
214 |
215 | public static System.IO.TextWriter Out
216 | {
217 | get
218 | {
219 | return System.Console.Out;
220 | }
221 | }
222 |
223 | public static System.Text.Encoding OutputEncoding
224 | {
225 | get
226 | {
227 | return System.Console.OutputEncoding;
228 | }
229 | set
230 | {
231 | System.Console.OutputEncoding = value;
232 | }
233 | }
234 | public static string Title
235 | {
236 | get
237 | {
238 | return System.Console.Title;
239 | }
240 | set
241 | {
242 | System.Console.Title = value;
243 | }
244 | }
245 |
246 | public static bool TreatControlCAsInput
247 | {
248 | get
249 | {
250 | return System.Console.TreatControlCAsInput;
251 | }
252 | set
253 | {
254 | System.Console.TreatControlCAsInput = value;
255 | }
256 | }
257 |
258 | public static int WindowHeight
259 | {
260 | get
261 | {
262 | return System.Console.WindowHeight;
263 | }
264 | set
265 | {
266 | System.Console.WindowHeight = value;
267 | }
268 | }
269 |
270 | public static int WindowLeft
271 | {
272 | get
273 | {
274 | return System.Console.WindowLeft;
275 | }
276 | set
277 | {
278 | System.Console.WindowLeft = value;
279 | }
280 | }
281 |
282 | public static int WindowTop
283 | {
284 | get
285 | {
286 | return System.Console.WindowTop;
287 | }
288 | set
289 | {
290 | System.Console.WindowTop = value;
291 | }
292 | }
293 |
294 | public static int WindowWidth
295 | {
296 | get
297 | {
298 | return System.Console.WindowWidth;
299 | }
300 | set
301 | {
302 | System.Console.WindowWidth = value;
303 | }
304 | }
305 | #endregion
306 |
307 | #region METHODS
308 | public static void Beep()
309 | {
310 | System.Console.Beep();
311 | }
312 | public static void Beep(int frequency, int duration)
313 | {
314 | System.Console.Beep(frequency, duration);
315 | }
316 | public static void Clear()
317 | {
318 | System.Console.Clear();
319 | }
320 | public static void Beep(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop)
321 | {
322 | System.Console.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop);
323 | }
324 | public static void Beep(int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight, int targetLeft, int targetTop, char sourceChar, System.ConsoleColor sourceForeColor, System.ConsoleColor sourceBackColor)
325 | {
326 | System.Console.MoveBufferArea(sourceLeft, sourceTop, sourceWidth, sourceHeight, targetLeft, targetTop, sourceChar, sourceForeColor, sourceBackColor);
327 | }
328 | public static System.IO.Stream OpenStandardError()
329 | {
330 | return System.Console.OpenStandardError();
331 | }
332 | public static System.IO.Stream OpenStandardError(int bufferSize)
333 | {
334 | return System.Console.OpenStandardError(bufferSize);
335 | }
336 | public static System.IO.Stream OpenStandardInput()
337 | {
338 | return System.Console.OpenStandardInput();
339 | }
340 | public static System.IO.Stream OpenStandardInput(int bufferSize)
341 | {
342 | return System.Console.OpenStandardInput(bufferSize);
343 | }
344 | public static System.IO.Stream OpenStandardOutput()
345 | {
346 | return System.Console.OpenStandardOutput();
347 | }
348 | public static System.IO.Stream OpenStandardOutput(int bufferSize)
349 | {
350 | return System.Console.OpenStandardOutput(bufferSize);
351 | }
352 | public static int Read()
353 | {
354 | return System.Console.Read();
355 | }
356 | public static System.ConsoleKeyInfo ReadKey()
357 | {
358 | return System.Console.ReadKey();
359 | }
360 | public static System.ConsoleKeyInfo ReadKey(bool intercept)
361 | {
362 | return System.Console.ReadKey(intercept);
363 | }
364 | public static string ReadLine()
365 | {
366 | return System.Console.ReadLine();
367 | }
368 | public static void ResetColor()
369 | {
370 | System.Console.ResetColor();
371 | }
372 | public static void SetBufferSize(int width, int height)
373 | {
374 | System.Console.SetBufferSize(width, height);
375 | }
376 | public static void SetCursorPosition(int left, int top)
377 | {
378 | System.Console.SetCursorPosition(left, top);
379 | }
380 | public static void SetError(System.IO.TextWriter newError)
381 | {
382 | System.Console.SetError(newError);
383 | }
384 | public static void SetIn(System.IO.TextReader newIn)
385 | {
386 | System.Console.SetIn(newIn);
387 | }
388 | public static void SetOut(System.IO.TextWriter newOut)
389 | {
390 | System.Console.SetOut(newOut);
391 | }
392 | public static void SetWindowPosition(int left, int top)
393 | {
394 | System.Console.SetWindowPosition(left, top);
395 | }
396 | public static void SetWindowSize(int width, int height)
397 | {
398 | System.Console.SetWindowSize(width, height);
399 | }
400 | public static void WriteLine(string value)
401 | {
402 | System.Console.WriteLine(value);
403 | }
404 | public static void Write(string value)
405 | {
406 | System.Console.Write(value);
407 | }
408 | #endregion
409 |
410 | #region MY METHODS
411 | public static void WriteSuccess(string value, bool sucess = true)
412 | {
413 | ForegroundColor = sucess ? ConsoleColor.Green : ConsoleColor.Red;
414 | WriteLine(value);
415 | ForegroundColor = ConsoleColor.White;
416 | }
417 |
418 | public static void WriteNotification(string value)
419 | {
420 | ForegroundColor = _notificationColor;
421 | WriteLine(value);
422 | ForegroundColor = ConsoleColor.White;
423 | }
424 |
425 | public static void WriteOffset(string name, System.IntPtr offset)
426 | {
427 | WriteSuccess($" \t{name}\t0x{offset.ToString("X").PadLeft(8, '0')}", offset != System.IntPtr.Zero);
428 | }
429 |
430 | public static void WriteCommandLine()
431 | {
432 | Write(CommandLine);
433 | }
434 |
435 | public static void WriteCustomLine(string value)
436 | {
437 | WriteLine(value);
438 | WriteCommandLine();
439 | }
440 |
441 | public static void WriteWatermark()
442 | {
443 | Clear();
444 | WriteLine(string.Format("{0," + ((WindowWidth / 2) + (Watermark.Length / 2)) + "}", Watermark));
445 | WriteLine(string.Format("{0," + ((WindowWidth / 2) + (Credits.Length / 2)) + "}", Credits));
446 | Write("\n\n\n");
447 | }
448 | #endregion
449 | }
450 | }
451 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/ConsoleSystem/ConsoleColor.cs:
--------------------------------------------------------------------------------
1 | namespace BlyadTheftAuto.ConsoleSystem
2 | {
3 | internal enum ConsoleColor
4 | {
5 | Black = 0,
6 | DarkBlue = 1,
7 | DarkGreen = 2,
8 | DarkCyan = 3,
9 | DarkRed = 4,
10 | DarkMagenta = 5,
11 | DarkYellow = 6,
12 | Gray = 7,
13 | DarkGray = 8,
14 | Blue = 9,
15 | Green = 10,
16 | Cyan = 11,
17 | Red = 12,
18 | Magenta = 13,
19 | Yellow = 14,
20 | White = 15
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/Extensions/Extensions.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.FeatureSystem;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Reflection;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace BlyadTheftAuto.Extensions
11 | {
12 | internal static class Extensions
13 | {
14 | public static DateTime GetLinkerTime(this Assembly assembly, TimeZoneInfo target = null)
15 | {
16 | var filePath = assembly.Location;
17 | const int c_PeHeaderOffset = 60;
18 | const int c_LinkerTimestampOffset = 8;
19 |
20 | var buffer = new byte[2048];
21 |
22 | using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
23 | stream.Read(buffer, 0, 2048);
24 |
25 | var offset = BitConverter.ToInt32(buffer, c_PeHeaderOffset);
26 | var secondsSince1970 = BitConverter.ToInt32(buffer, offset + c_LinkerTimestampOffset);
27 | var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
28 |
29 | var linkTimeUtc = epoch.AddSeconds(secondsSince1970);
30 |
31 | var tz = target ?? TimeZoneInfo.Local;
32 | var localTime = TimeZoneInfo.ConvertTimeFromUtc(linkTimeUtc, tz);
33 |
34 | return localTime;
35 | }
36 |
37 | public static IntPtr Add(this IntPtr first, IntPtr second)
38 | {
39 | if (IntPtr.Size == 4)
40 | return new IntPtr(first.ToInt32() + second.ToInt32());
41 | return new IntPtr(first.ToInt64() + second.ToInt64());
42 | }
43 |
44 | public static IntPtr Subtract(this IntPtr first, IntPtr second)
45 | {
46 | if (IntPtr.Size == 4)
47 | return new IntPtr(first.ToInt32() - second.ToInt32());
48 | return new IntPtr(first.ToInt64() - second.ToInt64());
49 | }
50 |
51 | public static T ByName(this List list, string name)
52 | {
53 | return ((T)list.Find(f => f.Name == name));
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/FeatureSystem/BoolFeature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace BlyadTheftAuto.FeatureSystem
9 | {
10 | internal class BoolFeature : IFeature
11 | {
12 | private string _name;
13 | private Keys _key;
14 | private Keys _secondaryKey = Keys.None;
15 | private bool _status;
16 | private Action _function;
17 |
18 | public string Name => _name;
19 | public Keys Key => _key;
20 | public Keys SecondaryKey => _secondaryKey;
21 | public bool Value => _status;
22 |
23 | public BoolFeature(string name, Keys key, Action function = null)
24 | {
25 | _name = name;
26 | _key = key;
27 | _function = function;
28 | }
29 |
30 | public void OnKey()
31 | {
32 | _status = !_status;
33 | _function?.Invoke();
34 | }
35 |
36 | public void OnSecondaryKey()
37 | {
38 | return;
39 | }
40 |
41 | public override string ToString()
42 | {
43 | return _status.ToString();
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/FeatureSystem/EventFeature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace BlyadTheftAuto.FeatureSystem
9 | {
10 | internal class EventFeature : IFeature
11 | {
12 | private string _name;
13 | private Keys _key;
14 | private Keys _secondaryKey = Keys.None;
15 | private string _status;
16 | private Action _function;
17 |
18 | public string Name => _name;
19 | public Keys Key => _key;
20 | public Keys SecondaryKey => _secondaryKey;
21 |
22 |
23 | public EventFeature(string name, Action function, Keys key, Keys secondaryKey = Keys.None)
24 | {
25 | _name = name;
26 | _key = key;
27 | _secondaryKey = secondaryKey;
28 | _function = function;
29 | _status = "Idle";
30 | }
31 |
32 | public void OnKey()
33 | {
34 | _status = "Running";
35 | _function();
36 | _status = "Idle";
37 | }
38 |
39 | public void OnSecondaryKey()
40 | {
41 | _status = "Running";
42 | _function();
43 | _status = "Idle";
44 | }
45 |
46 | public override string ToString()
47 | {
48 | return _status;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/FeatureSystem/IFeature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace BlyadTheftAuto.FeatureSystem
9 | {
10 | internal interface IFeature
11 | {
12 | string Name { get; }
13 | Keys Key { get; }
14 | Keys SecondaryKey { get; }
15 |
16 | void OnKey();
17 | void OnSecondaryKey();
18 | string ToString();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/FeatureSystem/IntFeature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Forms;
7 |
8 | namespace BlyadTheftAuto.FeatureSystem
9 | {
10 | internal class IntFeature : IFeature
11 | {
12 | private string _name;
13 | private Keys _key;
14 | private Keys _secondaryKey = Keys.None;
15 | private int _amount;
16 | private int _change;
17 | private int _min;
18 | private int _max;
19 | private Action _function;
20 |
21 | public string Name => _name;
22 | public Keys Key => _key;
23 | public Keys SecondaryKey => _secondaryKey;
24 | public int Min => _min;
25 | public int Max => _max;
26 | public int Value
27 | {
28 | get => _amount;
29 | set => _amount = value;
30 | }
31 |
32 |
33 | public IntFeature(string name, Keys key, Keys secondaryKey, int change, int min, int max, Action function = null)
34 | {
35 | _name = name;
36 | _key = key;
37 | _secondaryKey = secondaryKey;
38 | _change = change;
39 | _min = min;
40 | _max = max;
41 | _amount = _min;
42 | _function = function;
43 | }
44 |
45 | public void OnKey()
46 | {
47 | _amount += _change;
48 | if (_amount > _max) _amount = _max;
49 | _function?.Invoke();
50 | }
51 | public void OnSecondaryKey()
52 | {
53 | _amount -= _change;
54 | if (_amount < _min) _amount = _min;
55 | _function?.Invoke();
56 | }
57 |
58 | public override string ToString()
59 | {
60 | return _amount.ToString();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/FeatureSystem/TeleportPosition.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.Structs;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto.FeatureSystem
9 | {
10 | internal class TeleportPosition
11 | {
12 | public TeleportPosition(string name, Vector3D position)
13 | {
14 | _name = name;
15 | _positon = position;
16 | }
17 |
18 | private string _name;
19 | private Vector3D _positon;
20 |
21 | public string Name => _name;
22 | public Vector3D Positon => _positon;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Backup/BackupVehicle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BlyadTheftAuto.GrandTheftAuto.Models.Backup
8 | {
9 | internal class BackupVehicle
10 | {
11 | ///
12 | /// Backup Members of Vehicle. Not being used currently.
13 | ///
14 | private float _gravity;
15 | private int _alarmLength;
16 |
17 | public float Gravity => _gravity;
18 | public int AlarmLength => _alarmLength;
19 |
20 | public BackupVehicle(Vehicle copy)
21 | {
22 | _gravity = copy.Gravity;
23 | _alarmLength = copy.AlarmLength;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Backup/BackupVehicleHandling.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BlyadTheftAuto.GrandTheftAuto.Models.Backup
8 | {
9 | internal class BackupVehicleHandling
10 | {
11 | ///
12 | /// Backup members of VehicleHandling
13 | ///
14 | private IntPtr _address;
15 | private float _acceleration;
16 | private float _brakeForce;
17 | private float _handBrakeForce;
18 | private float _tractionCurveMin;
19 | private float _collisionDamage;
20 | private float _weaponDamage;
21 | private float _deformationDamage;
22 | private float _engineDamage;
23 | private float _upShift;
24 | private float _suspensionForce;
25 |
26 | public IntPtr Address => _address;
27 | public float Acceleration => _acceleration;
28 | public float BrakeForce => _brakeForce;
29 | public float HandBrakeForce => _handBrakeForce;
30 | public float TractionCurveMin => _tractionCurveMin;
31 | public float CollisionDamage => _collisionDamage;
32 | public float WeaponDamage => _weaponDamage;
33 | public float DeformationDamage => _deformationDamage;
34 | public float EngineDamage => _engineDamage;
35 | public float UpShift => _upShift;
36 | public float SuspensionForce => _suspensionForce;
37 |
38 | public BackupVehicleHandling(VehicleHandling copy)
39 | {
40 | _address = copy.Address;
41 | _acceleration = copy.Acceleration;
42 | _brakeForce = copy.BrakeForce;
43 | _handBrakeForce = copy.HandBrakeForce;
44 | _tractionCurveMin = copy.TractionCurveMin;
45 | _collisionDamage = copy.CollisionDamage;
46 | _weaponDamage = copy.WeaponDamage;
47 | _deformationDamage = copy.DeformationDamage;
48 | _engineDamage = copy.EngineDamage;
49 | _upShift = copy.UpShift;
50 | _suspensionForce = copy.SuspensionForce;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Backup/BackupWeapon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace BlyadTheftAuto.GrandTheftAuto.Models.Backup
8 | {
9 | internal class BackupWeapon
10 | {
11 | ///
12 | /// Backup members of Weapon
13 | ///
14 | private int _nameHash;
15 | private float _damage;
16 | private int _bulletBatch;
17 | private float _reloadTime;
18 | private float _spread;
19 | private float _batchSpread;
20 | private float _range;
21 | private float _recoil;
22 | private float _spinUp;
23 | private float _spin;
24 | private float _muzzleVelocity;
25 |
26 | public float Recoil => _recoil;
27 | public float Range => _range;
28 | public float Spread => _spread;
29 | public float BatchSpread => _batchSpread;
30 | public float ReloadTime => _reloadTime;
31 | public int BulletBatch => _bulletBatch;
32 | public float Damage => _damage;
33 | public int NameHash => _nameHash;
34 | public float SpinUp => _spinUp;
35 | public float Spin => _spin;
36 | public float MuzzleVelocity => _muzzleVelocity;
37 |
38 | public BackupWeapon(Weapon copy)
39 | {
40 | _nameHash = copy.NameHash;
41 | _damage = copy.Damage;
42 | _bulletBatch = copy.BulletBatch;
43 | _reloadTime = copy.ReloadTime;
44 | _recoil = copy.Recoil;
45 | _batchSpread = copy.BatchSpread;
46 | _spread = copy.Spread;
47 | _range = copy.Range;
48 | _reloadTime = copy.Recoil;
49 | _spinUp = copy.SpinUp;
50 | _spin = copy.Spin;
51 | _muzzleVelocity = copy.MuzzleVelocity;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Entity.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem;
2 | using BlyadTheftAuto.Structs;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BlyadTheftAuto.GrandTheftAuto.Models
10 | {
11 | internal class Entity
12 | {
13 | protected static ProcessMemory Memory => BlyadTheftAuto.Memory;
14 | protected byte[] readData;
15 | protected IntPtr address;
16 |
17 | public Entity(IntPtr address)
18 | {
19 | this.address = address;
20 | Update();
21 | }
22 |
23 | public IntPtr Address => address;
24 |
25 | public void Update()
26 | {
27 | readData = Memory.ReadByteArray(address, 0x14F4);
28 | }
29 |
30 | public bool GodMode
31 | {
32 | get
33 | {
34 | return readData[0x189] == 1;
35 | }
36 | set
37 | {
38 | Memory.Write(address + 0x189, (char)(value ? 1 : 0));
39 | }
40 | }
41 |
42 | public Vector3D Position
43 | {
44 | get
45 | {
46 | byte[] vecData = new byte[12];
47 | Buffer.BlockCopy(readData, 0x90, vecData, 0, 12);
48 | return ProcessMemory.BytesTo(vecData);
49 | }
50 | set
51 | {
52 | var navigation = new IntPtr(BitConverter.ToInt64(readData, 0x30));
53 | Memory.Write(navigation + 0x50, value);
54 | Memory.Write(address + 0x90, value);
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Ped.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.Structs;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto.GrandTheftAuto.Models
9 | {
10 | internal class Ped : Entity
11 | {
12 | public Ped(IntPtr address) : base(address)
13 | {
14 | }
15 |
16 | public Vector2D GetWaypoint()
17 | {
18 | var radar = new IntPtr(BitConverter.ToInt64(readData, 0xD0));
19 | return Memory.Read(radar + 0x4A8);
20 | }
21 |
22 | public float Health
23 | {
24 | get
25 | {
26 | return BitConverter.ToSingle(readData, 0x280);
27 | }
28 | set
29 | {
30 | Memory.Write(address + 0x280, value);
31 | }
32 | }
33 |
34 | public float MaxHealth
35 | {
36 | get
37 | {
38 | return BitConverter.ToSingle(readData, 0x2A0);
39 | }
40 | }
41 |
42 | public List GetAttackers()
43 | {
44 | var retList = new List();
45 | var attackerBase = new IntPtr(BitConverter.ToInt64(readData, 0x2A8));
46 | for (var i = 0; i < 3; i++)
47 | {
48 | var npc = new Ped(Memory.Read(attackerBase + (i * 0x18)));
49 | if (npc.address == IntPtr.Zero) continue;
50 | if (npc.address == address) continue;
51 | if (npc.Health < 1.0f) continue;
52 | retList.Add(npc);
53 | }
54 | return retList;
55 | }
56 |
57 | public PlayerInfo GetPlayerInfo()
58 | {
59 | return new PlayerInfo(new IntPtr(BitConverter.ToInt64(readData, 0x10c8)));
60 | }
61 |
62 | public Weapon GetWeapon()
63 | {
64 | var weaponManager = new IntPtr(BitConverter.ToInt64(readData, 0x10D8));
65 | return new Weapon(Memory.Read(weaponManager + 0x20));
66 | }
67 |
68 | public Vehicle GetVehicle()
69 | {
70 | return new Vehicle(new IntPtr(BitConverter.ToInt64(readData, 0xD30)));
71 | }
72 |
73 | public bool CanBeRagdolled
74 | {
75 | get
76 | {
77 | var btRead = readData[0x10B8];
78 | return (btRead & 0x20) == 0x20;
79 | }
80 | set
81 | {
82 | var btRead = readData[0x10B8];
83 | if (value)
84 | {
85 | if ((btRead & 0x20) != 0x20) btRead |= 0x20;
86 | }
87 | else
88 | {
89 | if ((btRead & 0x20) == 0x20) btRead ^= 0x20;
90 | }
91 |
92 | Memory.Write(address + 0x10B8, btRead);
93 | }
94 | }
95 |
96 | public bool HasSeatBelt
97 | {
98 | get
99 | {
100 | var btRead = readData[0x140C];
101 | return (btRead & 0x1) != 0x1;
102 | }
103 | set
104 | {
105 | var btRead = readData[0x140C];
106 | if (!value)
107 | {
108 | if ((btRead & 0x1) != 0x1) btRead |= 0x1;
109 | }
110 | else
111 | {
112 | if ((btRead & 0x1) == 0x1) btRead ^= 0x1;
113 | }
114 |
115 | Memory.Write(address + 0x140C, btRead);
116 | }
117 | }
118 |
119 | public bool IsInVehicle
120 | {
121 | get
122 | {
123 | var btRead = readData[0x148B];
124 | return ((btRead >> 4) & 1) == 0;
125 | }
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/PlayerInfo.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.Extensions;
2 | using BlyadTheftAuto.MemorySystem;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BlyadTheftAuto.GrandTheftAuto.Models
10 | {
11 | internal class PlayerInfo
12 | {
13 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
14 | private byte[] _readData;
15 | private readonly IntPtr _address;
16 |
17 | public PlayerInfo(IntPtr address)
18 | {
19 | this._address = address;
20 | Update();
21 | }
22 | public IntPtr Address => _address;
23 |
24 | public void Update()
25 | {
26 | _readData = Memory.ReadByteArray(_address, 0x0CF4);
27 | }
28 |
29 | public string GetName()
30 | {
31 | return Memory.ReadString(new IntPtr(BitConverter.ToInt64(_readData, 0xA4)));
32 | }
33 |
34 | public int WantedLevel
35 | {
36 | get
37 | {
38 | return BitConverter.ToInt32(_readData, 0x888);
39 | }
40 | set
41 | {
42 | Memory.Write(_address + 0x888, value);
43 | Memory.Write(_address + 0x88C, value);
44 | }
45 | }
46 |
47 | public int FrameFlags
48 | {
49 | get
50 | {
51 | return BitConverter.ToInt32(_readData, 0x218);
52 | }
53 | set
54 | {
55 | Memory.Write(_address + 0x218, value);
56 | }
57 | }
58 |
59 | public float SwimSpeed
60 | {
61 | get
62 | {
63 | return BitConverter.ToSingle(_readData, 0x0170);
64 | }
65 | set
66 | {
67 | Memory.Write(_address + 0x0170, value);
68 | }
69 | }
70 |
71 | public float RunSpeed
72 | {
73 | get
74 | {
75 | return BitConverter.ToSingle(_readData, 0x0CF0);
76 | }
77 | set
78 | {
79 | Memory.Write(_address + 0x0CF0, value);
80 | }
81 | }
82 |
83 |
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Vehicle.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.GrandTheftAuto.Models.Backup;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto.GrandTheftAuto.Models
9 | {
10 | internal class Vehicle : Entity
11 | {
12 | public Vehicle(IntPtr address) : base(address)
13 | {
14 | }
15 |
16 | public void Restore(BackupVehicle backup)
17 | {
18 | Gravity = backup.Gravity;
19 | AlarmLength = backup.AlarmLength;
20 | }
21 |
22 | public VehicleHandling GetHandling()
23 | {
24 | return new VehicleHandling(new IntPtr(BitConverter.ToInt64(readData, 0x938)));
25 | }
26 |
27 | public VehicleColors GetColors()
28 | {
29 | var options = new IntPtr(BitConverter.ToInt64(readData, 0x48));
30 | return new VehicleColors(Memory.Read(options + 0x20));
31 | }
32 |
33 | public float Health
34 | {
35 | get
36 | {
37 | return BitConverter.ToSingle(readData, 0x8E8);
38 | }
39 | set
40 | {
41 | Memory.Write(address + 0x8E8, value);
42 | }
43 | }
44 |
45 | public bool BulletproofTires
46 | {
47 | get
48 | {
49 | var btRead = readData[0x923];
50 | return (btRead & 0x20) == 0x20;
51 | }
52 | set
53 | {
54 | var btRead = readData[0x923];
55 | if (value)
56 | {
57 | if ((btRead & 0x20) != 0x20) btRead |= 0x20;
58 | }
59 | else
60 | {
61 | if ((btRead & 0x20) == 0x20) btRead ^= 0x20;
62 | }
63 |
64 | Memory.Write(address + 0x923, btRead);
65 | }
66 | }
67 |
68 | public int AlarmLength
69 | {
70 | get
71 | {
72 | return BitConverter.ToInt32(readData, 0x9E4);
73 | }
74 | set
75 | {
76 | Memory.Write(address + 0x9E4, value);
77 | }
78 | }
79 |
80 | public float Gravity
81 | {
82 | get
83 | {
84 | return BitConverter.ToInt32(readData, 0xBCC);
85 | }
86 | set
87 | {
88 | Memory.Write(address + 0xBCC, value);
89 | }
90 | }
91 |
92 | public float BoostAmount
93 | {
94 | get
95 | {
96 | return BitConverter.ToSingle(readData, 0x320);
97 | }
98 | set
99 | {
100 | Memory.Write(address + 0x320, value);
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/VehicleColors.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto.GrandTheftAuto.Models
9 | {
10 | internal class VehicleColors
11 | {
12 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
13 | private byte[] _readData;
14 | private IntPtr _address;
15 |
16 | public VehicleColors(IntPtr address)
17 | {
18 | _address = address;
19 | Update();
20 | }
21 |
22 | public IntPtr Address => _address;
23 |
24 | public void Update()
25 | {
26 | _readData = Memory.ReadByteArray(_address, 0xAC);
27 | }
28 |
29 |
30 | public byte PrimaryBlue
31 | {
32 | get
33 | {
34 | return _readData[0xA4];
35 | }
36 | set
37 | {
38 | Memory.Write(_address + 0xA4, value);
39 | }
40 | }
41 |
42 | public byte PrimaryGreen
43 | {
44 | get
45 | {
46 | return _readData[0xA5];
47 | }
48 | set
49 | {
50 | Memory.Write(_address + 0xA5, value);
51 | }
52 | }
53 |
54 | public byte PrimaryRed
55 | {
56 | get
57 | {
58 | return _readData[0xA6];
59 | }
60 | set
61 | {
62 | Memory.Write(_address + 0xA6, value);
63 | }
64 | }
65 |
66 | public byte PrimaryAlpha
67 | {
68 | get
69 | {
70 | return _readData[0xA7];
71 | }
72 | set
73 | {
74 | Memory.Write(_address + 0xA7, value);
75 | }
76 | }
77 |
78 | public byte SecondaryBlue
79 | {
80 | get
81 | {
82 | return _readData[0xA8];
83 | }
84 | set
85 | {
86 | Memory.Write(_address + 0xA8, value);
87 | }
88 | }
89 |
90 | public byte SecondaryGreen
91 | {
92 | get
93 | {
94 | return _readData[0xA9];
95 | }
96 | set
97 | {
98 | Memory.Write(_address + 0xA9, value);
99 | }
100 | }
101 |
102 | public byte SecondaryRed
103 | {
104 | get
105 | {
106 | return _readData[0xAA];
107 | }
108 | set
109 | {
110 | Memory.Write(_address + 0xAA, value);
111 | }
112 | }
113 |
114 | public byte SecondaryAlpha
115 | {
116 | get
117 | {
118 | return _readData[0xAB];
119 | }
120 | set
121 | {
122 | Memory.Write(_address + 0xAB, value);
123 | }
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/VehicleHandling.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.GrandTheftAuto.Models.Backup;
2 | using BlyadTheftAuto.MemorySystem;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BlyadTheftAuto.GrandTheftAuto.Models
10 | {
11 | internal class VehicleHandling
12 | {
13 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
14 | private byte[] _readData;
15 | private IntPtr _address;
16 |
17 | public VehicleHandling(IntPtr address)
18 | {
19 | _address = address;
20 | Update();
21 | }
22 |
23 | public IntPtr Address => _address;
24 |
25 | public void Update()
26 | {
27 | _readData = Memory.ReadByteArray(_address, 0x100);
28 | }
29 |
30 | public void Restore(BackupVehicleHandling backup)
31 | {
32 | Acceleration = backup.Acceleration;
33 | BrakeForce = backup.BrakeForce;
34 | TractionCurveMin = backup.TractionCurveMin;
35 | CollisionDamage = backup.CollisionDamage;
36 | WeaponDamage = backup.WeaponDamage;
37 | EngineDamage = backup.EngineDamage;
38 | DeformationDamage = backup.DeformationDamage;
39 | UpShift = backup.UpShift;
40 | HandBrakeForce = backup.HandBrakeForce;
41 | SuspensionForce = backup.SuspensionForce;
42 | }
43 |
44 | public float Acceleration
45 | {
46 | get
47 | {
48 | return BitConverter.ToSingle(_readData, 0x4C);
49 | }
50 | set
51 | {
52 | Memory.Write(_address + 0x4C, value);
53 | }
54 | }
55 |
56 | public float BrakeForce
57 | {
58 | get
59 | {
60 | return BitConverter.ToSingle(_readData, 0x6C);
61 | }
62 | set
63 | {
64 | Memory.Write(_address + 0x6C, value);
65 | }
66 | }
67 |
68 | public float HandBrakeForce
69 | {
70 | get
71 | {
72 | return BitConverter.ToSingle(_readData, 0x7C);
73 | }
74 | set
75 | {
76 | Memory.Write(_address + 0x7C, value);
77 | }
78 | }
79 |
80 | public float TractionCurveMin
81 | {
82 | get
83 | {
84 | return BitConverter.ToSingle(_readData, 0x90);
85 | }
86 | set
87 | {
88 | Memory.Write(_address + 0x90, value);
89 | }
90 | }
91 |
92 | public float CollisionDamage
93 | {
94 | get
95 | {
96 | return BitConverter.ToSingle(_readData, 0xF0);
97 | }
98 | set
99 | {
100 | Memory.Write(_address + 0xF0, value);
101 | }
102 | }
103 |
104 | public float WeaponDamage
105 | {
106 | get
107 | {
108 | return BitConverter.ToSingle(_readData, 0xF4);
109 | }
110 | set
111 | {
112 | Memory.Write(_address + 0xF4, value);
113 | }
114 | }
115 |
116 | public float DeformationDamage
117 | {
118 | get
119 | {
120 | return BitConverter.ToSingle(_readData, 0xF8);
121 | }
122 | set
123 | {
124 | Memory.Write(_address + 0xF8, value);
125 | }
126 | }
127 |
128 | public float EngineDamage
129 | {
130 | get
131 | {
132 | return BitConverter.ToSingle(_readData, 0xFC);
133 | }
134 | set
135 | {
136 | Memory.Write(_address + 0xFC, value);
137 | }
138 | }
139 |
140 | public float UpShift
141 | {
142 | get
143 | {
144 | return BitConverter.ToSingle(_readData, 0x58);
145 | }
146 | set
147 | {
148 | Memory.Write(_address + 0x58, value);
149 | }
150 | }
151 |
152 | public float SuspensionForce
153 | {
154 | get
155 | {
156 | return BitConverter.ToSingle(_readData, 0xBC);
157 | }
158 | set
159 | {
160 | Memory.Write(_address + 0xBC, value);
161 | }
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/Weapon.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.GrandTheftAuto.Models.Backup;
2 | using BlyadTheftAuto.MemorySystem;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace BlyadTheftAuto.GrandTheftAuto.Models
10 | {
11 | internal class PrimaryAmmoCount
12 | {
13 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
14 | private byte[] _readData;
15 | private IntPtr _address;
16 |
17 | public PrimaryAmmoCount(IntPtr address)
18 | {
19 | _address = address;
20 | Update();
21 |
22 | }
23 | public void Update()
24 | {
25 | _readData = Memory.ReadByteArray(_address, 0x1C);
26 | }
27 |
28 | public int AmmoCount
29 | {
30 | get => BitConverter.ToInt32(_readData, 0x18);
31 | set => Memory.Write(_address + 0x18, value);
32 | }
33 | }
34 |
35 | internal class Weapon
36 | {
37 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
38 | private byte[] _readData;
39 | private IntPtr _address;
40 |
41 | public Weapon(IntPtr address)
42 | {
43 | this._address = address;
44 | Update();
45 | }
46 |
47 | public void Update()
48 | {
49 | _readData = Memory.ReadByteArray(_address, 0x2DC);
50 | }
51 |
52 | public void Restore(BackupWeapon backup)
53 | {
54 | Damage = backup.Damage;
55 | BulletBatch = backup.BulletBatch;
56 | ReloadTime = backup.ReloadTime;
57 | Spread = backup.Spread;
58 | Range = backup.Range;
59 | Recoil = backup.Recoil;
60 | BatchSpread = backup.BatchSpread;
61 | SpinUp = backup.SpinUp;
62 | Spin = backup.Spin;
63 | MuzzleVelocity = backup.MuzzleVelocity;
64 | }
65 |
66 | public int NameHash
67 | {
68 | get
69 | {
70 | return BitConverter.ToInt32(_readData, 0x10);
71 | }
72 | }
73 |
74 | public PrimaryAmmoCount PrimaryAmmoCount
75 | {
76 | get
77 | {
78 | var ammoInfo = new IntPtr(BitConverter.ToInt64(_readData, 0x60));
79 | var ammoCount = Memory.Read(ammoInfo + 0x8);
80 | return new PrimaryAmmoCount(Memory.Read(ammoCount));
81 | }
82 | }
83 |
84 | public float Damage
85 | {
86 | get
87 | {
88 | return BitConverter.ToSingle(_readData, 0xB0);
89 | }
90 | set
91 | {
92 | Memory.Write(_address + 0xB0, value);
93 | }
94 | }
95 |
96 | public int BulletBatch
97 | {
98 | get
99 | {
100 | return BitConverter.ToInt32(_readData, 0x118);
101 | }
102 | set
103 | {
104 | Memory.Write(_address + 0x118, value);
105 | }
106 | }
107 |
108 | public float ReloadTime
109 | {
110 | get
111 | {
112 | return BitConverter.ToSingle(_readData, 0x12C);
113 | }
114 | set
115 | {
116 | Memory.Write(_address + 0x12C, value);
117 | }
118 | }
119 |
120 | public float Spread
121 | {
122 | get
123 | {
124 | return BitConverter.ToSingle(_readData, 0x70);
125 | }
126 | set
127 | {
128 | Memory.Write(_address + 0x70, value);
129 | }
130 | }
131 |
132 | public float BatchSpread
133 | {
134 | get
135 | {
136 | return BitConverter.ToSingle(_readData, 0x11C);
137 | }
138 | set
139 | {
140 | Memory.Write(_address + 0x11C, value);
141 | }
142 | }
143 |
144 | public float Range
145 | {
146 | get
147 | {
148 | return BitConverter.ToSingle(_readData, 0x28C);
149 | }
150 | set
151 | {
152 | Memory.Write(_address + 0x28C, value);
153 | }
154 | }
155 |
156 | public float Recoil
157 | {
158 | get
159 | {
160 | return BitConverter.ToSingle(_readData, 0x2D8);
161 | }
162 | set
163 | {
164 | Memory.Write(_address + 0x2D8, value);
165 | }
166 | }
167 |
168 | public float SpinUp
169 | {
170 | get
171 | {
172 | return BitConverter.ToSingle(_readData, 0x13C);
173 | }
174 | set
175 | {
176 | Memory.Write(_address + 0x13C, value);
177 | }
178 | }
179 |
180 | public float Spin
181 | {
182 | get
183 | {
184 | return BitConverter.ToSingle(_readData, 0x140);
185 | }
186 | set
187 | {
188 | Memory.Write(_address + 0x140, value);
189 | }
190 | }
191 |
192 | public float MuzzleVelocity
193 | {
194 | get
195 | {
196 | return BitConverter.ToSingle(_readData, 0x114);
197 | }
198 | set
199 | {
200 | Memory.Write(_address + 0x114, value);
201 | }
202 | }
203 | }
204 | }
205 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/GrandTheftAuto/Models/World.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace BlyadTheftAuto.GrandTheftAuto.Models
9 | {
10 | internal class World
11 | {
12 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
13 | private IntPtr _address;
14 |
15 | public World(IntPtr address)
16 | {
17 | this._address = Memory.Read(address);
18 | }
19 |
20 | public IntPtr Address => _address;
21 |
22 | public Ped GetLocalPlayer()
23 | {
24 | return new Ped(Memory.Read(_address + 0x8));
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Enums/ScanMethod.cs:
--------------------------------------------------------------------------------
1 | namespace BlyadTheftAuto.MemorySystem.Enums
2 | {
3 | public enum ScanMethod
4 | {
5 | None,
6 | Add,
7 | Subtract,
8 | Read,
9 | ReadAndSubtract
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Enums/AllocationType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.MemorySystem.Native.Enums
4 | {
5 | [Flags]
6 | internal enum AllocationType
7 | {
8 | Commit = 0x1000,
9 | Reserve = 0x2000,
10 | Decommit = 0x4000,
11 | Release = 0x8000,
12 | Reset = 0x80000,
13 | Physical = 0x400000,
14 | TopDown = 0x100000,
15 | WriteWatch = 0x200000,
16 | LargePages = 0x20000000
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Enums/CreationFlags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.MemorySystem.Native.Enums
4 | {
5 | [Flags]
6 | internal enum CreationFlags : uint
7 | {
8 | Immediately = 0,
9 | Suspended = 0x4,
10 | StackSizeParamIsAReservation = 0x10000
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Enums/FreeType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.MemorySystem.Native.Enums
4 | {
5 | [Flags]
6 | internal enum FreeType
7 | {
8 | Decommit = 0x4000,
9 | Release = 0x8000
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Enums/MemoryProtection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.MemorySystem.Native.Enums
4 | {
5 | [Flags]
6 | internal enum MemoryProtection
7 | {
8 | Execute = 0x10,
9 | ExecuteRead = 0x20,
10 | ExecuteReadWrite = 0x40,
11 | ExecuteWriteCopy = 0x80,
12 | NoAccess = 0x01,
13 | ReadOnly = 0x02,
14 | ReadWrite = 0x04,
15 | WriteCopy = 0x08,
16 | GuardModifierflag = 0x100,
17 | NoCacheModifierflag = 0x200,
18 | WriteCombineModifierflag = 0x400
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Enums/ProcessAccessFlags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace BlyadTheftAuto.MemorySystem.Native.Enums
4 | {
5 | [Flags]
6 | internal enum ProcessAccessFlags : uint
7 | {
8 | All = 0x001F0FFF,
9 | Terminate = 0x00000001,
10 | CreateThread = 0x00000002,
11 | VirtualMemoryOperation = 0x00000008,
12 | VirtualMemoryRead = 0x00000010,
13 | VirtualMemoryWrite = 0x00000020,
14 | DuplicateHandle = 0x00000040,
15 | CreateProcess = 0x000000080,
16 | SetQuota = 0x00000100,
17 | SetInformation = 0x00000200,
18 | QueryInformation = 0x00000400,
19 | QueryLimitedInformation = 0x00001000,
20 | Synchronize = 0x00100000
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Library/Kernel32.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem.Native.Enums;
2 | using BlyadTheftAuto.MemorySystem.Native.Structs;
3 | using System;
4 | using System.Runtime.InteropServices;
5 | using System.Security;
6 |
7 | namespace BlyadTheftAuto.MemorySystem.Native.Library
8 | {
9 | [SuppressUnmanagedCodeSecurity()]
10 | internal static class Kernel32
11 | {
12 | [DllImport("kernel32.dll", SetLastError = false)]
13 | public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In][Out] byte[] lpBuffer, int dwSize, IntPtr lpNumberOfBytesRead);
14 |
15 | [DllImport("kernel32.dll", SetLastError = false)]
16 | [return: MarshalAs(UnmanagedType.Bool)]
17 | public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int dwSize, IntPtr lpNumberOfBytesWritten);
18 |
19 | [DllImport("kernel32.dll", SetLastError = false, ExactSpelling = true)]
20 | public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress,
21 | int dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
22 |
23 | [DllImport("kernel32.dll", SetLastError = false, ExactSpelling = true)]
24 | public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress,
25 | int dwSize, FreeType dwFreeType);
26 |
27 | [DllImport("kernel32.dll", SetLastError = false)]
28 | public static extern IntPtr VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out MemoryBasicInformation lpBuffer, uint dwLength);
29 |
30 | [DllImport("kernel32.dll", SetLastError = false)]
31 | public static extern IntPtr CreateRemoteThread(IntPtr hProcess,
32 | IntPtr lpThreadAttributes, uint dwStackSize, IntPtr
33 | lpStartAddress, IntPtr lpParameter, CreationFlags dwCreationFlags, IntPtr lpThreadId);
34 |
35 | [DllImport("kernel32.dll", SetLastError = false)]
36 | public static extern int WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/Native/Structs/MemoryBasicInformation.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem.Native.Enums;
2 | using System;
3 |
4 | namespace BlyadTheftAuto.MemorySystem.Native.Structs
5 | {
6 | internal struct MemoryBasicInformation
7 | {
8 | public IntPtr BaseAddress;
9 | public IntPtr AllocationBase;
10 | public MemoryProtection AllocationProtect;
11 | public IntPtr RegionSize;
12 | public UIntPtr State;
13 | public MemoryProtection Protect;
14 | public UIntPtr Type;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/PatternScan.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem.Enums;
2 | using System;
3 | using System.Diagnostics;
4 | using System.Globalization;
5 |
6 | namespace BlyadTheftAuto.MemorySystem
7 | {
8 | internal class PatternScan
9 | {
10 | private IntPtr baseAddress;
11 | private int size;
12 |
13 | private byte[] dump;
14 |
15 | private ProcessMemory memory;
16 |
17 | private ProcessModule module;
18 |
19 | public ProcessModule Module { get { return module; } }
20 | public IntPtr BaseAddress { get { return baseAddress; } }
21 | public int MemorySize { get { return size; } }
22 |
23 | public PatternScan(Process process, string moduleName)
24 | {
25 | process.Refresh();
26 | memory = new ProcessMemory(process);
27 |
28 | module = memory.ModuleFromName(moduleName);
29 |
30 | baseAddress = module.BaseAddress;
31 | size = module.ModuleMemorySize;
32 |
33 | dump = memory.ReadByteArray(baseAddress, size);
34 | }
35 |
36 | public PatternScan(ProcessMemory processMemory, string moduleName)
37 | {
38 | memory = processMemory;
39 |
40 | module = memory.ModuleFromName(moduleName);
41 |
42 | baseAddress = module.BaseAddress;
43 | size = module.ModuleMemorySize;
44 |
45 | dump = memory.ReadByteArray(baseAddress, size);
46 | }
47 |
48 | public PatternScan(Process process, ProcessModule module)
49 | {
50 | memory = new ProcessMemory(process);
51 |
52 | baseAddress = module.BaseAddress;
53 | size = module.ModuleMemorySize;
54 |
55 | dump = memory.ReadByteArray(baseAddress, size);
56 | }
57 |
58 | public IntPtr Find(string mask, int patternOffset, int addressOffset, ScanMethod method)
59 | {
60 | return Find(MaskToPattern(mask), patternOffset, addressOffset, method);
61 | }
62 |
63 | public IntPtr Find(byte[] pattern, int patternOffset, int addressOffset, ScanMethod method)
64 | {
65 | int length = pattern.Length;
66 | int i = 0;
67 | int k = 0;
68 |
69 | int loopDist = dump.Length - length;
70 |
71 | while (i < loopDist)
72 | {
73 | if (pattern[k] == 0x00 || dump[i] == pattern[k])
74 | {
75 | k++;
76 | if (k == length)
77 | break;
78 | }
79 | else
80 | {
81 | i -= k;
82 | k = 0;
83 | }
84 | i++;
85 | }
86 |
87 | int address = i - k + 1;
88 |
89 | if (address < 1)
90 | return IntPtr.Zero;
91 |
92 | switch (method)
93 | {
94 | case ScanMethod.None:
95 | return (IntPtr)(address + patternOffset + addressOffset);
96 | case ScanMethod.Add:
97 | return baseAddress + address + patternOffset + addressOffset;
98 | case ScanMethod.Subtract:
99 | return baseAddress - address + patternOffset + addressOffset;
100 | case ScanMethod.Read:
101 | return memory.Read(baseAddress + address + patternOffset) + addressOffset;
102 | case ScanMethod.ReadAndSubtract:
103 | return (IntPtr)((memory.Read(baseAddress + address + patternOffset) + addressOffset).ToInt64() - baseAddress.ToInt64());
104 | }
105 |
106 | return (IntPtr)address;
107 | }
108 |
109 | private byte[] MaskToPattern(string mask)
110 | {
111 | string[] numbers = mask.StartsWith(@"\x") ? mask.Split('\\', 'x') : mask.Split(' ');
112 |
113 | byte[] pattern = new byte[numbers.Length];
114 |
115 | for (int i = 0; i < pattern.Length; i++)
116 | {
117 | if (numbers[i].StartsWith("?"))
118 | {
119 | pattern[i] = 0x00;
120 | }
121 | else
122 | {
123 | pattern[i] = byte.Parse(numbers[i], NumberStyles.HexNumber);
124 | }
125 | }
126 |
127 | return pattern;
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/ProcessMemory.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem.Native.Library;
2 | using System;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 |
8 | namespace BlyadTheftAuto.MemorySystem
9 | {
10 | internal class ProcessMemory
11 | {
12 | #region Fields
13 | private Process process;
14 |
15 | private int pid;
16 | #endregion
17 |
18 | #region Properties
19 | public Process Process
20 | {
21 | get { return process; }
22 | }
23 |
24 | public int ProcessId
25 | {
26 | get { return pid; }
27 | }
28 |
29 | public bool IsProcessRunning
30 | {
31 | get { return !process.HasExited; }
32 | }
33 |
34 | public IntPtr MainWindowHandle
35 | {
36 | get { return process.MainWindowHandle; }
37 | }
38 |
39 | public ProcessModule MainModule
40 | {
41 | get { return process.MainModule; }
42 | }
43 |
44 | public ProcessModuleCollection ProcessModules
45 | {
46 | get { return process.Modules; }
47 | }
48 | #endregion
49 |
50 | public ProcessMemory(string name)
51 | {
52 | this.process = ProcessByName(name);
53 | this.pid = process.Id;
54 | }
55 |
56 | public ProcessMemory(Process process)
57 | {
58 | this.process = process;
59 | this.pid = process.Id;
60 | }
61 |
62 | public ProcessModule this[string name]
63 | {
64 | get
65 | {
66 | return Process.Modules.Cast().FirstOrDefault(item => item.ModuleName == name);
67 | }
68 | }
69 |
70 | #region Read/Write Memory
71 | public byte[] ReadByteArray(IntPtr address, int length)
72 | {
73 | byte[] buffer = new byte[length];
74 |
75 | Kernel32.ReadProcessMemory(Process.Handle, address, buffer, length, IntPtr.Zero);
76 |
77 | return buffer;
78 | }
79 |
80 | public void WriteByteArray(IntPtr address, byte[] data)
81 | {
82 | Kernel32.WriteProcessMemory(Process.Handle, address, data, data.Length, IntPtr.Zero);
83 | }
84 |
85 | public T Read(IntPtr address) where T : struct
86 | {
87 | return BytesTo(ReadByteArray(address, TypeCache.Size));
88 | }
89 |
90 | public unsafe T[] ReadArray(IntPtr address, int length) where T : new()
91 | {
92 | int size = TypeCache.Size * length;
93 | byte[] data = ReadByteArray(address, size);
94 | T[] array = new T[length];
95 |
96 | fixed (byte* b = data)
97 | {
98 | for (int i = 0; i < length; i++)
99 | {
100 | array[i] = Marshal.PtrToStructure((IntPtr)(b + i * TypeCache.Size));
101 | }
102 | }
103 | return array;
104 | }
105 |
106 | public void Write(IntPtr address, T data) where T : struct
107 | {
108 | WriteByteArray(address, ConvertToBytes(data));
109 | }
110 |
111 | public unsafe void WriteArray(IntPtr address, T[] array)
112 | {
113 | byte[] buffer = new byte[TypeCache.Size * array.Length];
114 |
115 | fixed (byte* b = buffer)
116 | for (int i = 0; i < array.Length; i++)
117 | Marshal.StructureToPtr(array[i], (IntPtr)(b + i * TypeCache.Size), true);
118 |
119 | WriteByteArray(address, buffer);
120 | }
121 |
122 | public T ReadPointer(IntPtr baseAddress, params int[] offsets) where T : struct
123 | {
124 | return Read(DereferencePointer(baseAddress, offsets));
125 | }
126 |
127 | internal void Write(object p, float value)
128 | {
129 | throw new NotImplementedException();
130 | }
131 |
132 | public void WritePointer(IntPtr baseAddress, T data, params int[] offsets) where T : struct
133 | {
134 | Write(DereferencePointer(baseAddress, offsets), data);
135 | }
136 |
137 | public string ReadString(IntPtr address, bool unicode = false)
138 | {
139 | var encoding = unicode ? Encoding.UTF8 : Encoding.Default;
140 | var numArray = ReadByteArray(address, 255);
141 | var str = encoding.GetString(numArray);
142 |
143 | if (str.Contains('\0'))
144 | str = str.Substring(0, str.IndexOf('\0'));
145 | return str;
146 | }
147 |
148 | public void WriteString(IntPtr address, string str, Encoding encoding = null)
149 | {
150 | if (encoding == null)
151 | encoding = Encoding.Default;
152 |
153 | WriteByteArray(address, encoding.GetBytes(str));
154 | }
155 |
156 | public IntPtr DereferencePointer(IntPtr baseAddress, params int[] offsets)
157 | {
158 | for (int i = 0; i < offsets.Length - 1; i++)
159 | baseAddress = Read(baseAddress + offsets[i]);
160 | return baseAddress + offsets[offsets.Length - 1];
161 | }
162 |
163 | public IntPtr GetVirtualFunction(IntPtr classPointer, int index)
164 | {
165 | var table = Read(classPointer);
166 | return Read(table + (index * TypeCache.Size));
167 | }
168 | #endregion
169 |
170 | #region Advanced
171 | public RemoteAllocation Allocate(int size)
172 | {
173 | return new RemoteAllocation(process, size);
174 | }
175 | public RemoteAllocation Allocate() where T : struct
176 | {
177 | return new RemoteAllocation(process, TypeCache.Size);
178 | }
179 | public RemoteAllocation Allocate(T data) where T : struct
180 | {
181 | return RemoteAllocation.CreateNew(this, data);
182 | }
183 |
184 | public bool Execute(IntPtr fn, IntPtr param = default(IntPtr))
185 | {
186 | RemoteFunction remoteFn = new RemoteFunction(process, fn);
187 | return remoteFn.Execute(param);
188 | }
189 | public bool Execute(IntPtr fn, T param) where T : struct
190 | {
191 | RemoteFunction remoteFn = new RemoteFunction(process, fn);
192 | return remoteFn.Execute(this, param);
193 | }
194 | #endregion
195 |
196 | #region Process Modules
197 | public bool ModuleExists(string name)
198 | {
199 | return Process.Modules.Cast().Any(module => module.ModuleName == name);
200 | }
201 |
202 | public ProcessModule ModuleFromName(string name)
203 | {
204 | return Process.Modules.Cast().FirstOrDefault(item => item.ModuleName == name);
205 | }
206 |
207 | public IntPtr ModuleBaseAddress(string name)
208 | {
209 | ProcessModule module = ModuleFromName(name);
210 | if (module == null)
211 | return IntPtr.Zero;
212 | return module.BaseAddress;
213 | }
214 |
215 | public int ModuleMemorySize(string name)
216 | {
217 | ProcessModule module = ModuleFromName(name);
218 | if (module == null)
219 | return 0;
220 | return module.ModuleMemorySize;
221 | }
222 | #endregion
223 |
224 | #region Static methods
225 | public static bool ProcessExists(string name)
226 | {
227 | return Process.GetProcessesByName(name).FirstOrDefault() == null ? false : true;
228 | }
229 |
230 | public static Process ProcessByName(string name)
231 | {
232 | return Process.GetProcessesByName(name).FirstOrDefault();
233 | }
234 |
235 | public static int SizeOf() where T : struct
236 | {
237 | return TypeCache.Size;
238 | }
239 |
240 | public static Type TypeOf() where T : struct
241 | {
242 | return TypeCache.Type;
243 | }
244 |
245 | public static unsafe byte[] ConvertToBytes(T obj) where T : struct
246 | {
247 | byte[] buffer = new byte[TypeCache.Size];
248 | fixed (byte* b = buffer)
249 | {
250 | Marshal.StructureToPtr(obj, (IntPtr)b, true);
251 | }
252 | return buffer;
253 | }
254 |
255 | public static unsafe T BytesTo(byte[] data) where T : struct
256 | {
257 | fixed (byte* b = data)
258 | {
259 | return Marshal.PtrToStructure((IntPtr)b);
260 | }
261 | }
262 |
263 | public static unsafe T BytesTo(byte[] data, int index) where T : struct
264 | {
265 | int size = Marshal.SizeOf(typeof(T));
266 | byte[] tmp = new byte[size];
267 | Array.Copy(data, index, tmp, 0, size);
268 | return BytesTo(tmp);
269 | }
270 | #endregion
271 | }
272 | }
273 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/RemoteAllocation.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem.Native.Enums;
2 | using BlyadTheftAuto.MemorySystem.Native.Library;
3 | using System;
4 | using System.Diagnostics;
5 |
6 | namespace BlyadTheftAuto.MemorySystem
7 | {
8 | internal class RemoteAllocation : IDisposable
9 | {
10 | private bool isAllocated = false;
11 |
12 | public Process Process { get; private set; }
13 | public IntPtr Address { get; private set; }
14 | public int Size { get; private set; }
15 |
16 | public RemoteAllocation(Process process)
17 | {
18 | Process = process;
19 | }
20 |
21 | public RemoteAllocation(Process process, int size)
22 | {
23 | Process = process;
24 |
25 | Size = size;
26 |
27 | Allocate(Size);
28 | }
29 |
30 | ~RemoteAllocation()
31 | {
32 | Dispose(false);
33 | }
34 |
35 | public bool Allocate(int size)
36 | {
37 | if (isAllocated)
38 | return false;
39 |
40 | Address = Kernel32.VirtualAllocEx(Process.Handle, IntPtr.Zero, Size, AllocationType.Commit | AllocationType.Reserve, MemoryProtection.ExecuteReadWrite);
41 |
42 | isAllocated = true;
43 | return true;
44 | }
45 |
46 | public bool Free()
47 | {
48 | if (!isAllocated)
49 | return false;
50 |
51 | bool result = Kernel32.VirtualFreeEx(Process.Handle, Address, 0, FreeType.Release);
52 |
53 | isAllocated = !result;
54 |
55 | return result;
56 | }
57 |
58 | public static RemoteAllocation CreateNew(ProcessMemory memory, T data) where T : struct
59 | {
60 | RemoteAllocation ralloc = new RemoteAllocation(memory.Process);
61 |
62 | if (!ralloc.Allocate(TypeCache.Size))
63 | return null;
64 |
65 | memory.Write(ralloc.Address, data);
66 |
67 | return ralloc;
68 | }
69 |
70 | #region IDisposable Support
71 | private bool disposedValue = false;
72 |
73 | protected virtual void Dispose(bool disposing)
74 | {
75 | if (!disposedValue)
76 | {
77 | if (disposing)
78 | {
79 | }
80 |
81 | Free();
82 |
83 | disposedValue = true;
84 | }
85 | }
86 |
87 | public void Dispose()
88 | {
89 | Dispose(true);
90 | GC.SuppressFinalize(this);
91 | }
92 | #endregion
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/RemoteFunction.cs:
--------------------------------------------------------------------------------
1 | using BlyadTheftAuto.MemorySystem.Native.Enums;
2 | using BlyadTheftAuto.MemorySystem.Native.Library;
3 | using System;
4 | using System.Diagnostics;
5 |
6 | namespace BlyadTheftAuto.MemorySystem
7 | {
8 | internal class RemoteFunction
9 | {
10 | private const uint INFINITE = 0xFFFFFFFF;
11 |
12 | public Process Process { get; private set; }
13 | public IntPtr Address { get; set; }
14 |
15 | public RemoteFunction(Process process)
16 | {
17 | Process = process;
18 | }
19 |
20 | public RemoteFunction(Process process, IntPtr address)
21 | {
22 | Process = process;
23 | Address = address;
24 | }
25 |
26 | private void InvokeStub(IntPtr fn)
27 | {
28 | IntPtr hResult = Kernel32.CreateRemoteThread(Process.Handle, IntPtr.Zero, 0, fn, IntPtr.Zero, CreationFlags.Immediately, IntPtr.Zero);
29 |
30 | if (hResult != IntPtr.Zero)
31 | Kernel32.WaitForSingleObject(hResult, INFINITE);
32 | }
33 |
34 | public bool Execute(IntPtr param = default(IntPtr))
35 | {
36 | bool ret = false;
37 |
38 | IntPtr hResult = Kernel32.CreateRemoteThread(Process.Handle, IntPtr.Zero, 0, Address, param, CreationFlags.Immediately, IntPtr.Zero);
39 |
40 | if (hResult != IntPtr.Zero)
41 | ret = Kernel32.WaitForSingleObject(hResult, INFINITE) == 0;
42 |
43 | return ret;
44 | }
45 |
46 | public bool Execute(ProcessMemory mem, T param) where T : struct
47 | {
48 | bool ret = false;
49 | using (RemoteAllocation ralloc = RemoteAllocation.CreateNew(mem, param))
50 | {
51 | ret = Execute(ralloc.Address);
52 | }
53 | return ret;
54 | }
55 |
56 | public static bool Execute(Process process, IntPtr address, IntPtr param = default(IntPtr))
57 | {
58 | RemoteFunction fn = new RemoteFunction(process, address);
59 | return fn.Execute(param);
60 | }
61 |
62 | public static bool Execute(ProcessMemory memory, IntPtr address, T param) where T : struct
63 | {
64 | RemoteFunction fn = new RemoteFunction(memory.Process, address);
65 | return fn.Execute(memory, param);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/SignatureManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BlyadTheftAuto.Extensions;
3 | using System.Diagnostics;
4 | using System.Text;
5 | using BlyadTheftAuto.ConsoleSystem;
6 |
7 | namespace BlyadTheftAuto.MemorySystem
8 | {
9 | internal static class SignatureManager
10 | {
11 | private static ProcessMemory Memory => BlyadTheftAuto.Memory;
12 |
13 | public static System.IntPtr GetWorld()
14 | {
15 | //return new IntPtr(0x24AECE0).Add(BlyadTheftAuto.Memory.MainModule.BaseAddress);
16 | var address = BlyadTheftAuto.Game.Find("48 8B 05 ? ? ? ? 48 8B 48 08 48 85 C9 74 52 8B 81", 0, 0, Enums.ScanMethod.Add);
17 | //Console.WriteOffset("", address);
18 | return address + Memory.Read(address + 0x3) + 0x7;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/MemorySystem/TypeCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace BlyadTheftAuto.MemorySystem
5 | {
6 | internal static class TypeCache
7 | {
8 | public static readonly int Size;
9 | public static readonly Type Type;
10 | public static readonly TypeCode TypeCode;
11 |
12 | static TypeCache()
13 | {
14 | Type = typeof(T);
15 |
16 | if (Type.IsEnum)
17 | Type = Type.GetEnumUnderlyingType();
18 |
19 | if (Type == typeof(IntPtr))
20 | {
21 | Size = IntPtr.Size;
22 | }
23 | else if (Type == typeof(bool))
24 | {
25 | Size = 1;
26 | }
27 | else
28 | {
29 | Size = Marshal.SizeOf();
30 | }
31 |
32 | TypeCode = Type.GetTypeCode(Type);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Allgemeine Informationen über eine Assembly werden über die folgenden
6 | // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
7 | // die einer Assembly zugeordnet sind.
8 | [assembly: AssemblyTitle("BlyadTheftAuto")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("BlyadTheftAuto")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
18 | // für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
19 | // COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
20 | [assembly: ComVisible(false)]
21 |
22 | // Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
23 | [assembly: Guid("34ff8d6f-6df3-4166-ae34-c0e6b6bd80cd")]
24 |
25 | // Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
26 | //
27 | // Hauptversion
28 | // Nebenversion
29 | // Buildnummer
30 | // Revision
31 | //
32 | // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
33 | // übernehmen, indem Sie "*" eingeben:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.4.0.0")]
36 | [assembly: AssemblyFileVersion("1.4.0.0")]
37 |
--------------------------------------------------------------------------------
/BlyadTheftAuto/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
59 |
60 |
61 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Requi
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------