Saturday, February 15, 2014

[C#/Tut] How to make a All Clients dataGrid Tool

Hey everyone!
I Have been inactive for some (a long) time...

Today I am here with a tutorial... I will be teaching you on how to make a All clients grid tool in C#!

I will be making it for MW2 PC (using my PC Library) anyways you can make it for ANY! Platform.. you just need to change the Platform read and write code with yours....

Per example if your on PS3 load ps3tmapi_net.dll and PS3Lib.dll and use the read and write codes...

or If you are on PC but you don´t use my library (you use default ReadProcessMemory and WriteProcessMemory) just replace them :)!

So just to start... :

PC Memory Editor Library (the one that I made and used on this tutorial) : https://www.mediafire.com/?5hb7mwnz770tim7

PC Memory Editor Library codes :

Write Functions :


WriteInt - Writes an Integer number to the desired offset
MemEditor.WriteInt(string ProcessName, long OffsetToWrite, long WhatToWrite);
Example : MemEditor.WriteInt("iw4mp", 0x01B2C8723, 999999999); //or ..723, Convert.ToInt64(textBox1.Text);

WriteFloat - Writes a Float value to the desired offset
MemEditor.WriteFloat(string ProcessName, long OffsetToWrite, string WhatToWrite);

WriteString - Writes text to the desired offset
MemEditor.WriteString(string ProcessName, long OffsetToWrite, string WhatToWrite);

WriteByte - Writes a byte to the desired offset
MemEditor.WriteByte(string ProcessName, long OffsetToWrite, byte[] Buffer);

WriteDouble - Writes a double to the desired offset
MemEditor.WriteDouble(string ProcessName, long OffsetToWrite, double WhatToWrite);

READ Functions :

How to use : (make sure you have using System.IO;)

READCODE;
textBoxX.Clear();
textBoxX.Text = Convert.ToString(File.ReadAllText(@"tmp.txt");
File.Delete(@"tmp.txt");

ReadInt - Reads an integer from desired offset to a file
MemEditor.ReadInt(string ProcessName, long OffsetToWrite, int LengthToRead); (usually set length as 9!)

ReadFloat - Reads a float from desired offset to a file
MemEditor.ReadFloat(string ProcessName, long OffsetToWrite, int LengthToRead); (usually set length as 4)

ReadString - Reads text from desired offset to a file
MemEditor.ReadString(string ProcessName, long OffsetToWrite, int LengthToRead); (usually set length as whatever the max chars for what you reading is! (example max chars for class name is 15)

ReadByte - Reads byte from desired offset to a file
MemEditor.ReadByte(string ProcessName, long OffsetToWrite, int LengthToRead);

ReadDouble - Reads a double from desired offset to a file
MemEditor.ReadDouble(string ProcessName, long OffsetToWrite, int LengthToRead);

PC Memory Editor Library Tut : http://mw2toptenworld.blogspot.pt/2014/01/release-tut-net-c-vb-pc-trainer-memory.html

PS3 Lib´s : http://www.mediafire.com/?idmw4wlv4eyea0k and ?????????? (ps3tmapi_net.dll)

PS3 Lib codes :

PS3TMAPI.ProcessSetMemory(0, PS3TMAPI.UnitType.PPU, ProcessID, 0, Address, bytes);

byte[] iMCSx = new byte[0x20];
               PS3TMAPI.ProcessGetMemory(0, PS3TMAPI.UnitType.PPU, ProcessID, 0, Address, ref iMCSx);

Default PC C# Codes : http://www.jarloo.com/reading-and-writing-to-memory/   (i recommend my lib ;) )

for any other platform just google around!!

So let´s Start!

First just declare the normal stuff (for PS3Lib , ps3tmapi_net or my lib.. if your doing in non-lib PC C# Code then just ignore this step...)

using PC_Memory_Editor___Trainer_Library;

under partial class

MW2TopTenWORLDMemEditor MemEditor = new MW2TopTenWORLDMemEditor();

Second drag a dataGridView from the toolbox , uncheck the togglables 'Allow Delete, Allow Adding and Allow Editing'

Add a button called 'Get Client´s' and in front of the button a label saying 'NOTE : Left click and then right click a client to acess its mod menu'

Add to the dataGrid the rows that you want (I added # , Clients Name and God Mode)

Go to 'Form1_Load' and add these :

dataGridView1.RowCount = 18; <- change 18 with how many players there are (max players) in the game you are modding...

and (if you added the column # )

for (int i = 0; i < 18; i++)
            {
                dataGridView1.Rows[i].Cells[0].Value = i;
            }

^^This code will add to the cell 0 (#) the number 0 then on the next one 1 ... till 17 (we are enumerating the clients)

k! Now go to the button 1 code and add this..


            GetNames();
            GetGOD();

Obviously if your doing more stuff like 'Unlimited Ammo' also add GetAmmo();
You don´t need to do a GetAmmo for each mod! only for the mods that you want to display as true or false in the grid! :)


Now you obviously want to create some voids for those functions so right after  (under) your

public Form1()
{
}

add :

public void GetNames()
{

}

and

public void GetGOD()
{

}

Okay, now we are going to code the GetNames() function....

so add this into it

long client0Name = 0x01AA1A2C; <- defining the client 0 name offset (if on PS3 change to uint)
         
            for (int i = 0; i < 18; i++)
            {
                long allClientsOffset = client0Name + (0x6CD8 * i); <- adding the interval (defined on the offsets list)
                MemEditor.ReadString("iw4mp", allClientsOffset, 15); <- PC Mem Editor Lib Read String func
                string Name = File.ReadAllText(@"tmp.txt"); <- Getting the readed memory
                File.Delete(@"tmp.txt");<- Deleting the readed memory
                dataGridView1.Rows[i].Cells[1].Value = Name; <- Writing the readed memory onto the grid
            }
            System.Threading.Thread.Sleep(100); <- Telling the program to pause for 100 milisseconds (to prevent crashing

Now if you make a change name button dont forget to add 'GetNames();' to the end of it so it will automatcly refresh names :)!

Okay so now for GetGOD();

long client0Health = 0x018DC174; <- defining client 0 health offset

            for (int i = 0; i < 18; i++)
            {
                long allClientsOffset = client0Health + (0x4E8 * i); <- adding the interval (defined on offsets list)
             
                MemEditor.ReadByte("iw4mp", allClientsOffset, 4); <- reading 4 bytes for each client (00 00 00 00)

                string Status = File.ReadAllText(@"tmp.txt"); <- getting the readed memory

                File.Delete(@"tmp.txt"); <- deleting the readed memory

                if (Status.Contains("64000000")) <- checking if health is 100 (0x64)
                {
                    dataGridView1.Rows[i].Cells[2].Value = "false";
                }
                else
                {
                    if (Status.Contains("00000000")) <- checking if health is null (player not in game)
                    {
                        dataGridView1.Rows[i].Cells[2].Value = "false";
                    }
                    else <- else.. (than 100 and null = god)
                  {
                        dataGridView1.Rows[i].Cells[2].Value = "true";
                   }
                }
            }
            System.Threading.Thread.Sleep(100); <- pausing the program for 100 milisseconds

    Okay! That is easy :)

Now

create a context menu strip and add whatever mods you want to it..

I addded : GOD Mode -> Give , Remove

onto the dataGridView properties select contextMenuStrip -> contextMenuStrip1

now just code the Give and Remove functions! :)

(click each of them to access their void)

 private void giveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int currentIndex = dataGridView1.CurrentRow.Index; <- obtaining current grid index

            long GodOffset = 0x018DC174; <- client 0 offset

            long SelectedClientOffset = GodOffset + (0x4E8 * currentIndex); <- calculating selected client offset

            MemEditor.WriteInt("iw4mp", SelectedClientOffset, -1); <-  writing god (on PS3 would be 0xFF , 0xFF)

            GetGOD(); <- Refreshing GOD Status
        }

        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int currentIndex = dataGridView1.CurrentRow.Index;  <- obtaining current grid index

            long GodOffset = 0x018DC174; <- client 0 offset

            long SelectedClientOffset = GodOffset + (0x4E8 * currentIndex); <- calculating selected client offset

            MemEditor.WriteInt("iw4mp", SelectedClientOffset, 100); <-  removing god (on PS3 would be 0x64 , 0x00 or 0x00 , 0x64)

            GetGOD(); <- Refreshing GOD Status
        }


Well thats it!

Full paste bin source : http://pastebin.com/H0DeVfWS

Video : http://www.youtube.com/watch?v=vJYCDc6-6EE

Embed :

No comments:

Post a Comment