ReadProcessmemory always return error

Hi all:

I am trying to create a memory scanner, but my readprocessmemory()
line always returns error!

The problem appears to originate from incorrect values/variables fed to the
function.


https://pastebin.com/4KAJLLL3
Last edited on
What's the error?
I'm going to go out on a limb here and guess that the error code you are getting is error code 5; access denied. You need to enable the SeDebug flag on any process reading memory from other processes.

EDIT: Sorry, it just occurred to me that my last post was less than useful.

1
2
3
4
5
6
7
8
9
10
11
12
HANDLE CurrentProc = OpenProcess(PROCESS_ALL_ACCESS, TRUE, GetCurrentProcessId());
HANDLE CurrentToken = NULL;
TOKEN_PRIVILEGES tPriv[1];
        tPriv[0].PrivilegeCount = 1;

OpenProcessToken(CurrentProc, TOKEN_ADJUST_PRIVILEGES, &CurrentToken))
LookupPrivilegeValueA(NULL, "SeDebugPrivilege", &PrivValue))

tPriv[0].Privileges[0].Luid = PrivValue;
tPriv[0].Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

AdjustTokenPrivileges(CurrentToken, FALSE, tPriv, 0, NULL, NULL);

The headers to include are windows.h, winbase.h; also link to what ever version of Advapi32 works with your compiler.
Last edited on
Topic archived. No new replies allowed.