Solved ReadProcessMemory can't subtract addresses

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

olsarets7

Newbie
Full Member
Nov 15, 2014
13
92
0
Hello,

I'm working on csgo, and i want to get inCrosshairID. So I do dis:
C++:
ReadProcessMemory(hH, (LPCVOID)(playerBase + dw_chid), &inchid, sizeof(inchid), 0);
But inchid does not get a value at all.
playerBase got a value, and dw_chid as well. But they dont wanna add up, lol.

Anyways I'd want to know why this happens. So if anyone got an idea, I'm glad to hear it. Thanks in advance.
 

olsarets7

Newbie
Full Member
Nov 15, 2014
13
92
0
Sure thing.

C++:
DWORD dw_localPlayer = 0x00A844DC;
DWORD dw_entitylist = 0x04A9F774;
DWORD dw_health = 0x000000FC;
DWORD dw_chid = 0x0000AA44;
DWORD dw_teamnum = 0x000000F0;
DWORD entloopDist = 0x10;

DWORD clientDLL;
DWORD playerBase;
DWORD localTeam;
DWORD inchid;

HANDLE hH = NULL;
HWND hW = NULL;
DWORD procID;

        //CLIENT.dll
DWORD GetModuleBaseExtern(const DWORD dwProcessId, const char *szModuleName)
{
	HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessId);
	if (!hSnap) return 0;

	MODULEENTRY32 me;
	me.dwSize = sizeof(MODULEENTRY32);

	DWORD dwReturn = 0;

	if (Module32First(hSnap, &me)) {
		while (Module32Next(hSnap, &me)) {
			if (lstrcmpi(me.szModule, szModuleName) == 0) {
				dwReturn = (DWORD)me.modBaseAddr;
				break;
			}
		}
	}
	CloseHandle(hSnap);
	return dwReturn;
}


        hW = FindWindow(NULL, "Counter-Strike: Global Offensive");
	GetWindowThreadProcessId(hW, &procID);
	hH = OpenProcess(PROCESS_VM_READ | PROCESS_VM_OPERATION | PROCESS_VM_WRITE, FALSE, procID);
	clientDLL = GetModuleBaseExtern(procID, "client.dll");

	ReadProcessMemory(hH, (LPCVOID)(clientDLL + dw_localPlayer), &playerBase, sizeof(playerBase), 0); //all our info
	ReadProcessMemory(hH, (LPCVOID)(playerBase + dw_teamnum), &localTeam, sizeof(localTeam), 0); //enemyteam != localteam -> shoot
	ReadProcessMemory(hH, (LPCVOID)(playerBase + dw_chid), &inchid, sizeof(inchid), 0);//for knowing whats in out ch
        //^ this one does not get a value (inchid)

//what i'd like to do when i got inchid
ReadProcessMemory(hH, (LPCVOID)((clientDLL + dw_entitylist) + ((inchid - 1) * entloopDist)), &enemyCH, sizeof(enemyCH), 0); //if enemyCH


ReadProcessMemory(hH, (LPCVOID)(enemyCH + dw_health), &enemyHealth, sizeof(enemyHealth), 0); //IN enemy team, declaing their health.

ReadProcessMemory(hH, (LPCVOID)(enemyCH + dw_teamnum), &enemyTeam, sizeof(enemyTeam), 0); //IN enemy team, declaring their team num
 

olsarets7

Newbie
Full Member
Nov 15, 2014
13
92
0
Rake;42438 said:
That offset looks 100% wrong, make sure it is correct
Yeah, looked at wrong "quote". Ty for pointing that out.
I do not know what is going on. I cant even get playerBase right now...
Still doesnt read memory, or get adddresses and store them in playerBase.,,,
 

olsarets7

Newbie
Full Member
Nov 15, 2014
13
92
0
Yo, GetLastError() return 0x12b(299)
which means that only a part of readprocessmemory was read. I got no idea how to go from here. I dont know why it fails, i dong know what the error means even...
 

Lukor

ded
Meme Tier VIP
Fleep Tier Donator
Dec 13, 2013
489
5,353
25
One cause of this could be that you read below 4 byte of size (happened to me atleast) OR that you read not used memory.
Lets say the process memory starts at 0x40000 and you try to read from 0x10000... there is no module loaded to this memory so you can not read any process memory.
 

olsarets7

Newbie
Full Member
Nov 15, 2014
13
92
0
One cause of this could be that you read below 4 byte of size (happened to me atleast) OR that you read not used memory.
Lets say the process memory starts at 0x40000 and you try to read from 0x10000... there is no module loaded to this memory so you can not read any process memory.
Thanks, I wasn't reading 4 byte size. But still 1 problem tho, and that is this shiit:
C++:
ReadProcessMemory(hHandle, (LPCVOID)(clientDLL + dw_entityList + ((in_crosshair - 1) * dw_entloopDist)), &enemyinCH, sizeof(enemyinCH), NULL);
enemyinCH doesn't get a value. Size is 4 bytes. I get error 0x12b when I debug it. (getlasterror())
I know what it means but I don't know enough to know how to solve it... Any help appreciated.
Also pls no spoonfeeding sinxe i'm trying to learn, as much as I can.
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,104
78,998
2,374
Thanks, I wasn't reading 4 byte size. But still 1 problem tho, and that is this shiit:
C++:
ReadProcessMemory(hHandle, (LPCVOID)(clientDLL + dw_entityList + ((in_crosshair - 1) * dw_entloopDist)), &enemyinCH, sizeof(enemyinCH), NULL);
enemyinCH doesn't get a value. Size is 4 bytes. I get error 0x12b when I debug it. (getlasterror())
I know what it means but I don't know enough to know how to solve it... Any help appreciated.
Also pls no spoonfeeding sinxe i'm trying to learn, as much as I can.
You literally need to step through every single line of code and to find your problem.

Also you're adding dw_entityList to dw_clientdll but looks like dw_entityList is a static address not a relative offset but I could be wrong.
C++:
DWORD dw_entitylist = 0x04A9F774;
Make sure your offsets are correct. If you are copy and pasting offsets from a source on the internet I recommend you stop doing that and learn how to do it yourself.
 

Lukor

ded
Meme Tier VIP
Fleep Tier Donator
Dec 13, 2013
489
5,353
25
You did not read my whole post.
ReadProcessMemory tries to read from not used memory.

Rake is probably right.
You read wrong addresses. Check your addresses and offsets.
 

olsarets7

Newbie
Full Member
Nov 15, 2014
13
92
0
Solved it, thanks. I remade the entire trigger. Apparently this is completely wrong, since i can't get all in one...
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,104
78,998
2,374
Solved it, thanks. I remade the entire trigger. Apparently this is completely wrong, since i can't get all in one...
You did a good job so far, just got some learnin' to do :)
 
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