PostHelpDo you always have to readProcessMemory before writingProcessMemory?

Posts 1–7 of 7 · Page 1 of 1
Do you always have to readProcessMemory before writingProcessMemory?
While adding more hacks to my trainer I started to get a bit confused whether I need to always readProcessMemory before I writeProcessMemory.
Do I have to always read before I write or does it still work fine if I don't? and if I don't what is the down side?


PS. Sorry I have posted a lot recently XD
I'm not sure if you ALWAYS have to read the memory before you write it, however in most cases I believe you do. Just for the simple reason that the data you want to edit needs to be accessed through more than 1 pointer. I'm going to use reading and writing CS GO as an example because that's what I know best.

Code:
example:
(I dont care to use correct syntax I use memory libraries anyway, I don't use readprocessmemory)

int LocalBase = Readmem.CSGO<int>(bClient + LocalPlayer) // We have to do this because in order to access pretty much any valuable data we have to go through the bClient and LocalPlayer pointers. 

int Health = Readmem.CSGO<int>(LocalBase + HealthPointer) // We need to identify in the memory where the health pointer is, in order to edit it, if you dont use variables that read those other pointers that lead you to what you want to edit, it won't really work

Writemem.CSGO<int>(Health, 500) // Writes to the pointer you found above you wouldn't have found those pointers if you didnt read the memory.
Ok so if I don't always have too then what would be the downside of not reading?
You don't have to read if you're *directly* accessing the value you need to edit. For example game+0x12345678
If you're accessing a pointer then you could skip reading, but your pointer might become invalid. for example if you read a player pointer, but connect to a different server afterwards it will probably be invalid.
So if I wanted to create an Esp I would have to read then write and to make the ammo infinite I would just write because I'm directly changing the amount/value?
Quote Originally Posted by michaeldardy View Post
So if I wanted to create an Esp I would have to read then write and to make the ammo infinite I would just write because I'm directly changing the amount/value?
If ammo is located at an offset relative to the main module then you only need to write. If it's part of a player pointer, which is likely to change during the duration of your cheat running then you would need to read the player pointer, and then write to pointer+offset.
When you are accessing memory the computer does not care if you have read the data previously or not, as long as you know the correct location to write to you don’t need to read. It would be useful to perform a read before a write in order to verify you have the correct location.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us