Solved Always Getting The Wrong Result

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

danqua

Newbie
Nov 2, 2015
3
62
0
Hi there,

first of all I'm new to this board; followed the link from the YouTube Channel :)

My Problem is that I don't know why I always get the wrong results.
I successfully found the pointers I was trying to find. (Snes9X with Super Mario World)

What I found out so far
C++:
base address 	0x140405EC8
or
"snes9x-x64.exe" + 0x405EC8

Coins Offset 	0xdbf
Life 		0xdbe
Player Status 	0x019
Joshi-State 	0x0ca
When I enter the base address above with one of the offsets in Cheat Engine everything works just fine, still when I relaunch Cheat Engine or the Emulator.

I don't get any results when I try to achieve the same in C++. The outputted data looks also really strange.

My Code
C++:
int main(void)
{
	HANDLE hProcess = NULL;
	HMODULE hModule = NULL;
	DWORD dwProcessId = NULL;
	HWND hWindow = FindWindow(NULL, "Snes9X v1.53 for Windows");

	if (!hWindow)
	{
		std::cerr << "Snes9x v1.53 window not found." << std::endl;
		return -1;
	}

	// Find process of window
	GetWindowThreadProcessId(hWindow, &dwProcessId);
	if (dwProcessId == NULL)
	{
		std::cout << "Failed to get window thread process." << std::endl;
		return -2;
	}

	hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, dwProcessId);
	hModule = GetModuleHandle(0);
	
	DWORD dwAddressOffset = NULL;
	BYTE life = 0;
	
	// base address = 0x140405EC8
	// "snes9x-x64.exe"  + 0x405EC8
	ReadProcessMemory(hProcess, (PBYTE*)(hModule + 0x405EC8), &dwAddressOffset, sizeof(DWORD), NULL);
	ReadProcessMemory(hProcess, (PBYTE*)(dwAddressOffset + 0xdbe), &life, sizeof(BYTE), NULL);
	
	std::cout << "hProcess: \t" << std::hex << hProcess << std::dec << std::endl;
	std::cout << "hModule: \t" << std::hex << hModule << std::dec << std::endl;
	std::cout << "hWindow: \t" << std::hex << hWindow << std::dec << std::endl;
	std::cout << "dwProcessId: \t" << dwProcessId << std::endl;
	std::cout << "0xdbe: \t\t" << (int)life << std::endl;
	
	CloseHandle(hProcess);
	
	getchar();
	return 0;
}

OUTPUT
hProcess:       0000000000000088
hModule:        00007FF6C3240000
hWindow:        00000000001E0A86
dwProcessId:    2440
0xdbe:          0
I hope I made my point clear. Thanks for your help!

danqua
 

mambda

headass
Escobar Tier VIP
Trump Tier Donator
Jun 25, 2014
2,298
37,938
269
hModule = GetModuleHandle(0);
No.

You can't get module handle anything outside your address space, to get the base address of a module of another program you can either use TlHelp32 or ReadProcessMemory the programs PEB and parse it for module locations in memory,

there are loads of tutorials out there on using TlHelp32 to get module addresses so it shouldn't be too much of a bother
 

danqua

Newbie
Nov 2, 2015
3
62
0
hModule = GetModuleHandle(0);
No.

You can't get module handle anything outside your address space, to get the base address of a module of another program you can either use TlHelp32 or ReadProcessMemory the programs PEB and parse it for module locations in memory,

there are loads of tutorials out there on using TlHelp32 to get module addresses so it shouldn't be too much of a bother
I used the code from here (this method ListProcessModules) to list the modules. Now I am really confused which module is the right one? I got a list with about 15-25 modules listed.

EDIT: typo; I meant the method ListProcessModules
 
Last edited:
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