Using game structs in C#.
Structs are a huge part of both external and internal hacks. However, many people new to hacking are confused by what they are, and how to use them. In this tutorial, I will show how to read and use structs in noob-friendly C# (Go on @Horror ;p).
Structs (or structures) are groups of variables of a fixed size. This means a series of them may be read from memory easily. For my example, I will be using the Client_t struct for MW3 1.9.433 (thanks to @Jorndel for posting):
First off, we'll create a C# Class:
Next, we create a function to read the class from game memory. The numbers on the right of the struct come into play here, as each one represents the variables' offset from the start of the struct. This is what I came up with (using Jorndel's trainer class as a base):
Here, the base Address is 0xAD28F8, and the Size is 0x564. Since we know there are 18 clients max in MW3, we can create this function:
And you're done. Leave any questions down in the comments with a mention, and I'll answer as many as I can. Happy fragging!
Structs (or structures) are groups of variables of a fixed size. This means a series of them may be read from memory easily. For my example, I will be using the Client_t struct for MW3 1.9.433 (thanks to @Jorndel for posting):
Code:
typedef struct
{
int Valid; //0x0 (0xAD28F8)
char _0x0004[0x8]; //0x4
char Name[16]; //0xC (0xAD2904)
int Team; //0x1C (0xAD2914)
char _0x0020[0x4]; //0x20
int Rank; //0x24 (0xAD291C)
char _0x0028[0x10]; //0x28
int Perk; //0x38 (0xAD2930)
char _0x003C[0x8]; //0x3C
int Score; //0x44 (0xAD293C)
char _0x0048[0x458]; //0x48
int Attacking; //0x4A0 (0xAD2D98)
char _0x04A4[0x4]; //0x4A4
int Zooming; //0x4A8 (0xAD2DA0)
char _0x04AC[0xB8]; //0x4AC
}client_t; //[Addr: 0xAD28F8] [Size: 0x564]
Code:
class Client_t
{
public int valid;
public string name;
public int team;
public int rank;
public int perk;
public int score;
public int attacking;
public int zooming;
}
Code:
public static Client_t ReadClient(int Address)
{
int A = Address;
Client_t ret = new Client_t();
ret.valid = ReadInteger(A);
ret.name = ReadString(A + 0xC, 15);
ret.team = ReadInteger(A + 0x1C);
ret.rank = ReadInteger(A + 0x24);
ret.perk = ReadInteger(A + 0x38);
ret.score = ReadInteger(A + 0x44);
ret.attacking = ReadInteger(A + 0x4A0);
ret.zooming = ReadInteger(A + 0x4A8);
return ret;
}
Code:
Client_t[] clients = new Client_t[18];
int a = 0xAD28F8;
for (int i = 0; i < clients.Length; i++) {
clients[i] = ReadClient(a);
a += 0x564;
}



And make sure the Client_t[] clients = new Client_t[18]; section is inside a function.
Idk how to do that ...

![=]](/forum/images/emotions/=].gif)