Solved Reading/Writing to memory

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

zoratz

Jr.Coder
Dank Tier Donator
Nobleman
Jul 22, 2013
81
838
2
Hey guys, I have a question, migth be easy for the most, however, i'm getting confused with it.
Can you explain, step by step, whats these functions below do? I mean, line by line..
I understand some of the lines, but the whole thing.

HTML:
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress){
	DWORD pointer = BaseAddress;
	DWORD pTemp;
	DWORD pointerAddr;

	for(int i = 0; i < PointerLevel; i++){
		if(i == 0){
			ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, 4, NULL);
		}

		// Add 1st OFFSET to that address
		pointerAddr = pTemp + Offsets[i];

		ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, 4, NULL);
	}
	return pointerAddr;
}

void WriteToMemory(HANDLE hProcHandle){
	// AMMO
	DWORD AmmoAddressToWrite = FindDmaAddy(3, hProcHandle, AmmoOffsets, AmmoBaseAddress);
	WriteProcessMemory(hProcHandle, (BYTE*)AmmoAddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL);

	// HEALTH
	DWORD HealthAddressToWrite = FindDmaAddy(1, hProcHandle, HealthOffsets, HeatlhBaseAddress);
	WriteProcessMemory(hProcHandle, (BYTE*)HealthAddressToWrite, &HealthValue, sizeof(HealthValue), NULL);
}
Thanks yall..
 

NebulaGrey

Newbie
Full Member
Jun 8, 2014
30
218
1
DWORD FindDmaAddy(int PointerLevel, HANDLE hProcHandle, DWORD Offsets[], DWORD BaseAddress){ // looks to be a user-made method to loop through all the reads.
DWORD pointer = BaseAddress; // The base address (used without any offsets)
DWORD pTemp; // Temporary offset
DWORD pointerAddr; // Another address + offsets

for(int i = 0; i < PointerLevel; i++){
if(i == 0){
ReadProcessMemory(hProcHandle, (LPCVOID)pointer, &pTemp, 4, NULL); // Gets the value of the baseaddrPtr.
}

// Add 1st OFFSET to that address
pointerAddr = pTemp + Offsets; // Adds the offset

ReadProcessMemory(hProcHandle, (LPCVOID)pointerAddr, &pTemp, 4, NULL); // Finds the value of pointerAddr, and writes it to pTemp
}
return pointerAddr; // Returns the address used to read/write to the value you want.
}

void WriteToMemory(HANDLE hProcHandle){ // Writes to an open process
// AMMO
DWORD AmmoAddressToWrite = FindDmaAddy(3, hProcHandle, AmmoOffsets, AmmoBaseAddress); // Gets the address for Ammo to be written to.
WriteProcessMemory(hProcHandle, (BYTE*)AmmoAddressToWrite, &AmmoValue, sizeof(AmmoValue), NULL); // Writes to the address found above. with AmmoValue (if AmmoValue is 4 Bytes, it writes 4 Bytes)

// HEALTH
DWORD HealthAddressToWrite = FindDmaAddy(1, hProcHandle, HealthOffsets, HeatlhBaseAddress); // As above but for health
WriteProcessMemory(hProcHandle, (BYTE*)HealthAddressToWrite, &HealthValue, sizeof(HealthValue), NULL); // As above but for health
}

I've added comments to every line, hope that helps :)
 
Last edited:

zoratz

Jr.Coder
Dank Tier Donator
Nobleman
Jul 22, 2013
81
838
2
Thanks alot NebulaGrey, after I read your comments I realised that I was forgotting some thoughs over there..
Thanks again
 
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