1

I'm new to this area of experties so I'm not entirely sure... I know externaly you've got two functions: WriteProcessMemory and ReadProcessMemory , but internally things are different... I'm also not familiar enough with pointers yet to make it myself - but if you can comment it for me I think I'll be okay :).

So, what's the best way to read memory?

By the way, this is my write memory function:

void WriteToMemory(DWORD addressToWrite, char* valueToWrite, int byteNum)
{
    //used to change our file access type, stores the old
    //access type and restores it after memory is written
    unsigned long OldProtection;
    //give that address read and write permissions and store the old permissions at oldProtection
    VirtualProtect((LPVOID)(addressToWrite), byteNum, PAGE_EXECUTE_READWRITE, &OldProtection);

    //write the memory into the program and overwrite previous value
    memcpy((LPVOID)addressToWrite, valueToWrite, byteNum);

    //reset the permissions of the address back to oldProtection after writting memory
    VirtualProtect((LPVOID)(addressToWrite), byteNum, OldProtection, NULL);
}
Naltamer14
  • 187
  • 3
  • 10
  • Not sure what you're asking. "Internally" = read memory from the running process? There's no need for any API for that, just access the memory. Perhaps you're asking about enumerating the loaded DLLs and accessing the memory region mapped to a specific one? – Ofek Shilon Mar 08 '16 at 16:48
  • Like I said, new to this so my terminology isn't good, sorry :P What I started with was an external console program, that wrote memory to another program with WriteProcessMemory. Now I've got a DLL that I inject into a program. I think it's called internally changing memory or similiar... – Naltamer14 Mar 08 '16 at 16:51
  • "not familiar enough with pointers yet" - while that's not necessarily a bad thing in C++, it is bad for the type of things you're trying here. You should be perfectly comfortable with normal pointers before attempting these things. – MSalters Mar 08 '16 at 16:52
  • It's not that I don't understand them, I'm just new to them and new things take a while to get familiarized with :D Anyway, I'm posting one method I used, I'm just not too sure if it's "the best way" to do it. I'm trying not to get caught by cheat detectors if possible. – Naltamer14 Mar 08 '16 at 17:27

1 Answers1

0

Here's one way of doing it:

void ReadFromMemory(DWORD addressToRead, float value)
{
    value = *(float*)addressToRead;
}

Any other suggestions?

Naltamer14
  • 187
  • 3
  • 10