I wrote a small function for reading the memory of the process, but when it is triggered, the program on which the experiments are conducted flies. What am I doing wrong? Code:
DWORD ReadMemory(DWORD address) { if (!IsBadReadPtr((void*)address, 0x10)) { DWORD buffer = 0; HANDLE phandle = OpenProcess(PROCESS_ALL_ACCESS, 0, GetCurrentProcessId()); if (phandle == NULL) { MessageBoxA(NULL, "Error with handle", NULL, MB_OK); return NULL; } ReadProcessMemory(phandle, (void*)address, (LPVOID)&buffer, 4, NULL); CloseHandle(phandle); return buffer; } else { MessageBoxA(NULL, "Address wasn't finded", NULL, MB_OK); return NULL; } }