Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › MultiPlayer Game Hacks & Cheats › Game Hack & Cheat Development › General Game Hacking › Whats wrong with this C# WPM method?

Whats wrong with this C# WPM method?

Posts 1–2 of 2 · Page 1 of 1
RP
Rpetty84
Whats wrong with this C# WPM method?
First off I know my offsets are correct (0x01C2EF54, 0x458, 0x0, 0x350, 0x584) because the ReadProcessMemory works fine and dandy. But im having a problem with Writing to address using the same offsets above, and im tired of banging my head on my desk trying to figure it out. So if any of you kind folks care to take a look it be most appreciated. How im trying to use is at the bottom.


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Windows.Forms;

namespace MemoryAPI
{
    public class MemoryEditor
    {

        public Process[] _TargetProcess;
        public int _ProcessId;
        public IntPtr _ProcessHandle;

        public void GetTargetProcess(string process_name)
        {
            try
            {
                _TargetProcess = Process.GetProcessesByName(process_name);
                _ProcessId = _TargetProcess[0].Id;
            }
            catch (Exception)
            {
                MessageBox.Show(null, "Sorry, target process " + process_name + " Could not be found. Please make sure desired application is running",
                    "Target Process Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }


        public void OpenProcess()
        {
            try
            {
                _ProcessHandle = OpenProcess((uint)RequiredAccess.All, false, _ProcessId);
            }
            catch (Exception)
            {
                MessageBox.Show(null, "failed to open target process", "Target Process Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public void CloseProcess()
        {
            if (_ProcessHandle != null)
            {
                CloseHandle(_ProcessHandle);
            }
        }


        public byte[] ReadMemoryWithOffsets(int[] offsets)
        {
            byte[] value = new byte[20];
            byte[] tmpAddressBuffer = new byte[4];
            IntPtr tmpAddress = IntPtr.Zero;
            int count = offsets.Length - 1;


            OpenProcess();

            if (count == 0)//Only 1 Offset
            {
                ReadProcessMemory(_ProcessHandle, IntPtr.Add(_TargetProcess[0].MainModule.BaseAddress, offsets[0]), value, 20, 0);
                CloseProcess();
                return value;
            }

            for (int i = 0; i <= count; i++)
            {
                if (i == count)
                {
                    ReadProcessMemory(_ProcessHandle, IntPtr.Add(tmpAddress, offsets[offsets.Length - 1]), value, 20, 0);
                    tmpAddress = IntPtr.Add(tmpAddress, offsets[i]);
                    CloseProcess();
                    return value;
                }

                else if (i == 0)
                {
                    ReadProcessMemory(_ProcessHandle, IntPtr.Add(_TargetProcess[0].MainModule.BaseAddress, offsets[i]), tmpAddressBuffer, 4, 0);
                    tmpAddress = (IntPtr)BitConverter.ToInt32(tmpAddressBuffer, 0);
                }
                else
                {
                    ReadProcessMemory(_ProcessHandle, IntPtr.Add(tmpAddress, offsets[i]), tmpAddressBuffer, 4, 0);
                    tmpAddress = (IntPtr)BitConverter.ToInt32(tmpAddressBuffer, 0);
                }
            }

            CloseProcess();
            return value;

        }


        public void WriteMemoryWithOffsets(int[] offsets, byte[] bytesToWrite)
        {

            byte[] value = new byte[20];
            byte[] tmpAddressBuffer = new byte[4];
            IntPtr tmpAddress = IntPtr.Zero;
            int count = offsets.Length - 1;

            OpenProcess();

            if (count == 0)
            {
                ReadProcessMemory(_ProcessHandle, IntPtr.Add(_TargetProcess[0].MainModule.BaseAddress, offsets[0]), tmpAddressBuffer, 4, 0);
            }

            for (int i = 0; i <= count; i++)
            {

                if (i == count)
                {
                    WriteProcessMemory(_ProcessHandle, IntPtr.Add(_TargetProcess[0].MainModule.BaseAddress, offsets[i]), bytesToWrite, bytesToWrite.Length, 0);
                }

                else if (i == 0)
                {
                    ReadProcessMemory(_ProcessHandle, IntPtr.Add(_TargetProcess[0].MainModule.BaseAddress, offsets[i]), tmpAddressBuffer, 4, 0);
                    tmpAddress = (IntPtr)BitConverter.ToInt32(tmpAddressBuffer, 0);
                }

                else
                {
                    ReadProcessMemory(_ProcessHandle, IntPtr.Add(tmpAddress, offsets[i]), tmpAddressBuffer, 4, 0);
                    tmpAddress = (IntPtr)BitConverter.ToInt32(tmpAddressBuffer, 0);
                }
            }

            CloseProcess();
        }

        //Access Flags
        [Flags]
        public enum RequiredAccess : uint
        {
            All = 0x001F0FFF,
            Terminate = 0x00000001,
            CreateThread = 0x00000002,
            VMOperation = 0x00000008,
            VMRead = 0x00000010,
            VMWrite = 0x00000020,
            DupHandle = 0x00000040,
            SetInformation = 0x00000200,
            QueryInformation = 0x00000400,
            Synchronize = 0x00100000,
        }

        //DLL IMPORTS
        [DllImport("kernel32.dll")]
        public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);


        [DllImport("kernel32.dll")]
        public static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesWritten);

        [DllImport("kernel32.dll")]
        public static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);

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

    }
}

So i load my offset array like this:
Code:
public static int[] CamDistOffsets = new int[] { 0x01C2EF54, 0x458, 0x0, 0x350, 0x584 };
and im trying to write to memory inside a trackbar value change event. (the event is working because thats how i tested my RPM method, value returned is correct(matches in game value)).
But like i said above when i try to write to same address the changes do not take place. (tested value change with CE and it works fine, Camera Zooms out as attended), but cant get same results with the WPM.

Oh and if your wondering, the trackbar changes the string in a textbox, and the textbox is the value im trying to WPM.

Code:
 private void tbr_CameraDistance_ValueChanged(object sender, EventArgs e)
        {
            //Write Value to Memory for CameraDistance
            float tbxValue = Convert.ToSingle(tbx_CameraDistance.Text);
            byte[] valueToWrite = BitConverter.GetBytes(tbxValue);
            Memory.WriteMemoryWithOffsets(CamDistOffsets, valueToWrite);
        }
#1 · 11y ago
RP
Rpetty84
LOL solved my own mistake by looking at a previous version of this class i made.(been away for awhile from the code dealing with processes).

My problem was i was adding offset to module base address when i should of been reading from the tempaddress.
Code:
if (i == count)
{
     WriteProcessMemory(_ProcessHandle, IntPtr.Add(_TargetProcess[0].MainModule.BaseAddress, offsets[i]), bytesToWrite, bytesToWrite.Length, 0);
}
and it should of been like this:

Code:
                if (i == count)
                {
                    WriteProcessMemory(_ProcessHandle, IntPtr.Add(tmpAddress, offsets[i]), bytesToWrite, bytesToWrite.Length, 0);
                }
#2 · 11y ago
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

  • whats wrong with this...By NetNavi in WarRock - International Hacks
    6Last post 19y ago
  • Whats wrong with this code ?By bohnenbong in WarRock - International Hacks
    7Last post 18y ago
  • whats wrong with this?By whitten in C++/C Programming
    3Last post 17y ago
  • Whats wrong with this?By superHackz in WarRock - International Hacks
    1Last post 18y ago
  • Whats wrong with this?By superHackz in Visual Basic Programming
    1Last post 18y ago

Tags for this Thread

#code#hack#help#question#readprocessmemory#writeprocessmemory