Write Process Memory causing CS:GO to crash?

Posts 12 of 2 · Page 1 of 1
Write Process Memory causing CS:GO to crash?
Hi Guys,

So i'm starting to get into developing hacks for CS:GO, following a few tutorials and using some resources from this site to help me get started. The tutorial I've been following has been using VAMemory which i understand as not being that good? So i've been implementing the Read and Write process memory functions but when it tries to write a value of 0 it is crashing CS:GO? Any help?

Code:
                ProcessMemory pMemory = new ProcessMemory();
                Process lProcess = Process.GetProcessesByName("csgo")[0];
                IntPtr oProcess = OpenProcess(0x1F0FFF, false, (IntPtr)lProcess.Id);

                if (GetModuleAddy())
                {
                    while (true)
                    {
                        GlowStruct Enemy = new GlowStruct()
                        {
                            r = 1,
                            g = 0,
                            b = 0,
                            a = 1,
                            rwo = true,
                            rwuo = true

                        };

                        int address;
                        int i = 1;

                        do
                        {
                            address = bClient + Offsets.oLocalPlayer;
                            int Player = pMemory.Read(oProcess, address);

                            address = Player + Offsets.oTeam;
                            int MyTeam = pMemory.Read(oProcess, address);

                            address = bClient + Offsets.oEntityList + (i - 1) * 0x10;
                            int EntityList = pMemory.Read(oProcess, address);

                            address = EntityList + Offsets.oTeam;
                            int EnemyTeam = pMemory.Read(oProcess, address);

                            address = EntityList + Offsets.oGlowIndex;

                            int GlowIndex = pMemory.Read(oProcess, address);

                            address = EnemyTeam + Offsets.oDormant;
                            if (!pMemory.ReadBoolean(oProcess, address))
                            {
                                address = bClient + Offsets.oGlowObject;
                                int GlowObject = pMemory.Read(oProcess, address);

                                int calculation = GlowIndex * 0x38 + 0x4;
                                int current = GlowObject + calculation;
                                pMemory.WriteFloat(oProcess, address, Enemy.r);

                                calculation = GlowIndex * 0x38 + 0x8;
                                current = GlowObject + calculation;
                                pMemory.WriteFloat(oProcess, address, Enemy.g);

                                calculation = GlowIndex * 0x38 + 0xC;
                                current = GlowObject + calculation;
                                pMemory.WriteFloat(oProcess, address, Enemy.b);

                                calculation = GlowIndex * 0x38 + 0x10;
                                current = GlowObject + calculation;
                                pMemory.WriteFloat(oProcess, address, Enemy.a);

                                calculation = GlowIndex * 0x38 + 0x24;
                                current = GlowObject + calculation;
                                pMemory.WriteBoolean(oProcess, address, Enemy.rwo);

                                calculation = GlowIndex * 0x38 + 0x25;
                                current = GlowObject + calculation;
                                pMemory.WriteBoolean(oProcess, address, Enemy.rwuo);
                            }

                            i++;
                        } while (i < 65);

                        Thread.Sleep(10);
                    }
Specifically it is crashing after executing this set of code:

Code:
                                
                                calculation = GlowIndex * 0x38 + 0x8;
                                current = GlowObject + calculation;
                                pMemory.WriteFloat(oProcess, address, Enemy.g);
and here is the WriteFloat function in case the problem is in that:

Code:
        public bool WriteFloat(IntPtr handle, int address, float value)
        {
            byte[] dataBuffer = BitConverter.GetBytes(value);
            IntPtr bytesWritten = IntPtr.Zero;

            WriteProcessMemory(handle, (IntPtr)address, dataBuffer, dataBuffer.Length, out bytesWritten);

            if (bytesWritten == IntPtr.Zero)
            {
                return false;
            }
            if (bytesWritten.ToInt32() < dataBuffer.Length)
            {
                return false;
            }

            return true;
        }

Any help would be appreciated, Thank-you!
Resolved:

For anyone wondering about this i was writing to the wrong address

Code:
pMemory.WriteFloat(oProcess, address, Enemy.g);
'address' should have been 'current'
Posts 12 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?