Solved C# Unlimited Ammo Cheat

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Hey guys, i'm trying to make a trainer using C#, i've followed fleep's tutorial but i'm having a small problem with multiple pointers!
Since the tutorial is for another game, i'm doing one for assault cube and trying to understand those things, i could get Health HACK to work but my AmmoHack isn't.

I'm stuck !

C++:
bool UnlimitedAmmo = false;
int[] AmmoOffset = { 0x0, 0x14, 0x378 };
int AmmoToFill = 20;

if (UnlimitedAmmo)
{
int pointerAddress = HexToDec(globalPointer);
int bytesWritten;
byte[] valueToWrite = BitConverter.GetBytes(AmmoToFill); //convert AmmoFils to Bytes
string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, //Static address
                                                                    valueToWrite, //attribute value
                                                                    AmmoOffset, //Offsets 
                                                                    out bytesWritten);
}
 

Attachments

Last edited:

Crazywink

Hacker
Meme Tier VIP
Dank Tier Donator
Jul 18, 2012
626
4,613
17
There doesn't appear to be anything wrong with your code by just glancing over it quickly. Do you ever set UnlimitedAmmo to true? Also, what is globalPointer? Is it something along the lines of: myProcess[0].MainModule.BaseAddress.ToInt32() + 0x00000000; ?

Crazywink
 

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Ah, sorry, that globalPointer is the memory address which is the same for Ammo and Health, just changing offsets!
Yes, i have a button that activate Ammo and Health separately, Health is working fine, if i change the ammo offsets to health offsets it works as health, and i can't understand why ammo doesn't work, when i set manually the address using CE it works!

I'm following Fleeps tutorial "How to Make a TRAINER C#" and using external files that he provided, Memory.cs, which contains all this ProcessMemory thing you said!

Health HACK is working nicely, my problem is the Ammo HACK!
Can it be wrong pointers? Health doesn't have multiple pointers

Thanks for helping
 
Last edited:

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
Hello gnuzim,

Could you maybe post your full source so we're able to get a better look at your problem. :)


~ Magnificient
 

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Ok

Form1.cs
HTML:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Threading;

namespace CubeTrainer
{
    public partial class Form1 : Form
    {
        #region Global variables
        Memory myMemory = new Memory();
        Process[] myProcess;
        bool isGameAvailable = false;
        string globalPointer = "4DF73C";
        bool tuse = false;

        bool UnlimitedAmmo = false;
        int[] AmmoOffset = { 0x000, 0x014, 0x378 };
        int AmmoToFill = 20;
        bool t = false;

        bool UnlimitedHealth = false;
        int[] HealthOffset = { 0xF4 };
        int HealthToFill = 100;

        #endregion

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void UnlimAmmoBTN_Click(object sender, EventArgs e)
        {
            if (isGameAvailable)
            {
                if (UnlimitedAmmo)
                {
                    UnlimitedAmmo = false;
                    UnlimAmmoBTN.Text = "1.OFF";
                }
                else
                {
                    UnlimitedAmmo = true;
                    UnlimAmmoBTN.Text = "1.ON";
                }
            }
        }

        private void GameAvailabilityTMR_Tick(object sender, EventArgs e)
        {
            myProcess = Process.GetProcessesByName("ac_client") ;
            if (myProcess.Length != 0)
            {
                isGameAvailable = true;
                statusLBL.Text = "Status: Assault Cube Availiable";
            }
            else
            {
                isGameAvailable = false;
                statusLBL.Text = "Status: Assault Cube NOT Availiable";
            }
        }

        private void UpdateCheatsTMR_Tick(object sender, EventArgs e)
        {
            if (isGameAvailable)
            {
                myMemory.ReadProcess = myProcess[0];
                myMemory.Open();

                #region Unlimited Ammo
                if (UnlimitedAmmo)
                {
                    int pointerAddress = HexToDec(globalPointer);
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(AmmoToFill); //convert AmmoFils to Bytes
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, //Endereço estatico MUNIÇÃO
                                                                    valueToWrite, //valor a atribuir
                                                                    AmmoOffset, //Offsets 
                                                                    out bytesWritten);
                    if (!tuse)
                    {
                        tuse = true;
                        MessageBox.Show(bytesWritten.ToString("X"));
                    }

                }
                #endregion

                #region Unlimited Health
                if (UnlimitedHealth)
                {
                    int pointerAddress = HexToDec(globalPointer);
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(HealthToFill); //convert HealthFils to Bytes
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, //Endereço estatico HP
                                                                    valueToWrite, //Valor a atribuir
                                                                    HealthOffset, //offsets
                                                                    out bytesWritten);
                    if (!tuse)
                    {
                        tuse = true;
                        MessageBox.Show(bytesWritten.ToString("X"));
                    }
                }
                myMemory.CloseHandle();
                #endregion
            }
        }

        public static string HexToDec(int DEC)
        {
            return DEC.ToString("X");
        }
        public static int HexToDec(string Hex)
        {
            return int.Parse(Hex, NumberStyles.HexNumber);
        }

        private void UnlimHealthBTN_Click(object sender, EventArgs e)
        {
            if (isGameAvailable)
            {
                if (UnlimitedHealth)
                {
                    UnlimitedHealth = false;
                    UnlimHealthBTN.Text = "1.OFF";
                }
                else
                {
                    UnlimitedHealth = true;
                    UnlimHealthBTN.Text = "1.ON";
                }
            }
        }

    }
}
I can't add the Memory.cs cause its 2 big

// Download links that leads outside GuidedHacking are not allowed. Please attach it to your thread the next time. :)

Uploaded by Fleep to his tutorial

Thanks
 
Last edited by a moderator:

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Memory.cs
HTML:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; //USED TO CALL THE DLL IMPORTS
using System.Globalization;
using System.Diagnostics;
using System.Windows.Forms; //DELETE ME
namespace CubeTrainer
{
    //Class wasnt done by me
    //FULL CREDITS TO
    //https://forum.cheatengine.org/viewtopic.php?t=530207


    public class Memory
    {
        private Process m_ReadProcess = null;
        private IntPtr m_hProcess = IntPtr.Zero;

        public Process ReadProcess
        {
            get
            {
                return m_ReadProcess;
            }
            set
            {
                m_ReadProcess = value;
            }
        }

        public void Open()
        {
            ProcessAccessType access = ProcessAccessType.PROCESS_VM_READ
            | ProcessAccessType.PROCESS_VM_WRITE
            | ProcessAccessType.PROCESS_VM_OPERATION;
            m_hProcess = OpenProcess((uint)access, 1, (uint)m_ReadProcess.Id);
        }

        public void CloseHandle()
        {
            int iRetValue;
            iRetValue = CloseHandle(m_hProcess);
            if (iRetValue == 0)
            {
                throw new Exception("CloseHandle Failed");
            }
        }

        public byte[] Read(IntPtr MemoryAddress, uint bytesToRead, out int bytesRead)
        {
            byte[] buffer = new byte[bytesToRead];
            IntPtr ptrBytesRead;
            ReadProcessMemory(m_hProcess, MemoryAddress, buffer, bytesToRead, out ptrBytesRead);
            bytesRead = ptrBytesRead.ToInt32();
            return buffer;
        }

        public byte[] PointerRead(IntPtr MemoryAddress, uint bytesToRead, int[] Offset, out int bytesRead)
        {
            int iPointerCount = Offset.Length - 1;
            IntPtr ptrBytesRead;
            bytesRead = 0;
            byte[] buffer = new byte[4]; //DWORD to hold an Address
            int tempAddress = 0;

            if (iPointerCount == 0)
            {

                
                ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesRead);
                tempAddress = ToDec(Make(buffer)) + Offset[0]; //Final Address

                buffer = new byte[bytesToRead];
                ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, bytesToRead, out ptrBytesRead);

                bytesRead = ptrBytesRead.ToInt32();

                //MessageBox.Show(bytesRead.ToString());
                
                return buffer;


            }

            for (int i = 0; i <= iPointerCount; i++)
            {
                if (i == iPointerCount)
                {
                    ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesRead);
                    tempAddress = ToDec(Make(buffer)) + Offset[i]; //Final Address

                    buffer = new byte[bytesToRead];
                    ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, bytesToRead, out ptrBytesRead);

                    bytesRead = ptrBytesRead.ToInt32();
                    return buffer;
                }
                else if (i == 0)
                {
                    ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesRead);
                    tempAddress = ToDec(Make(buffer)) + Offset[1];
                }
                else
                {
                   ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesRead);
                    tempAddress = ToDec(Make(buffer)) + Offset[i];
                }
            }

            return buffer;
        }

        public void Write(IntPtr MemoryAddress, byte[] bytesToWrite, out int bytesWritten)
        {
            IntPtr ptrBytesWritten;
            WriteProcessMemory(m_hProcess, MemoryAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);
            bytesWritten = ptrBytesWritten.ToInt32();
        }

        public string PointerWrite(IntPtr MemoryAddress, byte[] bytesToWrite, int[] Offset, out int bytesWritten)
        {
            int iPointerCount = Offset.Length - 1;
            IntPtr ptrBytesWritten;
            bytesWritten = 0;
            byte[] buffer = new byte[4]; //DWORD to hold an Address
            int tempAddress = 0;

            if (iPointerCount == 0)
            {
                ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesWritten);
                tempAddress = ToDec(Make(buffer)) + Offset[0]; //Final Address
                WriteProcessMemory(m_hProcess, (IntPtr)tempAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);

                bytesWritten = ptrBytesWritten.ToInt32();
                return ToHex(tempAddress);
            }

            //only necessary for multiple OFFSETS
            for (int i = 0; i <= iPointerCount; i++)
            {
                if (i == iPointerCount)
                {
                    ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesWritten);
                    tempAddress = ToDec(Make(buffer)) + Offset[i]; //Final Address
                    WriteProcessMemory(m_hProcess, (IntPtr)tempAddress, bytesToWrite, (uint)bytesToWrite.Length, out ptrBytesWritten);

                    bytesWritten = ptrBytesWritten.ToInt32();
                    return ToHex(tempAddress);
                }
                else if (i == 0)
                {
                    ReadProcessMemory(m_hProcess, MemoryAddress, buffer, 4, out ptrBytesWritten);
                    tempAddress = ToDec(Make(buffer)) + Offset[i];
                }
                else
                {
                    ReadProcessMemory(m_hProcess, (IntPtr)tempAddress, buffer, 4, out ptrBytesWritten);
                    tempAddress = ToDec(Make(buffer)) + Offset[i];
                }
            }

            return ToHex(tempAddress);
        }

        public int PID()
        {
            return m_ReadProcess.Id;
        }

        public string BaseAddressH()
        {
            return ToHex(m_ReadProcess.MainModule.BaseAddress.ToInt32());
        }

        public int BaseAddressD()
        {
            return m_ReadProcess.MainModule.BaseAddress.ToInt32();
        }

        [Flags]
        public enum ProcessAccessType
        {
            PROCESS_TERMINATE = (0x0001),
            PROCESS_CREATE_THREAD = (0x0002),
            PROCESS_SET_SESSIONID = (0x0004),
            PROCESS_VM_OPERATION = (0x0008),
            PROCESS_VM_READ = (0x0010),
            PROCESS_VM_WRITE = (0x0020),
            PROCESS_DUP_HANDLE = (0x0040),
            PROCESS_CREATE_PROCESS = (0x0080),
            PROCESS_SET_QUOTA = (0x0100),
            PROCESS_SET_INFORMATION = (0x0200),
            PROCESS_QUERY_INFORMATION = (0x0400)
        }

        public static string Make(byte[] buffer)
        {
            string sTemp = "";

            for (int i = 0; i < buffer.Length; i++)
            {
                if (Convert.ToInt16(buffer[i]) < 10)
                {
                    sTemp = "0" + ToHex(buffer[i]) + sTemp;
                }
                else
                {
                    sTemp = ToHex(buffer[i]) + sTemp;
                }
            }
            return sTemp;
        }

        public static string ToHex(int Decimal)
        {
            return Decimal.ToString("X"); //Convert Decimal to Hexadecimal
        }

        public static int ToDec(string Hex)
        {
            return int.Parse(Hex, NumberStyles.HexNumber); //Convert Hexadecimal to Decimal
        }

        [DllImport("kernel32.dll")]
        public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);

        [DllImport("kernel32.dll")]
        public static extern Int32 CloseHandle(IntPtr hObject);

        [DllImport("kernel32.dll")]
        public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);

        [DllImport("kernel32.dll")]
        public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);

    }
}
I guess thats all!
Thanks
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
If you give me a minute. I'll go back to Assault Cube and try to look for something real quick. I'll post back in 5 - 10 minutes. :)
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
Could you try this for a minute and see if it works. Maybe your offsets are wrong because Health, Ammo etc is all within one structure.

Health:

Pointer: 4E4DBC
Offset: F4

Ammo:

Pointer: 4E4DBC
Offset: 140
 

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Still not working for me :(
HTML:
       #region Global variables
        Memory myMemory = new Memory();
        Process[] myProcess;
        bool isGameAvailable = false;
        string globalPointer = "4E4DBC";

        bool UnlimitedAmmo = false;
        int[] AmmoOffset = { 0x140 };
        int AmmoToFill = 20;

        bool UnlimitedHealth = false;
        int[] HealthOffset = { 0xF4 };
        int HealthToFill = 100;

        #endregion
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
Ah okay. Then something else is wrong. :)

Could you upload the project please? :)
 

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Ok, there you go

// Download links that lead outside GuidedHacking are not allowed. Please attach your project to your post. :)

Its 6mb i forgot to delete Scans from Scan pointers, just dont copy that
 
Last edited by a moderator:

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
ok, i have no idea how to do that
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
Could you attach the project to your post. :)

Edit your post sing the full editor. Scroll down till you see Attachments. Click on it, a window will open where you can upload your .zip file. :)
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
Cool.

I'll try to download it and see what's wrong. :)
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,088
78,998
2,373
I see the problem that you are having.

While your ammo works without any problems. The ammo hack only deals with the Shotgun while your Pistol and most likely other guns are not affected. I just took a look and the ammo for each weapon is stored separately in memory. Let's take a look at the pistol shall we?

The ammo for pistol is stored at offset 138 while the ammo for the shotgun is stored at offset 140. So you have to find all offsets for ammo. Go ahead and try it for yourself. The ammo offset for Pistol is 138. :)
 

gnuzim

Jr.Coder
Trump Tier Donator
Dank Tier Donator
Nobleman
Nov 28, 2012
67
1,418
0
Wow, nice, so the problem was the offsets!
Thanks alot for the help =D

Another question, when i get others offsets i can put all together in AmmoOffsets array?
 
Last edited:
Status
Not open for further replies.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods