Passing address to WriteProcessMemory

1
I'm trying to pass a memory address to WriteProcessMemory() , but this address should be typed by the user, I'm in doubt how can I do this, I tried with strings, wstring I was not successful.

int isSuccessful = WriteProcessMemory(hproc, /*VALOR DIGITADO PELO USUARIO(LPVOID)0x002bf55c*/, &NewValue, (DWORD)sizeof(NewValue), NULL);
    
asked by anonymous 12.02.2015 / 07:05

1 answer

3

Are you sure you want to do this? It seems that you are wanting to do something very advanced and dangerous and are having a very basic doubt. This combination does not usually work out.

Is the application allowed to write to this area of memory? Luckily the operating system controls this and even though it does not let the application write anywhere in memory. You can not write to other applications or even parts of your own application.

Were the variables used correctly set ? I will consider that yes, after all you did not put every part of the program and you should consider that there is a problem only in this line.

Then just read an integer and use it as a pointer as you were already trying to do. Probably the problem is that I was reading a string .

int endereco;
scanf("%d", &endereco);
int isSuccessful = WriteProcessMemory(hproc, (LPVOID)endereco, &NewValue, (DWORD)sizeof(NewValue), NULL);
    
12.02.2015 / 12:35