Solved C# Problem

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

xa84759x

Newbie
Full Member
Jan 11, 2015
13
102
0
its like this i get no errors but i wonder how i would set this up this is C# int[] HealthOffset = { 0x1F8, 0x2C4, 0xE0, 0x7F4 };


this is CE
string HealthPointer = "006F5F50";
this is the base address ----> "client.dll"+006F5F50 offset 7F4

other offsets
E0
2C4
1F8
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,140
78,998
2,394
other offsets
E0
2C4
1F8
This is in C++ but you just need to do the equivolent in C# and I have no idea how to do that.

Include this function prototype:
C++:
DWORD_PTR dwGetModuleBaseAddress(DWORD dwProcID, TCHAR *szModuleName)
Corresponding function:
C++:
DWORD_PTR dwGetModuleBaseAddress(DWORD dwProcID, TCHAR *szModuleName)
{
    DWORD_PTR dwModuleBaseAddress = 0;
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, dwProcID);
    if (hSnapshot != INVALID_HANDLE_VALUE)
    {
        MODULEENTRY32 ModuleEntry32;
        ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
        if (Module32First(hSnapshot, &ModuleEntry32))
        {
            do
            {
                if (_tcsicmp(ModuleEntry32.szModule, szModuleName) == 0)
                {
                    dwModuleBaseAddress = (DWORD_PTR)ModuleEntry32.modBaseAddr;
                    break;
                }
            } while (Module32Next(hSnapshot, &ModuleEntry32));
        }
        CloseHandle(hSnapshot);
    }
    return dwModuleBaseAddress;
}
Write this in your code:
C++:
DWORD HealthPointer = 0x006F5F50;[/COLOR]
DWORD HealthOffset[] = { 0x1F8, 0x2C4, 0xE0, 0x7F4 };

DWORD BaseAddress = (dwGetModuleBaseAddress(dwProcId, _T("client.dll"))) + 0x7F4;
other offsets
E0
2C4
1F8
I don't know what this is in reference to. If you are more specific and describe what you are doing more I can help you but I don't know jack about C#
 
Last edited:

xa84759x

Newbie
Full Member
Jan 11, 2015
13
102
0
what ya mean

this is the biggset problem int[] HealthOffset = { 0x1F8, 0x2C4, 0xE0, 0x7F4 };
 

Solaire

Respected Hacker
Dank Tier VIP
Dec 15, 2013
1,051
16,353
62
Learn the language before trying to hack with it. Change int to DWORD, and what's the issue you're having? That's like saying "I'm having an issue with my house". Explain! What's the issue with your house? Plumbing? Smells? Random ghosts looking at you in the mirror? (Might just be you in that case).
 

Syntax Error

Coder
Silenced
Meme Tier VIP
Nov 6, 2014
239
2,928
6
Im pretty sure hes talking about a transgender marshmellow.. its an int array and a string... ?
 

xa84759x

Newbie
Full Member
Jan 11, 2015
13
102
0
thats not working either but i followed fleeps tut but did it with gmod that has multipule offsets and have that client.dll
 

xa84759x

Newbie
Full Member
Jan 11, 2015
13
102
0
C#:
using System;
using System.Diagnostics;
using System.Globalization;
using System.Windows.Forms;
using Virtua_Cop_2Trainer;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        #region region variables
        Memory myMemory = new Memory();
        Process[] myprocess;
        bool IsGameAvailble = false;

        bool UnlimitedAmmo = false;
        string AmmoPointer = "00509B74";
        int[] AmmoOffset = { 0x148 };
        int AmmoFill = 400;

        bool UnlimitedHealth = false;
        string HealthPointer = "006F5F50";
        int[] HealthOffset = { 0x7F4, 0x15, 0x0};    <----- this one
        int HealthFill = 5000;

        bool UnlimitedAmmo1 = false;
        string AmmoPointer1 = "00509B74";
        int[] AmmoOffset1 = { 0x150 };
        int Ammofill1 = 400;

        bool UnlimitedAmmo2 = false;
        string AmmoPointer2 = "00509B74";
        int[] AmmoOffset2 = { 0x14C };
        int Ammofill2 = 400;

        bool UnlimitedAmmo3 = false;
        string AmmoPointer3 = "00509B74";
        int[] AmmoOffset3 = { 0x13C };
        int Ammofill3 = 400;

        bool UnlimitedAmmo4 = false;
        string AmmoPointer4 = "00509B74";
        int[] AmmoOffset4 = { 0x144 };
        int Ammofill4 = 400;

        bool UnlimitedArmour = false;
        string ArmourPointer = "00509B74";
        int[] ArmourOffset = { 0xFC };
        int Armourfill = 1000;

        bool UnlimitedAmmo5 = false;
        string AmmoPointer5 = "00509B74";
        int[] AmmoOffset5 = { 0x158 };
        int Ammofill5 = 400;

        #endregion



        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            {
                if (IsGameAvailble)
                {
                    if (UnlimitedHealth)
                    {
                        UnlimitedHealth = false;
                        button1.Text = "Deactivated";
                    }
                    else
                    {
                        UnlimitedHealth = true;
                        button1.Text = "Activated";
                    }
                }
            }
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (IsGameAvailble)
            {
                if (UnlimitedAmmo)
                {
                    UnlimitedAmmo = false;
                    button2.Text = "Deactivated";
                }
                else
                {
                    UnlimitedAmmo = true;
                    button2.Text = "Activated";
                }
            }
        }

        private void GameAvailabilityTMR_Tick(object sender, EventArgs e)
        {
            myprocess = Process.GetProcessesByName("hl2");
            if (myprocess.Length != 0)
            {
                IsGameAvailble = true;
                StatusLBL.Text = "Status: gmod is ready too hack";
            }
            else
            {
                IsGameAvailble = false;
                StatusLBL.Text = "Status: gmod is not ready too hack";


            }
        }

        private void UpdateCheatsTMR_Tick(object sender, EventArgs e)
        {
            if (IsGameAvailble)
            {
                #region Ammo
                if (UnlimitedAmmo)
                {
                    myMemory.ReadProcess = myprocess[0];
                    myMemory.Open();
                    int pointerAddress = HexToDec(AmmoPointer);
                    int[] pointerOffset = AmmoOffset;
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(AmmoFill);
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, valueToWrite, pointerOffset, out bytesWritten);
                    myMemory.CloseHandle();
                }



                #endregion
                #region Health
                if (UnlimitedHealth)
                {
                    myMemory.ReadProcess = myprocess[0];
                    myMemory.Open();
                    int pointerAdress = HexToDec(HealthPointer);
                    int[] pointerOffset = HealthOffset;
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(HealthFill);
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAdress, valueToWrite, pointerOffset, out bytesWritten);
                    myMemory.CloseHandle();
                }
                #endregion
                #region UnlimitedAmmo1
                if (UnlimitedAmmo1)
                {

                    myMemory.ReadProcess = myprocess[0];
                    myMemory.Open();
                    int pointerAdress = HexToDec(AmmoPointer1);
                    int[] pointerOffset = AmmoOffset1;
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(Ammofill1);
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAdress, valueToWrite, pointerOffset, out bytesWritten);
                    myMemory.CloseHandle();

                }
                #endregion
                #region UnlimitedAmmo2
                if (UnlimitedAmmo2)
                {

                    myMemory.ReadProcess = myprocess[0];
                    myMemory.Open();
                    int pointerAdress = HexToDec(AmmoPointer2);
                    int[] pointerOffset = AmmoOffset2;
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(Ammofill2);
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAdress, valueToWrite, pointerOffset, out bytesWritten);
                    myMemory.CloseHandle();

                }
                #endregion
                #region UnlimitedAmmo3
                if (UnlimitedAmmo3)
                {
                    myMemory.ReadProcess = myprocess[0];
                    myMemory.Open();
                    int pointerAdress = HexToDec(AmmoPointer3);
                    int[] pointerOffset = AmmoOffset3;
                    int bytesWritten;
                    byte[] valueToWrite = BitConverter.GetBytes(Ammofill3);
                    string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAdress, valueToWrite, pointerOffset, out bytesWritten);
                    myMemory.CloseHandle();
                #endregion
                #region UnlimitedAmmo4
                    if (UnlimitedAmmo4)
                    {
                        myMemory.ReadProcess = myprocess[0];
                        myMemory.Open();
                        int pointerAddress = HexToDec(AmmoPointer4);
                        int[] PointerOffset = AmmoOffset4;
                        int BytesWritten;
                        byte[] ValueToWrite = BitConverter.GetBytes(Ammofill4);
                        string WrittenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, ValueToWrite, PointerOffset, out BytesWritten);
                        myMemory.CloseHandle();
                #endregion
                #region Armour
                        {
                            myMemory.ReadProcess = myprocess[0];
                            myMemory.Open();
                            int PointerAdress = HexToDec(ArmourPointer);
                            int[] PointerOffsetX = ArmourOffset;
                            int byteswritten;
                            byte[] valueToWriteX = BitConverter.GetBytes(Armourfill);
                            string Writtenaddress = myMemory.PointerWrite((IntPtr)PointerAdress, valueToWriteX, PointerOffsetX, out byteswritten);
                            myMemory.CloseHandle();
                              }
                            #endregion
                #region UnlimitedAmmo5
                            {
                            myMemory.ReadProcess = myprocess[0];
                            myMemory.Open();
                            int pointerAddressX = HexToDec(AmmoPointer4);
                            int[] PointerOffsetx = AmmoOffset4;
                            int BytesWrittenB;
                            byte[] ValueToWritex = BitConverter.GetBytes(Ammofill4);
                            string Writtenaddress = myMemory.PointerWrite((IntPtr)pointerAddressX, ValueToWritex, PointerOffsetx, out BytesWrittenB);
                            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 button3_Click(object sender, EventArgs e)
        {
            {
                if (IsGameAvailble)
                {
                    if (UnlimitedAmmo1)
                    {
                        UnlimitedAmmo1 = false;
                        button3.Text = "Deactivated";
                    }
                    else
                    {
                        UnlimitedAmmo1 = true;
                        button3.Text = "Activated";
                    }
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            {
                {
                    if (IsGameAvailble)
                    {
                        if (UnlimitedAmmo2)
                        {
                            UnlimitedAmmo2 = false;
                            button4.Text = "Deactivated";
                        }
                        else
                        {
                            UnlimitedAmmo2 = true;
                            button4.Text = "Activated";
                        }
                    }
                }
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            {
                {
                    {
                        if (IsGameAvailble)
                        {
                            if (UnlimitedAmmo3)
                            {
                                UnlimitedAmmo3 = false;
                                button5.Text = "Deactivated";
                            }
                            else
                            {
                                UnlimitedAmmo3 = true;
                                button5.Text = "Activated";
                            }
                        }
                    }
                }
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            {
                {
                    {
                        {
                            if (IsGameAvailble)
                            {
                                if (UnlimitedAmmo4)
                                {
                                    UnlimitedAmmo4 = false;
                                    button6.Text = "Deactivated";
                                }
                                else
                                {
                                    UnlimitedAmmo4 = true;
                                    button6.Text = "Activated";
                                }
                            }
                        }
                    }
                }
            }

        }

        private void button7_Click(object sender, EventArgs e)
        {
            {
                {
                    {
                        {
                            {
                                if (IsGameAvailble)
                                {
                                    if (UnlimitedArmour)
                                    {
                                        UnlimitedArmour = false;
                                        button7.Text = "Deactivated";
                                    }
                                    else
                                    {
                                        UnlimitedArmour = true;
                                        button7.Text = "Activated";
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            {
                {
                    {
                        {
                            {
                                {
                                    if (IsGameAvailble)
                                    {
                                        if (UnlimitedAmmo5)
                                        {
                                            UnlimitedAmmo5 = false;
                                            button8.Text = "Deactivated";
                                        }
                                        else
                                        {
                                            UnlimitedAmmo5 = true;
                                            button8.Text = "Activated";
                                        }
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }
    }
}
 
Last edited by a moderator:

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,140
78,998
2,394
In memory.cs there is this function:

C#:
       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);
        }
You want to make sure you're unlimited health function is calling this PointerWrite() function and it is going to the second part:

C#:
  //only necessary for multiple OFFSETS
            for (int i = 0; i <= iPointerCount; i++)
So breakpoint this line in Form1.cs:
C#:
string writtenAddress = myMemory.PointerWrite((IntPtr)pointerAddress, valueToWrite, pointerOffset, out bytesWritten);
that's when your unlimited health keybind gets pressed. Step through the code into the PointerWrite() function because the health uses a multi offset pointer you need to make sure that it is detecting the iPointerCount correctly.
I am sure your problem will be found from stepping through the code after breakpointing that address.
 
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