-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
152 lines (133 loc) · 4.4 KB
/
MainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
* Author: FileEX
* Class: MainClass
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Trainer
{
[Flags]
public enum eMemAddress
{
// static address
Main = 0x0076F3B8,
Money = 0x00B7CE50,
WantedLevel = 0x00BAA420,
Gravity = 0x00863984,
GameSpeed = 0x00B7CB64,
// offsets
HealthOffset = 0x540,
ArmorOffset = 0x548,
//
Stamina = 0x00B793D8,
FatLevel = 0x00B793D4,
Muscle = 0x00B793DC,
Respect = 0x00B79480,
}
public partial class MainForm : Form
{
private Process pProc;
private int pointer;
// define const value
private const int MAX_MONEY = 99999999;
private const int MAX_HEALTH = 100;
private const int MAX_ARMOR = 100;
//private const int MAX_WANTEDLEVEL = 6;
private const int MAX_FAT = 3000;
public MainForm()
{
InitializeComponent();
}
private void MainFormLoad(object sender, EventArgs e)
{
if (Process.GetProcessesByName("gta_sa").Length == 0)
{
MessageBox.Show("GTA SA is not running", "Error");
Application.Exit();
}
pProc = Process.GetProcessesByName("gta_sa")[0];
pointer = (int)pProc.MainModule.BaseAddress + (int)eMemAddress.Main;
// grab info from process
int iCPedOffset = Convert.ToInt32(Mem.ReadMem(pProc, pointer, "int"));
string strMoney = Mem.ReadMem(pProc, (int)eMemAddress.Money + 0x04, "long");
moneyLbl.Text = "Money: " + strMoney + " $";
string strHealth = Mem.ReadMem(pProc, iCPedOffset + (int)eMemAddress.HealthOffset, "float");
healthLbl.Text = "Health: " + Math.Floor(Convert.ToDecimal(strHealth)).ToString() + " %";
string strArmor = Mem.ReadMem(pProc, iCPedOffset + (int)eMemAddress.ArmorOffset, "float");
armorLbl.Text = "Armor: " + strArmor + " %";
string strWanted = Mem.ReadMem(pProc, (int)eMemAddress.WantedLevel, "int");
wantedLbl.Text = "Wanted level: " + strWanted;
string strFat = Mem.ReadMem(pProc, (int)eMemAddress.FatLevel, "float");
fatLbl.Text = "Fat level: " + strFat;
}
private void OnClickMoneyChange(object sender, EventArgs e)
{
if (moneyBox.Text.Length > 0 && moneyBox.Text != " ")
{
long lMoneyValue = (long)Convert.ToInt64(moneyBox.Text);
if (lMoneyValue >= 0 && lMoneyValue <= MAX_MONEY)
{
Mem.WriteMemInt64(pProc, (int)eMemAddress.Money, lMoneyValue);
Mem.WriteMemInt64(pProc, (int)eMemAddress.Money + 0x04, lMoneyValue); // write add value for read later
moneyLbl.Text = "Money: " + lMoneyValue.ToString() + " $";
}
}
}
private void OnClickHealthChange(object sender, EventArgs e)
{
if (healthBox.Text.Length > 0 && healthBox.Text != " ")
{
float fHealth = (float)Convert.ToSingle(healthBox.Text);
if (fHealth >= 0 && fHealth <= MAX_HEALTH)
{
string strMatchOffset = Mem.ReadMem(pProc, pointer, "int");
int iOffset = (int)Convert.ToInt32(strMatchOffset);
Mem.WriteMemFloat(pProc, iOffset + (int)eMemAddress.HealthOffset, fHealth);
healthLbl.Text = "Health: " + fHealth.ToString() + " %";
}
}
}
private void ArmorButtonClick(object sender, EventArgs e)
{
if (armorBox.Text.Length > 0 && armorBox.Text != " ")
{
float fArmor = (float)Convert.ToSingle(armorBox.Text);
if (fArmor >= 0 && fArmor <= MAX_ARMOR)
{
string strMatchOffset = Mem.ReadMem(pProc, pointer, "int");
int iOffset = (int)Convert.ToInt32(strMatchOffset);
Mem.WriteMemFloat(pProc, iOffset + (int)eMemAddress.ArmorOffset, fArmor);
armorLbl.Text = "Armor: " + fArmor.ToString() + " %";
}
}
}
/* TODO
void WantedBtnClick(object sender, EventArgs e)
{
if (wantedBox.Text.Length > 0 && wantedBox.Text != " ")
{
uint iWanted = (uint)Convert.ToUInt16(wantedBox.Text);
if (iWanted >= 0 && iWanted <= MAX_WANTEDLEVEL)
{
wantedLbl.Text = "Wanted level: " + iWanted.ToString();
}
}
}*/
void FatBtnClick(object sender, EventArgs e)
{
if (fatBox.Text.Length > 0 && fatBox.Text != " ")
{
float fFat = (float)Convert.ToSingle(fatBox.Text);
if (fFat >= 0 && fFat <= MAX_FAT)
{
Mem.WriteMemFloat(pProc, (int)eMemAddress.FatLevel, fFat);
fatLbl.Text = "Fat level: " + fFat.ToString();
}
}
}
}
}