This one "0x7def70" is for the 640 resolution value
This one "0x7def74" is for the 480 resolution value
But, when I execute my code it never changes in-game
but in cheat engine it does when I test it in-game what am I doing wrong
in my code or in general?
I'm testing this out on "The lord of the Rings: Fellowship of the ring" pc game.
Here is my code.
#include <iostream>
#include <Windows.h>
using namespace std;
float widthres = 2560;
float heightres = 1080;
int main()
{
HWND hwnd = FindWindowA(NULL, "Lord of The Rings: The Fellowship of The Ring");
if (hwnd == NULL)
{
cout << "cannot find window" << endl;
Sleep(3000);
exit(-1);
}
else
{
DWORD procid;
GetWindowThreadProcessId(hwnd, &procid);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procid);
Seems also when I re-attach my debugger in cheat engine and search the byte array's for each the width and the height results it always changes the memory addresses every damn time this means that the address I had before now does not work after re-run of game?
Then, what can you do to get the right addresses that never change and write to memory to change the width and height values in c++ code?
You should check the result of WriteProcessMemory(...) whether it was successful or not. It returns BOOL.
GetModuleInformation(...) can be used to determine the entry point of the process. When this changes the address in question might change too. You may check whether the two addresses are related. If so you may use an offset rather than the absolute address.
Well, I know the 2 addresses are 4bytes and they are addresses that always change so this is why it does not work I need to find the abolsute 2 offsets instead.
And, the result of WriteProcessMemory is doing what it is suppose to.
So, I need to find the 2 offsets instead of 2 memory addresses that always change in memory.
Seems this is the way to do this I wander if you all have other ways of doing this?
wtf I found the 2 offsets but they seem to change as well everytime you re-run the game?
I must have to change the hex value's at that memory offset for each width and height res's.
I'm pretty sure Windows has address space layout randomization. This can prevent cheats like this from working, as it loads code in different locations in the address space every time the program is executed. It's more of a security feature to prevent injected code from things like buffer overflows from working, but it could be interfering with what you are trying to do here.
To get around that, you're going to somehow figure out where the executable or dll is loaded and calculate offsets from that address rather than absolute addresses.