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 › Programming › C++/C Programming › Basic memory editing problem c++ GTA

Basic memory editing problem c++ GTA

Posts 1–5 of 5 · Page 1 of 1
base187
base187
Basic memory editing problem c++ GTA
I have recently got involved in game hacking and wanted to try making a small trainer for GTA SA:MP using tutorials.

It's a basic tool to change the money, I found out the memory address which is correct
But when I try t run the hack it just doesn't change the money.

Code:
#include <iostream>
#include <windows.h>

int newdata = 99999999;

int main() 
{
	HWND hWnd = FindWindow(0, "GTA:SA:MP");
  	if(hWnd == 0)
	{
    		printf("Error cannot find window.");
  	} 
	else
	{
		DWORD ProcessID;
		GetWindowThreadProcessId(hWnd, &ProcessID);
		HANDLE handleprocess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessID);
		if(!handleprocess)
			printf("Error opening process");
		else{
			WriteProcessMemory(handleprocess, (LPVOID)0xB7CE50, &newdata, (DWORD)sizeof(newdata), NULL);
		}
		CloseHandle(handleprocess);

	}

	getchar();
  	return 0;
}
It can't seem to open the process correctly so I tried using PROCESS_QUERY_INFORMATION instead of PROCESS_ALL_ACCESS which seems to work but it still won't change the money value. It's getting frustrating and I wonder if anyone can help me out.
#1 · 12y ago
Jabberwock
Jabberwock
WriteProcessMemory function (Windows)

To be able to use WriteProcessMemory you'll need to have both PROCESS_VM_WRITE and PROCESS_VM_OPERATION access on the handle, or simply PROCESS_ALL_ACCESS which includes them both.

0xB7CE50 is your address? Did you find it in Cheat Engine? In Cheat Engine the module's offset isn't showing as a part of the address, so if it's shown like this: GTA.exe+B7CE50 then GTA.exe -> is the offset which you will need to add to B7CE50, look at the address list where it doesn't show it in this form.

And if OpenProcess fails when you try to open the process with PROCESS_ALL_ACCESS, you can see what is the problem with this function:

Code:
void ShowError(DWORD dwErrorCode)
{
	TCHAR* lpMessageBuffer;

	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (TCHAR*)&lpMessageBuffer, 0, NULL);

	MessageBox(HWND_DESKTOP, lpMessageBuffer, NULL, MB_OK | MB_ICONINFORMATION);

	LocalFree(lpMessageBuffer);
}
Add it above main() function. And instead of printf("Error opening process"); type: ShowError(GetLastError());
#2 · edited 12y ago · 12y ago
abuckau907
abuckau907
Quote Originally Posted by base187 View Post
.
So you can't get OpenProcess() to return a valid handle? ..try running the program "As Administrator" ?

Also, WriteProcessMemory() returns a BOOL: you should check it for success/fail.
And you do output messages when there are errors, but it might also be helpful to give output for successes, just for debugging purposes.

ex.
#include <iostream>
#include <windows.h>

int newdata = 99999999;

int main()
{
HWND hWnd = FindWindow(0, "GTA:SA:MP");
if(hWnd == 0)
{
printf("Error cannot find window.");
}
else
{
std::cout <<"SA:MP Window Found, Handle: " << hWnd << std::endl;
DWORD ProcessID;
GetWindowThreadProcessId(hWnd, &ProcessID);
std::cout <<"SA:MP Process Id: " << ProcessID << std::endl;
HANDLE handleprocess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcessID);
if(!handleprocess)
printf("Error opening process");
else{
std::cout <<"OpenProcess() Success! _handle returned was: " << handleprocess << std::endl;
if (WriteProcessMemory(handleprocess, (LPVOID)0xB7CE50, &newdata, (DWORD)sizeof(newdata), NULL) == TRUE)
std::cout <<"WriteProcessMemory Ssccess. Value was changed to " << newdata << std::endl;
else
std::cout <<"WriteProcessMemory Failed!" << std::endl;

CloseHandle(handleprocess);

}


}

getchar();
return 0;
}

//not important yet, but also moved CloseHandle() --> it was getting called even if the handle wasn't valid.


Switch it back to PROCESS_ALL_ACCESS and try running your IDE (if you have one) "as Administrator" and|or running the program "as Administrator".
#3 · edited 12y ago · 12y ago
Biesi
Biesi
Try
- setting debug privileges
- unhiding the process
- using PROCESS_VM_WRITE | PROCESS_VM_OPERATION
#4 · 12y ago
base187
base187
Thanks everyone for posting! Sorry it took me a few days to reply.

Jabberwo0ck: Yes the memory address is the right one, I used an online list of memory addresses. I used your error function, the error it gave was "access denied" which was what I thought it probably was.

abuckau907: Running as admin seemed to fix it but I really wanted to be able to run the hack with a limited account, I could edit the values using cheat engine fine but not with my hack. I prefer using c style strings instead out cout, I find it cleaner and easier to organize data.

[MPGH]Biesi: I have seen some people using debug privileges but I could never get it to work. You were right about adjusting the access rights.

I got it working, I changed the access rights to: PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION
and now it seems to work great so thanks everyone!

Here's the code:
Code:
#include <cstdlib>
#include <iostream>
#include <windows.h>

int newdata = 1000;



void ShowError(DWORD dwErrorCode)
{
	TCHAR* lpMessageBuffer;

	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (TCHAR*)&lpMessageBuffer, 0, NULL);

	MessageBox(HWND_DESKTOP, lpMessageBuffer, NULL, MB_OK | MB_ICONINFORMATION);

	LocalFree(lpMessageBuffer);
}

int main() 
{
	HWND hWnd = FindWindow(0, "GTA:SA:MP");
  	if(hWnd == 0)
	{
			ShowError(GetLastError());
  	} 
	else
	{
		DWORD ProcessID;
		GetWindowThreadProcessId(hWnd, &ProcessID);
		HANDLE handleprocess = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, ProcessID);
		if(!handleprocess)
		{
			ShowError(GetLastError());
		}
		else{
			int hack = WriteProcessMemory(handleprocess, (LPVOID)0xB7CE50, &newdata, (DWORD)sizeof(newdata), NULL);
			if(hack > 0){
				printf("success!");
			}
			else{
				ShowError(GetLastError());
			}
		}
		CloseHandle(handleprocess);

	}

	getchar();
  	return 0;
}
#5 · 12y ago
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

  • Getting started with C++ DLL hacking - Basic Memory EditingBy Kai13shadow in C++/C Programming
    2Last post 13y ago
  • [Tutorial] Basic C++ Game Hacking (Memory Editing)By Tukjedude in C++/C Programming
    17Last post 16y ago
  • Problem with memory editing.By tdct in C++/C Programming
    2Last post 15y ago
  • memory editing idea/helpBy ihacksumtimes in Combat Arms Help
    1Last post 16y ago
  • Memory editing Last chaos?By Darkendnox in General Game Hacking
    3Last post 19y ago

Tags for this Thread

None