I've trying to read memory adress(float type).So, it just return 0 in any cases(I've tried int, float etc. memory adress values).In other programs(Cheat Engine) all works.
#include <windows.h>
#include <process.h>
#include <iostream>
DWORD adresss = 0x00179574;
DWORD pid;
float id;
int main()
{
HWND game = FindWindowA(0, ("Window name"));
GetWindowThreadProcessId(game, &pid);
HANDLE maincs = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
for (;;)
{
ReadProcessMemory(maincs, (void*)adresss, &id, sizeof(int), 0);
std::cout << id << std::endl;
Sleep(100);
}
}
It seems like you are reading the value of an int
from the process, but saving it as a float
. Try to change it to sizeof(float)
. Also, make address
LPVOID
, instead of casting it to a void pointer.
If it still fails, there is one more thing. The address you seem to be reading seems too small. A common address in the process will be like 0x7ff6d91c0000
.
Also, you don't need <Process.h>
, and the last address of ReadProcessMemory
should be nullptr
instead of 0
.