Solved [c++] BasePointer "Game.exe + offset"

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

H4rtzer

Newbie
Full Member
Apr 9, 2013
6
172
0
Hey!

I often found a BasePointer which was not an address. For instance for the windowsgame "Solitair".The Base I found was something like solitaire.exe+BAFA8. In this case solitaire.exe is variable and so I always get a new base address after each start of solitaire. How can I handle that.

Thanks Guys!
 

H4rtzer

Newbie
Full Member
Apr 9, 2013
6
172
0
Ahh thanks! I often heard something about this function. Can you give a code example please;)?
 

Syperus

RTFM
Meme Tier VIP
Dank Tier Donator
Oct 29, 2012
432
2,638
7
You can use:

C++:
static DWORD dwGetModuleBaseAddress(DWORD dwProcessIdentifier, TCHAR *lpszModuleName)
		{
			HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessIdentifier);
			DWORD dwModuleBaseAddress = 0;
			if(hSnapshot != INVALID_HANDLE_VALUE)
			{
				MODULEENTRY32 ModuleEntry32 = {0};
				ModuleEntry32.dwSize = sizeof(MODULEENTRY32);
				if(Module32First(hSnapshot, &ModuleEntry32))
				{
					do
					{
						if(_tcscmp(ModuleEntry32.szModule, lpszModuleName) == 0)
						{
							dwModuleBaseAddress = (DWORD)ModuleEntry32.modBaseAddr;
							break;
						}
					}
					while(Module32Next(hSnapshot, &ModuleEntry32));
				}
				CloseHandle(hSnapshot);
			}
			return dwModuleBaseAddress;
		}
This will return the game base address. Usage example for this:
C++:
DWORD BaseAddress= dwGetModuleBaseAddress(pID, _T("GameName.exe"));
pID would be the processID incase you didnt' know. :)
 

H4rtzer

Newbie
Full Member
Apr 9, 2013
6
172
0
Is GetModuleAddress not included in windows.h? Or is it necessary to define this function on myself?
 

Syperus

RTFM
Meme Tier VIP
Dank Tier Donator
Oct 29, 2012
432
2,638
7
Is GetModuleAddress not included in windows.h? Or is it necessary to define this function on myself?
You need to include the TlHelp32.h header file for the snapshot. Go ahead and include tchar.h as well since you'll need that using the example.

C++:
#include <tchar.h>
#include <TlHelp32.h>
 

Syperus

RTFM
Meme Tier VIP
Dank Tier Donator
Oct 29, 2012
432
2,638
7
dwGetModuleBaseAddress works fine. What type of project is this (dll, console, form ect.). Post your code in code tags so I can see exactly what you're doing.
 

H4rtzer

Newbie
Full Member
Apr 9, 2013
6
172
0
I created a console application for that(32bit I think). I uses win7 64bit and Bisual Studio 2010 as IDE.

Code:

#include <Windows.h>
#include <stdio.h>
#include <iostream>
#include "GetModuleBaseAddress.h"
#include <tchar.h>

PCSTR WindowlName = "Solitär";
int main()

HWND hWindow = 0;
hWindow = FindWindow(NULL, WindowName);
DWORD dwProcessID = -1;
GetWindowThreadProcessId(hWindow, &dwProcessID);
HANDLE hProzessHandle = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, dwProcessID);
std::cout << "\nhWindow: " << hWindow << " \nPID: " << dwProcessID << " \nProzessHandle: " << hProzessHandle << std::endl;
DWORD BaseAddress= dwGetModuleBaseAddress(dwProcessID, _T("Solitair.exe")); //function renamed...also in Header of course
std::cout << "BaseAddress: "<<BaseAddress <<std::endl;

return 0;
}

Thanks Syperus for supporting me in this problem with such a high level of quality. Thanks!
 
Last edited:

Syperus

RTFM
Meme Tier VIP
Dank Tier Donator
Oct 29, 2012
432
2,638
7
Just at a quick glance I see a few things wrong.

C++:
#include "GetModuleBaseAddress.h"
What's in GetModuleBaseAddress.h? Did you define dwGetModuleBaseAddress() in here? If so and if that's all you defined in there then just remove it and define it in your main.cpp file (or whatever you named yours). It's also good practice to declare functions before int main() that are defined in a header to ensure an error free program. It's required if you define a function after int main().

You need to include <TlHelp32.h> for the CreateToolhelp32Snapshot function in dwGetModuleBaseAddress.

C++:
int main()
You need to have an open bracket "{" after int main().

C++:
HWND hWindow = 0;
hWindow = FindWindow(NULL, WindowName);
WindowName needs to be the actual name of the Window. I.E. Solitair. Also it's pointless to create/define hWindow as 0 and then redefine it in the next line. This isn't wrong and will work, but just pointless in this situation.

I'm going to be on my phone most of the day, but will be checking in from time to time. Try these fixes and see if that helps your problem. I'm working on a project with another member, but if you're still having problems when I get home I'll see if I can quickly debug your program if you still need assistance.
 

H4rtzer

Newbie
Full Member
Apr 9, 2013
6
172
0
Exuse me. Thats a copy mistake cause i dont want to copay the german commentary. I included <TlHelp32.h> in the Header of GetModuleBaseAddress.h and so yes I put GetModuleBaseAddress() in the Header GetModuleBaseAddress.h. The bracket was a copying mistake. The FindWindow function works. I have declared "PCSTR SpielName = "Unbenannt - Editor" for example. The window name is "Solitär" so I had to change to multibyte signs. Only thing I can tray is your first tip. A question: Is it possible that this function only works with 32bit executables, cause I found that on MSDN :"The modBaseAddr and hModule members are valid only in the context of the process specified by th32ProcessID."(Solitaire.exe is a 64bit) Thanks. I hope we can solve this problem.
 
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