I'm getting error 998 (access denied)
with writeprocessmemory in C++
.
I don't know what I'm doing wrong.
Here's some of my code:
DWORD ProcessId;
GetWindowThreadProcessId(WindowHandle, &ProcessId); //pID
if (ProcessId) {}
else {
cout << "ERROR! Process ID Could not be received." << endl;
return 0;
}
//Get the Process Handle
HANDLE ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessId);
if (ProcessId) {}
else {
cout << "ERROR! Process Handle could not be received." << endl;
return 0;
}
//Get it done with.
bool MemWritten = WriteProcessMemory(ProcessHandle, Address, &NewValue, sizeof(NewValue), NULL);
//Close the process handle to prevent memory leak.
CloseHandle(ProcessHandle);